PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
omptough.c File Reference
Include dependency graph for omptough.c:

Go to the source code of this file.

Macros

#define NITER   (100000)
 

Functions

int main (int argc, char *argv[])
 

Macro Definition Documentation

#define NITER   (100000)

Definition at line 9 of file omptough.c.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 12 of file omptough.c.

13 {
14  int i;
15  int ret;
16  int nthreads;
17  int *evtset;
18  int *ctrcode;
19 
20  nthreads = omp_get_max_threads( );
21  evtset = ( int * ) malloc( sizeof ( int ) * nthreads );
22  ctrcode = ( int * ) malloc( sizeof ( int ) * nthreads );
23 
24  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
25 
27  if ( ret != PAPI_VER_CURRENT && ret > 0 ) {
28  fprintf( stderr, "PAPI library version mismatch '%s'\n",
29  PAPI_strerror( ret ) );
30  exit( 1 );
31  }
32 
33  if ( ret < 0 ) {
34  fprintf( stderr, "PAPI initialization error '%s'\n",
35  PAPI_strerror( ret ) );
36  exit( 1 );
37  }
38 
39  if ( ( ret =
40  PAPI_thread_init( ( unsigned long ( * )( void ) ) pthread_self ) ) !=
41  PAPI_OK ) {
42  fprintf( stderr, "PAPI thread initialization error '%s'\n",
43  PAPI_strerror( ret ) );
44  exit( 1 );
45  }
46 
47  for ( i = 0; i < nthreads; i++ ) {
48  evtset[i] = PAPI_NULL;
49 
50  if ( ( ret = PAPI_event_name_to_code( "PAPI_TOT_INS", &ctrcode[i] ) )
51  != PAPI_OK ) {
52  fprintf( stderr, "PAPI evt-name-to-code error '%s'\n",
53  PAPI_strerror( ret ) );
54  }
55 
56  }
57 
58  for ( i = 0; i < NITER; i++ ) {
59 #pragma omp parallel
60  {
61  int tid;
62  int pid;
63  tid = omp_get_thread_num( );
64 
65  pid = pthread_self( );
66 
67  if ( ( ret = PAPI_register_thread( ) ) != PAPI_OK ) {
68  if ( !TESTS_QUIET ) {
69  fprintf( stderr,
70  "[%5d] Error in register thread (tid=%d pid=%d) '%s'\n",
71  i, tid, pid, PAPI_strerror( ret ) );
72  test_fail( __FILE__, __LINE__, "omptough", 1 );
73  }
74  }
75 
76  evtset[tid] = PAPI_NULL;
77  if ( ( ret = PAPI_create_eventset( &( evtset[tid] ) ) ) != PAPI_OK ) {
78  if ( !TESTS_QUIET ) {
79  fprintf( stderr,
80  "[%5d] Error creating eventset (tid=%d pid=%d) '%s'\n",
81  i, tid, pid, PAPI_strerror( ret ) );
82  test_fail( __FILE__, __LINE__, "omptough", 1 );
83  }
84  }
85 
86 
87  if ( ( ret =
88  PAPI_destroy_eventset( &( evtset[tid] ) ) ) != PAPI_OK ) {
89  if ( !TESTS_QUIET ) {
90  fprintf( stderr,
91  "[%5d] Error destroying eventset (tid=%d pid=%d) '%s'\n",
92  i, tid, pid, PAPI_strerror( ret ) );
93  evtset[tid] = PAPI_NULL;
94  test_fail( __FILE__, __LINE__, "omptough", 1 );
95  }
96  }
97 
98  if ( ( ret = PAPI_unregister_thread( ) ) != PAPI_OK ) {
99  if ( !TESTS_QUIET ) {
100  fprintf( stderr,
101  "[%5d] Error in unregister thread (tid=%d pid=%d) ret='%s'\n",
102  i, tid, pid, PAPI_strerror( ret ) );
103  test_fail( __FILE__, __LINE__, "omptough", 1 );
104  }
105  }
106  }
107  }
108  test_pass( __FILE__, NULL, 0 );
109  exit( 1 );
110 }
#define PAPI_NULL
Definition: fpapi.h:13
int PAPI_register_thread(void)
Definition: papi.c:203
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
long long ret
Definition: iozone.c:1346
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_thread_init(unsigned long int(*id_fn)(void))
Definition: papi.c:118
int PAPI_library_init(int version)
Definition: papi.c:495
int i
Definition: fileop.c:140
static int pid
#define NITER
Definition: omptough.c:9
void *long long tid
Definition: iozone.c:18586
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1399
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1003
int PAPI_unregister_thread(void)
Definition: papi.c:239
char * PAPI_strerror(int errorCode)
Definition: papi.c:4470
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1937
void exit()

Here is the call graph for this function: