15#define EVENT PAPI_TOT_CYC
37 long num = (
long ) pthread_getspecific(
key );
40 test_fail( __FILE__, __LINE__,
"getspecific failed", 1 );
51 gettimeofday( &now, NULL );
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] );
76 gettimeofday( &
start, NULL );
80 for (
x = 1.0;
x < 250000.0;
x += 1.0 )
83 printf(
"==>> SUM IS NEGATIVE !! <<==\n" );
87 gettimeofday( &now, NULL );
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 );
199 gettimeofday( &
start, NULL );
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" );
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
initialize the PAPI library.
Set up an event set to begin registering overflows.
Query if PAPI event exists.
removes a hardware event from a PAPI event set.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
Initialize thread support in the PAPI library.
int PAPI_register_thread(void)
int PAPI_unregister_thread(void)
static long iter[MAX_THREADS]
static void * my_thread(void *v)
static long count[MAX_THREADS]
static struct timeval last[MAX_THREADS]
static void print_rate(long num)
static struct timeval start
static void my_handler(int EventSet, void *pc, long long ovec, void *context)
static void do_cycles(long num, int len)
Return codes and api definitions.
unsigned long int pthread_t
unsigned int pthread_key_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)