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

Go to the source code of this file.

Functions

void Thread (int n)
 
int main (int argc, char **argv)
 

Variables

const PAPI_hw_info_thw_info = NULL
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 116 of file zero_omp.c.

117 {
118  int maxthr, retval;
119  long long elapsed_us, elapsed_cyc;
120 
121  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
122 
124  if ( retval != PAPI_VER_CURRENT )
125  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
126 
128  if ( hw_info == NULL )
129  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
130 
131  elapsed_us = PAPI_get_real_usec( );
132 
133  elapsed_cyc = PAPI_get_real_cyc( );
134 
135 
136  retval =
137  PAPI_thread_init( ( unsigned
138  long ( * )( void ) ) ( omp_get_thread_num ) );
139  if ( retval != PAPI_OK ) {
140  if ( retval == PAPI_ECMP )
141  test_skip( __FILE__, __LINE__, "PAPI_thread_init", retval );
142  else
143  test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
144  }
145 #pragma omp parallel private(maxthr)
146  {
147  maxthr = omp_get_num_threads( );
148  Thread( 1000000 * ( omp_get_thread_num( ) + 1 ) );
149  }
150  omp_set_num_threads( 1 );
151  Thread( 1000000 * ( omp_get_thread_num( ) + 1 ) );
152  omp_set_num_threads( omp_get_max_threads( ) );
153 #pragma omp parallel private(maxthr)
154  {
155  maxthr = omp_get_num_threads( );
156  Thread( 1000000 * ( omp_get_thread_num( ) + 1 ) );
157  }
158 
159  elapsed_cyc = PAPI_get_real_cyc( ) - elapsed_cyc;
160 
161  elapsed_us = PAPI_get_real_usec( ) - elapsed_us;
162 
163  if ( !TESTS_QUIET ) {
164  printf( "Master real usec : \t%lld\n", elapsed_us );
165  printf( "Master real cycles : \t%lld\n", elapsed_cyc );
166  }
167 
168  test_pass( __FILE__, NULL, 0 );
169  exit( 0 );
170 }
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
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
long long elapsed_cyc
Definition: zero_fork.c:43
#define PAPI_ECMP
Definition: fpapi.h:109
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
void * Thread(void *arg)
long long PAPI_get_real_usec(void)
Definition: papi.c:6138
long long PAPI_get_real_cyc(void)
Definition: papi.c:6091
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6059
ssize_t retval
Definition: libasync.c:338
long long elapsed_us
Definition: zero_fork.c:43
static const PAPI_hw_info_t * hw_info
Definition: byte_profile.c:23
void exit()

Here is the call graph for this function:

void Thread ( int  n)

Definition at line 51 of file zero_omp.c.

52 {
53  int retval, num_tests = 1;
54  int EventSet1 = PAPI_NULL;
55  int PAPI_event, mask1;
56  int num_events1;
57  long long **values;
58  long long elapsed_us, elapsed_cyc;
60 
61  printf( "Thread %#x started\n", omp_get_thread_num( ) );
62  num_events1 = 2;
63 
64  /* add PAPI_TOT_CYC and one of the events in
65  PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS,
66  depending on the availability of the event
67  on the platform */
68  EventSet1 = add_two_events( &num_events1, &PAPI_event, &mask1 );
69 
70  retval = PAPI_event_code_to_name( PAPI_event, event_name );
71  if ( retval != PAPI_OK )
72  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
73 
74  values = allocate_test_space( num_tests, num_events1 );
75 
76  elapsed_us = PAPI_get_real_usec( );
77 
78  elapsed_cyc = PAPI_get_real_cyc( );
79 
80  retval = PAPI_start( EventSet1 );
81  if ( retval != PAPI_OK )
82  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
83 
84  do_flops( n );
85 
86  retval = PAPI_stop( EventSet1, values[0] );
87  if ( retval != PAPI_OK )
88  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
89 
90  elapsed_us = PAPI_get_real_usec( ) - elapsed_us;
91 
92  elapsed_cyc = PAPI_get_real_cyc( ) - elapsed_cyc;
93 
94  remove_test_events( &EventSet1, mask1 );
95 
96  if ( !TESTS_QUIET ) {
97  printf( "Thread %#x %-12s : \t%lld\n", omp_get_thread_num( ),
98  event_name, values[0][1] );
99  printf( "Thread %#x PAPI_TOT_CYC: \t%lld\n", omp_get_thread_num( ),
100  values[0][0] );
101  printf( "Thread %#x Real usec : \t%lld\n", omp_get_thread_num( ),
102  elapsed_us );
103  printf( "Thread %#x Real cycles : \t%lld\n", omp_get_thread_num( ),
104  elapsed_cyc );
105  }
106 
107  /* It is illegal for the threads to exit in OpenMP */
108  /* test_pass(__FILE__,0,0); */
109  free_test_space( values, num_tests );
110 
112  printf( "Thread %#x finished\n", omp_get_thread_num( ) );
113 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int mask1
Definition: zero_fork.c:41
int PAPI_event[2]
Definition: data_range.c:24
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
int num_events1
Definition: zero_fork.c:42
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
int TESTS_QUIET
Definition: test_utils.c:11
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
long long elapsed_cyc
Definition: zero_fork.c:43
int add_two_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:680
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:131
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
int num_tests
Definition: zero_fork.c:46
void do_flops(int n)
Definition: multiplex.c:23
long long PAPI_get_real_usec(void)
Definition: papi.c:6138
int PAPI_unregister_thread(void)
Definition: papi.c:239
long long PAPI_get_real_cyc(void)
Definition: papi.c:6091
int PAPI_start(int EventSet)
Definition: papi.c:2026
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long elapsed_us
Definition: zero_fork.c:43
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:107
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:277
int EventSet1
Definition: zero_fork.c:40
int n
Definition: mendes-alt.c:164

Here is the call graph for this function:

Variable Documentation

const PAPI_hw_info_t* hw_info = NULL

Definition at line 48 of file zero_omp.c.