PAPI 7.1.0.0
Loading...
Searching...
No Matches
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)
 
unsigned long omp_get_thread_num_wrapper (void)
 
int main (int argc, char **argv)
 

Variables

const PAPI_hw_info_thw_info = NULL
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 133 of file zero_omp.c.

134{
135 int retval;
136 long long elapsed_us, elapsed_cyc;
137 int quiet;
138
139 /* Set TESTS_QUIET variable */
140 quiet = tests_quiet( argc, argv );
141
143 if ( retval != PAPI_VER_CURRENT ) {
144 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
145 }
146
148 if ( hw_info == NULL ) {
149 test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
150 }
151
153 if (!quiet) printf("Can't find PAPI_TOT_INS\n");
154 test_skip(__FILE__,__LINE__,"Event missing",1);
155 }
156
158 if (!quiet) printf("Can't find PAPI_TOT_CYC\n");
159 test_skip(__FILE__,__LINE__,"Event missing",1);
160 }
161
163
165
166
168 if ( retval != PAPI_OK ) {
169 if ( retval == PAPI_ECMP ) {
170 if (!quiet) printf("Trouble init threads\n");
171 test_skip( __FILE__, __LINE__, "PAPI_thread_init", retval );
172 }
173 else {
174 test_fail( __FILE__, __LINE__, "PAPI_thread_init", retval );
175 }
176 }
177#pragma omp parallel
178 {
179 Thread( 1000000 * ( omp_get_thread_num( ) + 1 ) );
180 }
181 omp_set_num_threads( 1 );
182 Thread( 1000000 * ( omp_get_thread_num( ) + 1 ) );
183 omp_set_num_threads( omp_get_max_threads( ) );
184#pragma omp parallel
185 {
186 Thread( 1000000 * ( omp_get_thread_num( ) + 1 ) );
187 }
188
190
192
193 if ( !TESTS_QUIET ) {
194 printf( "Master real usec : \t%lld\n", elapsed_us );
195 printf( "Master real cycles : \t%lld\n", elapsed_cyc );
196 }
197
198 test_pass( __FILE__ );
199
200 return 0;
201}
get information about the system hardware
get real time counter value in clock cycles Returns the total real time passed since some arbitrary s...
get real time counter value in microseconds
initialize the PAPI library.
Query if PAPI event exists.
Initialize thread support in the PAPI library.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_TOT_CYC
Definition: f90papi.h:308
#define PAPI_ECMP
Definition: f90papi.h:214
#define PAPI_TOT_INS
Definition: f90papi.h:317
int TESTS_QUIET
Definition: test_utils.c:18
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int quiet
Definition: rapl_overflow.c:19
long long elapsed_cyc
Definition: zero_fork.c:50
long long elapsed_us
Definition: zero_fork.c:50
int retval
Definition: zero_fork.c:53
const PAPI_hw_info_t * hw_info
Definition: zero_omp.c:54
void Thread(int n)
Definition: zero_omp.c:57
unsigned long omp_get_thread_num_wrapper(void)
Definition: zero_omp.c:128
Here is the call graph for this function:

◆ omp_get_thread_num_wrapper()

unsigned long omp_get_thread_num_wrapper ( void  )

Definition at line 128 of file zero_omp.c.

128 {
129 return (unsigned long)omp_get_thread_num();
130}
Here is the caller graph for this function:

◆ Thread()

void Thread ( int  n)

Definition at line 57 of file zero_omp.c.

58{
59 int retval, num_tests = 1;
60 int EventSet1 = PAPI_NULL;
61 int PAPI_event, mask1;
62 int num_events1;
63 long long **values;
64 long long elapsed_us, elapsed_cyc;
66
67 if (!TESTS_QUIET) {
68 printf( "Thread %#x started\n", omp_get_thread_num( ) );
69 }
70
71 /* add PAPI_TOT_CYC and one of the events in
72 PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS,
73 depending on the availability of the event
74 on the platform */
76 if (num_events1==0) {
77 if (!TESTS_QUIET) printf("No events added!\n");
78 test_fail(__FILE__,__LINE__,"No events",0);
79 }
80
82 if ( retval != PAPI_OK )
83 test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
84
86
88
90
92 if ( retval != PAPI_OK )
93 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
94
95 do_flops( n );
96
98 if ( retval != PAPI_OK )
99 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
100
102
104
106
107 if ( !TESTS_QUIET ) {
108 printf( "Thread %#x %-12s : \t%lld\n", omp_get_thread_num( ),
109 event_name, values[0][1] );
110 printf( "Thread %#x PAPI_TOT_CYC: \t%lld\n", omp_get_thread_num( ),
111 values[0][0] );
112 printf( "Thread %#x Real usec : \t%lld\n", omp_get_thread_num( ),
113 elapsed_us );
114 printf( "Thread %#x Real cycles : \t%lld\n", omp_get_thread_num( ),
115 elapsed_cyc );
116 }
117
118 /* It is illegal for the threads to exit in OpenMP */
119 /* test_pass(__FILE__,0,0); */
121
123 if (!TESTS_QUIET) {
124 printf( "Thread %#x finished\n", omp_get_thread_num( ) );
125 }
126}
Convert a numeric hardware event code to a name.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
Notify PAPI that a thread has 'disappeared'.
int PAPI_event[2]
Definition: data_range.c:30
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void do_flops(int n)
Definition: multiplex.c:23
void free_test_space(long long **values, int num_tests)
Definition: test_utils.c:70
long long ** allocate_test_space(int num_tests, int num_events)
Definition: test_utils.c:46
int add_two_events(int *num_events, int *papi_event, int *mask)
Definition: test_utils.c:640
int remove_test_events(int *EventSet, int mask)
Definition: test_utils.c:201
int EventSet1
Definition: zero_fork.c:47
int num_events1
Definition: zero_fork.c:49
int mask1
Definition: zero_fork.c:48
int num_tests
Definition: zero_fork.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ hw_info

const PAPI_hw_info_t* hw_info = NULL

Definition at line 54 of file zero_omp.c.