172{
174 long n;
176
177
179
180 if ( argc < 2 || sscanf( argv[1],
"%d", &
program_time ) < 1 )
182 if ( argc < 3 || sscanf( argv[2],
"%d", &
threshold ) < 1 )
184 if ( argc < 4 || sscanf( argv[3],
"%d", &
num_threads ) < 1 )
186
188 if (!td) {
189 test_fail( __FILE__, __LINE__,
"td malloc failed", 1 );
190 }
191
193 printf( "program_time = %d, threshold = %d, num_threads = %d\n\n",
195 }
196
198 test_fail( __FILE__, __LINE__,
"PAPI_library_init failed", 1 );
199
200
203 if (!
quiet) printf(
"Trouble finding event\n");
204 test_skip(__FILE__,__LINE__,
"Event not available",1);
205 }
206
207 if (
PAPI_thread_init( (
unsigned long ( * )(
void ) ) ( pthread_self ) ) !=
209 test_fail( __FILE__, __LINE__,
"PAPI_thread_init failed", 1 );
210
211 if ( pthread_key_create( &
key, NULL ) != 0 )
212 test_fail( __FILE__, __LINE__,
"pthread key create failed", 1 );
213
214 gettimeofday( &
start, NULL );
215
217 if ( pthread_create( &(td[n]), NULL,
my_thread, (
void * ) n ) != 0 )
218 test_fail( __FILE__, __LINE__,
"pthread create failed", 1 );
219 }
220
222
223
225 if ( pthread_join( td[n], NULL))
226 test_fail( __FILE__, __LINE__,
"pthread join failed", 1 );
227 }
228
229 free(td);
230
231 if (!
quiet) printf(
"done\n" );
232
234
235 return 0;
236}
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)