5 #define MAX_THREADS 256 15 #define EVENT PAPI_TOT_CYC 37 long num = ( long ) pthread_getspecific(
key );
40 test_fail( __FILE__, __LINE__,
"getspecific failed", 1 );
55 if ( last_secs <= 0.001 )
59 printf(
"[%ld] time = %ld, count = %ld, iter = %ld, " 60 "rate = %.1f/Kiter\n",
62 ( 1000.0 * (
double )
count[num] ) / (
double )
iter[num] );
80 for (
x = 1.0;
x < 250000.0;
x += 1.0 )
83 printf(
"==>> SUM IS NEGATIVE !! <<==\n" );
96 long num = ( long ) v;
107 pthread_setspecific(
key, v );
115 test_fail( __FILE__, __LINE__,
"PAPI_create_eventset failed",
retval );
120 if (!
TESTS_QUIET) printf(
"Trouble adding event\n");
125 test_fail( __FILE__, __LINE__,
"PAPI_overflow failed", 1 );
128 test_fail( __FILE__, __LINE__,
"PAPI_start failed", 1 );
130 if (!
TESTS_QUIET) printf(
"launched timer in thread %ld\n", num );
141 test_fail( __FILE__, __LINE__,
"PAPI_overflow failed to reset the overflow handler",
retval );
144 test_fail( __FILE__, __LINE__,
"PAPI_remove_event", 1 );
147 test_fail( __FILE__, __LINE__,
"PAPI_destroy_eventset", 1 );
150 test_fail( __FILE__, __LINE__,
"PAPI_unregister_thread", 1 );
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 )
174 test_fail( __FILE__, __LINE__,
"td malloc failed", 1 );
178 printf(
"program_time = %d, threshold = %d, num_threads = %d\n\n",
183 test_fail( __FILE__, __LINE__,
"PAPI_library_init failed", 1 );
188 if (!
quiet) printf(
"Trouble finding event\n");
189 test_skip(__FILE__,__LINE__,
"Event not available",1);
192 if (
PAPI_thread_init( (
unsigned long ( * )(
void ) ) ( pthread_self ) ) !=
194 test_fail( __FILE__, __LINE__,
"PAPI_thread_init failed", 1 );
196 if ( pthread_key_create( &
key, NULL ) != 0 )
197 test_fail( __FILE__, __LINE__,
"pthread key create failed", 1 );
202 if ( pthread_create( &(td[n]), NULL,
my_thread, (
void * ) n ) != 0 )
203 test_fail( __FILE__, __LINE__,
"pthread create failed", 1 );
210 if ( pthread_join( td[n], NULL))
211 test_fail( __FILE__, __LINE__,
"pthread join failed", 1 );
216 if (!
quiet) printf(
"done\n" );
int PAPI_stop(int EventSet, long long *values)
void test_pass(const char *filename)
int PAPI_add_event(int EventSet, int EventCode)
unsigned long int pthread_t
int PAPI_remove_event(int EventSet, int EventCode)
static void print_rate(long num)
int PAPI_register_thread(void)
int PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler)
static struct timeval start
static void * my_thread(void *v)
static long count[MAX_THREADS]
int main(int argc, char **argv)
Return codes and api definitions.
void test_skip(const char *file, int line, const char *call, int retval)
int PAPI_thread_init(unsigned long int(*id_fn)(void))
int PAPI_library_init(int version)
static long iter[MAX_THREADS]
static struct timeval last[MAX_THREADS]
static void my_handler(int EventSet, void *pc, long long ovec, void *context)
int PAPI_create_eventset(int *EventSet)
int PAPI_query_event(int EventCode)
static void do_cycles(long num, int len)
int gettimeofday(void *ptr1, void *ptr2)
int PAPI_unregister_thread(void)
int tests_quiet(int argc, char **argv)
void test_fail(const char *file, int line, const char *call, int retval)
int PAPI_destroy_eventset(int *EventSet)
int PAPI_start(int EventSet)
unsigned int pthread_key_t