PAPI 7.1.0.0
Loading...
Searching...
No Matches
The High Level API

Functions

int PAPI_hl_region_begin (const char *region)
 
int PAPI_hl_read (const char *region)
 
int PAPI_hl_region_end (const char *region)
 
int PAPI_hl_stop (void)
 

Detailed Description

The simple interface implemented by the following routines allows the user to record hardware events inside instrumented regions from both C and Fortran.

Function Documentation

◆ PAPI_hl_read()

int PAPI_hl_read ( const char *  region)

read performance events inside of a region and store the difference to the corresponding beginning of the region

Definition at line 2013 of file papi_hl.c.

2014{
2015 int retval;
2016
2017 if ( state == PAPIHL_DEACTIVATED ) {
2018 /* check if we have to clean up local stuff */
2019 if ( _local_state == PAPIHL_ACTIVE )
2021 return ( PAPI_EMISC );
2022 }
2023
2024 if ( _local_region_begin_cnt == 0 ) {
2025 verbose_fprintf(stdout, "PAPI-HL Warning: Cannot find matching region for PAPI_hl_read(\"%s\") for thread %lu.\n", region, PAPI_thread_id());
2026 return ( PAPI_EMISC );
2027 }
2028
2029 if ( _local_components == NULL )
2030 return ( PAPI_ENOTRUN );
2031
2032 /* read and store all events */
2033 HLDBG("Thread ID:%lu, Region:%s\n", PAPI_thread_id(), region);
2035 return ( retval );
2036
2037 return ( PAPI_OK );
2038}
Get the thread identifier of the current thread.
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_EMISC
Definition: f90papi.h:122
#define PAPI_ENOTRUN
Definition: f90papi.h:146
#define HLDBG(format, args...)
Definition: papi_debug.h:73
FILE * stdout
#define PAPIHL_ACTIVE
Definition: papi_hl.c:44
#define PAPIHL_DEACTIVATED
Definition: papi_hl.c:45
THREAD_LOCAL_STORAGE_KEYWORD unsigned int _local_region_begin_cnt
Definition: papi_hl.c:82
@ REGION_READ
Definition: papi_hl.c:143
static int _internal_hl_read_and_store_counters(const char *region, enum region_type reg_typ)
Definition: papi_hl.c:1075
bool state
Definition: papi_hl.c:155
THREAD_LOCAL_STORAGE_KEYWORD local_components_t * _local_components
Definition: papi_hl.c:79
static void _internal_hl_clean_up_local_data()
Definition: papi_hl.c:1608
#define verbose_fprintf
Definition: papi_hl.c:37
THREAD_LOCAL_STORAGE_KEYWORD volatile bool _local_state
Definition: papi_hl.c:81
int retval
Definition: zero_fork.c:53

◆ PAPI_hl_region_begin()

int PAPI_hl_region_begin ( const char *  region)

read performance events at the beginning of a region

Definition at line 1900 of file papi_hl.c.

1901{
1902 int retval;
1903 /* if a rate event set is running stop it */
1904 if ( _papi_rate_events_running == 1 ) {
1905 if ( ( retval = PAPI_rate_stop() ) != PAPI_OK )
1906 return ( retval );
1907 }
1908
1909 if ( state == PAPIHL_DEACTIVATED ) {
1910 /* check if we have to clean up local stuff */
1911 if ( _local_state == PAPIHL_ACTIVE )
1913 return ( PAPI_EMISC );
1914 }
1915
1916 if ( hl_finalized == true )
1917 return ( PAPI_ENOTRUN );
1918
1919 if ( hl_initiated == false ) {
1920 if ( ( retval = _internal_PAPI_hl_init() ) != PAPI_OK )
1921 return ( retval );
1922 }
1923
1924 if ( events_determined == false ) {
1925 if ( ( retval = _internal_PAPI_hl_set_events(NULL) ) != PAPI_OK )
1926 return ( retval );
1927 }
1928
1929 if ( _local_components == NULL ) {
1931 HLDBG("Could not create local events sets for thread %lu.\n", PAPI_thread_id());
1933 return ( retval );
1934 }
1935 }
1936
1937 if ( _papi_hl_events_running == 0 ) {
1938 if ( ( retval = _internal_hl_start_counters() ) != PAPI_OK ) {
1939 HLDBG("Could not start counters for thread %lu.\n", PAPI_thread_id());
1941 return ( retval );
1942 }
1943 }
1944
1945 /* read and store all events */
1946 HLDBG("Thread ID:%lu, Region:%s\n", PAPI_thread_id(), region);
1948 return ( retval );
1949
1950 if ( ( retval = _internal_hl_region_id_push() ) != PAPI_OK ) {
1951 verbose_fprintf(stdout, "PAPI-HL Warning: Number of nested regions exceeded for thread %lu.\n", PAPI_thread_id());
1953 return ( retval );
1954 }
1956 return ( PAPI_OK );
1957}
Stop a running event set of a rate function.
int _internal_PAPI_hl_set_events(const char *events)
Definition: papi_hl.c:1796
static int _internal_hl_region_id_push()
Definition: papi_hl.c:816
bool hl_initiated
Definition: papi_hl.c:148
bool hl_finalized
Definition: papi_hl.c:149
@ REGION_BEGIN
Definition: papi_hl.c:143
static int _internal_hl_create_event_sets()
Definition: papi_hl.c:732
int _internal_PAPI_hl_init()
Definition: papi_hl.c:1758
static int _internal_hl_start_counters()
Definition: papi_hl.c:786
bool events_determined
Definition: papi_hl.c:150
static void _internal_hl_clean_up_all(bool deactivate)
Definition: papi_hl.c:1688
THREAD_LOCAL_STORAGE_KEYWORD int _papi_hl_events_running
Definition: papi_internal.c:63
THREAD_LOCAL_STORAGE_KEYWORD int _papi_rate_events_running
Definition: papi_internal.c:62

◆ PAPI_hl_region_end()

int PAPI_hl_region_end ( const char *  region)

read performance events at the end of a region and store the difference to the corresponding beginning of the region

Definition at line 2131 of file papi_hl.c.

2132{
2133 int retval;
2134
2135 if ( state == PAPIHL_DEACTIVATED ) {
2136 /* check if we have to clean up local stuff */
2137 if ( _local_state == PAPIHL_ACTIVE )
2139 return ( PAPI_EMISC );
2140 }
2141
2142 if ( _local_region_begin_cnt == 0 ) {
2143 verbose_fprintf(stdout, "PAPI-HL Warning: Cannot find matching region for PAPI_hl_region_end(\"%s\") for thread %lu.\n", region, PAPI_thread_id());
2144 return ( PAPI_EMISC );
2145 }
2146
2147 if ( _local_components == NULL )
2148 return ( PAPI_ENOTRUN );
2149
2150 /* read and store all events */
2151 HLDBG("Thread ID:%lu, Region:%s\n", PAPI_thread_id(), region);
2153 return ( retval );
2154
2157 return ( PAPI_OK );
2158}
THREAD_LOCAL_STORAGE_KEYWORD unsigned int _local_region_end_cnt
Definition: papi_hl.c:83
@ REGION_END
Definition: papi_hl.c:143
static int _internal_hl_region_id_pop()
Definition: papi_hl.c:807

◆ PAPI_hl_stop()

int PAPI_hl_stop ( void  )

stops a running high-level event set

Definition at line 2184 of file papi_hl.c.

2185{
2186 int retval, i;
2187
2188 if ( _papi_hl_events_running == 1 ) {
2189 if ( _local_components != NULL ) {
2190 for ( i = 0; i < num_of_components; i++ ) {
2192 return ( retval );
2193 }
2194 }
2196 return ( PAPI_OK );
2197 }
2198 return ( PAPI_ENOEVNT );
2199}
int i
Stop counting hardware events in an event set.
#define PAPI_ENOEVNT
Definition: f90papi.h:139
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
int num_of_components
Definition: papi_hl.c:63