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 );
char event_name[2][PAPI_MAX_STR_LEN]
int PAPI_stop(int EventSet, long long *values)
void test_pass(const char *filename)
unsigned long int pthread_t
get the executable's info
int PAPI_register_thread(void)
#define PAPI_PROFIL_POSIX
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)
int PAPI_profil(void *buf, unsigned bufsiz, caddr_t offset, unsigned scale, int EventSet, int EventCode, int threshold, int flags)
const PAPI_exe_info_t * PAPI_get_executable_info(void)
PAPI_address_map_t address_info
void free_test_space(long long **values, int num_tests)
int PAPI_event_code_to_name(int EventCode, char *out)
int PAPI_query_event(int EventCode)
long long PAPI_get_real_usec(void)
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 main(int argc, char **argv)
int add_two_nonderived_events(int *num_events, int *papi_event, int *mask)
long long PAPI_get_real_cyc(void)
int PAPI_start(int EventSet)
static long long values[NUM_EVENTS]
long long ** allocate_test_space(int num_tests, int num_events)
int remove_test_events(int *EventSet, int mask)