157{
159 long n;
161
162
164
165 if ( argc < 2 || sscanf( argv[1],
"%d", &
program_time ) < 1 )
167 if ( argc < 3 || sscanf( argv[2],
"%d", &
threshold ) < 1 )
169 if ( argc < 4 || sscanf( argv[3],
"%d", &
num_threads ) < 1 )
171
173 if (!td) {
174 test_fail( __FILE__, __LINE__,
"td malloc failed", 1 );
175 }
176
178 printf( "program_time = %d, threshold = %d, num_threads = %d\n\n",
180 }
181
183 test_fail( __FILE__, __LINE__,
"PAPI_library_init failed", 1 );
184
185
188 if (!
quiet) printf(
"Trouble finding event\n");
189 test_skip(__FILE__,__LINE__,
"Event not available",1);
190 }
191
192 if (
PAPI_thread_init( (
unsigned long ( * )(
void ) ) ( pthread_self ) ) !=
194 test_fail( __FILE__, __LINE__,
"PAPI_thread_init failed", 1 );
195
196 if ( pthread_key_create( &
key, NULL ) != 0 )
197 test_fail( __FILE__, __LINE__,
"pthread key create failed", 1 );
198
199 gettimeofday( &
start, NULL );
200
202 if ( pthread_create( &(td[n]), NULL,
my_thread, (
void * ) n ) != 0 )
203 test_fail( __FILE__, __LINE__,
"pthread create failed", 1 );
204 }
205
207
208
210 if ( pthread_join( td[n], NULL))
211 test_fail( __FILE__, __LINE__,
"pthread join failed", 1 );
212 }
213
214 free(td);
215
216 if (!
quiet) printf(
"done\n" );
217
219
220 return 0;
221}
initialize the PAPI library.
Query if PAPI event exists.
Initialize thread support in the PAPI library.
static void * my_thread(void *v)
unsigned long int pthread_t
int tests_quiet(int argc, char **argv)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)