14#define FLOPS 100000000
35 profbuf = (
unsigned short * ) malloc(
length *
sizeof (
unsigned short ) );
37 test_fail(__FILE__, __LINE__,
"Allocate memory",0);
91 printf(
"Thread %#x PAPI_TOT_INS : \t%lld\n",
92 (
int ) pthread_self( ), (
values[0] )[0] );
94 printf(
"Thread %#x PAPI_FP_INS : \t%lld\n",
95 (
int ) pthread_self( ), (
values[0] )[0] );
97 printf(
"Thread %#x PAPI_TOT_CYC: \t%lld\n", (
int ) pthread_self( ),
99 printf(
"Thread %#x Real usec : \t%lld\n", (
int ) pthread_self( ),
101 printf(
"Thread %#x Real cycles : \t%lld\n", (
int ) pthread_self( ),
104 printf(
"Test case: PAPI_profil() for pthreads\n" );
105 printf(
"----Profile buffer for Thread %#x---\n",
106 (
int ) pthread_self( ) );
109 printf(
"%#lx\t%d\n", (
unsigned long ) (
my_start + 2 *
i ),
118 test_fail( __FILE__, __LINE__,
"No information in buffers", 1 );
152 if (!
quiet) printf(
"Trouble adding event\n");
153 test_skip(__FILE__,__LINE__,
"No events",0);
177 pthread_attr_init( &attr );
178#ifdef PTHREAD_CREATE_UNDETACHED
179 pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_UNDETACHED );
181#ifdef PTHREAD_SCOPE_SYSTEM
182 retval = pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM );
189 rc = pthread_create( &
id[
i], &attr,
Thread, (
void * ) &flops[
i] );
194 pthread_join(
id[
i], NULL );
196 pthread_attr_destroy( &attr );
203 printf(
"Master real usec : \t%lld\n",
elapsed_us );
204 printf(
"Master real cycles : \t%lld\n",
elapsed_cyc );
209 pthread_exit( NULL );
Convert a numeric hardware event code to a name.
Get the executable's address space info.
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.
Generate a histogram of hardware counter overflows vs. PC addresses.
Query if PAPI event exists.
Notify PAPI that a thread has 'appeared'.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
Initialize thread support in the PAPI library.
Notify PAPI that a thread has 'disappeared'.
char event_name[2][PAPI_MAX_STR_LEN]
#define PAPI_PROFIL_POSIX
static long long values[NUM_EVENTS]
Return codes and api definitions.
unsigned long int pthread_t
int tests_quiet(int argc, char **argv)
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
void free_test_space(long long **values, int num_tests)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
long long ** allocate_test_space(int num_tests, int num_events)
void PAPI_NORETURN test_pass(const char *filename)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
int remove_test_events(int *EventSet, int mask)
get the executable's info
PAPI_address_map_t address_info