/** @class PAPI_stop_counters * @brief Stop counting hardware events and reset values to zero. * * @par C Interface: * \#include <papi.h> @n * int PAPI_stop_counters( long long *values, int array_len ); * * @param *values * an array where to put the counter values * @param array_len * the number of items in the *values array * * @post * After this function is called, the values are reset to zero. * * @retval PAPI_EINVAL * One or more of the arguments is invalid. * @retval PAPI_ENOTRUN * The EventSet is not started yet. * @retval PAPI_ENOEVST * The EventSet has not been added yet. * * The PAPI_stop_counters() function stops the counters and copies the counts * into the *values array. * The counters must have been started by a previous call to PAPI_start_counters(). * * \code int Events[2] = { PAPI_TOT_CYC, PAPI_TOT_INS }; long long values[2]; if ( PAPI_start_counters( Events, 2 ) != PAPI_OK ) handle_error(1); your_slow_code(); if ( PAPI_stop_counters( values, 2 ) != PAPI_OK ) handle_error(1); * \endcode * * @see PAPI_read_counters() PAPI_start_counters() PAPI_set_opt() */ int PAPI_stop_counters( long long *values, int array_len ) { int retval; HighLevelInfo *state = NULL; if ( ( retval = _internal_check_state( &state ) ) != PAPI_OK ) return ( retval ); if ( state->running == 0 ) return ( PAPI_ENOTRUN ); if ( state->running == HL_START ) { if ( array_len < state->num_evts || values == NULL) { return ( PAPI_EINVAL ); } else { retval = PAPI_stop( state->EventSet, values ); } } if ( state->running > HL_START ) { long long tmp_values[3]; retval = PAPI_stop( state->EventSet, tmp_values ); } if ( retval == PAPI_OK ) { _internal_cleanup_hl_info( state ); PAPI_cleanup_eventset( state->EventSet ); } APIDBG( "PAPI_stop_counters returns %d\n", retval ); return retval; }
int PAPI_stop_counters(long long * values, int array_len) { int retval; HighLevelInfo *state = NULL; if ((retval = _internal_check_state(&state)) != PAPI_OK) return (retval); if (state->running == 0) return (PAPI_ENOTRUN); if (state->running == HL_FLOPS || state->running == HL_FLIPS || state->running == HL_IPC) { long long tmp_values[2]; retval = PAPI_stop(state->EventSet, tmp_values); } else if(state->running != HL_START_COUNTERS || array_len < state->num_evts) return (PAPI_EINVAL); else retval = PAPI_stop(state->EventSet, values); if (retval==PAPI_OK) { _internal_cleanup_hl_info(state); PAPI_cleanup_eventset(state->EventSet); } APIDBG("PAPI_stop_counters returns %d\n", retval); return retval; }
void esd_metric_free(struct esd_metv* metv) { int retval, i; long_long papi_vals[ELG_METRIC_MAXNUM]; if ( metv == NULL ) return; /* treat PAPI failures at this point as non-fatal */ /* KF: do everything for all components with counters */ for( i=0; i<ELG_PAPIC_MAX_COMP; i++ ) { if( metv->NumEvents[i]==0 ) continue; retval = PAPI_stop(metv->EventSet[i], papi_vals); if ( retval != PAPI_OK ) { esd_metric_warning(retval, "PAPI_stop"); } else { /* cleanup/destroy require successful PAPI_stop */ retval = PAPI_cleanup_eventset(metv->EventSet[i]); if ( retval != PAPI_OK ) esd_metric_warning(retval, "PAPI_cleanup_eventset"); retval = PAPI_destroy_eventset(&metv->EventSet[i]); if ( retval != PAPI_OK ) esd_metric_warning(retval, "PAPI_destroy_eventset"); free(metv); elg_cntl_msg("Counters stopped"); } } }
void GPTL_PAPIfinalize (int maxthreads) { int t; /* thread index */ int ret; /* return code */ for (t = 0; t < maxthreads; t++) { ret = PAPI_stop (EventSet[t], papicounters[t]); free (papicounters[t]); ret = PAPI_cleanup_eventset (EventSet[t]); ret = PAPI_destroy_eventset (&EventSet[t]); } free (EventSet); free (papicounters); /* Reset initial values */ npapievents = 0; nevents = 0; is_multiplexed = false; narrowprint = true; persec = true; enable_multiplexing = false; verbose = false; }
void vt_metric_free(struct vt_metv* metv, uint32_t tid) { int retval, i; long_long papi_vals[VT_METRIC_MAXNUM]; if ( metv == NULL ) return; /* treat PAPI failures at this point as non-fatal */ VT_SUSPEND_IO_TRACING(tid); /* foreach used eventset */ for (i=0; i < VT_METRIC_MAXNUM && metv->EventSet[i]!=NULL; i++) { retval = PAPI_stop(metv->EventSet[i]->EventId, papi_vals); if ( retval != PAPI_OK ) { metric_warning(retval, "PAPI_stop"); } else { /* cleanup/destroy require successful PAPI_stop */ retval = PAPI_cleanup_eventset(metv->EventSet[i]->EventId); if ( retval != PAPI_OK ) metric_warning(retval, "PAPI_cleanup_eventset"); retval = PAPI_destroy_eventset(&metv->EventSet[i]->EventId); if ( retval != PAPI_OK ) metric_warning(retval, "PAPI_destroy_eventset"); } free(metv->EventSet[i]); } VT_RESUME_IO_TRACING(tid); free(metv); }
void vt_metric_free(struct vt_metv* metv) { int retval; long_long papi_vals[VT_METRIC_MAXNUM]; if ( metv == NULL ) return; /* treat PAPI failures at this point as non-fatal */ retval = PAPI_stop(metv->EventSet, papi_vals); if ( retval != PAPI_OK ) { vt_metric_warning(retval, "PAPI_stop"); } else { /* cleanup/destroy require successful PAPI_stop */ retval = PAPI_cleanup_eventset(metv->EventSet); if ( retval != PAPI_OK ) vt_metric_warning(retval, "PAPI_cleanup_eventset"); retval = PAPI_destroy_eventset(&metv->EventSet); if ( retval != PAPI_OK ) vt_metric_warning(retval, "PAPI_destroy_eventset"); free(metv); /*vt_cntl_msg("Counters stopped");*/ } }
JNIEXPORT jint JNICALL Java_papi_Wrapper_eventSetStop (JNIEnv *env, jclass UNUSED_ARG(self), jlong eventsetid, jlongArray valuesarr) { if (valuesarr == NULL) { return PAPI_EINVAL; } int values_count = (*env)->GetArrayLength(env, valuesarr); if (values_count == 0) { return PAPI_EINVAL; } int eventset = (int) eventsetid; jlong *valuesj = (*env)->GetLongArrayElements(env, valuesarr, NULL); long long *values = (long long *) valuesj; int rc = PAPI_stop(eventset, values); if (rc == PAPI_OK) { (*env)->ReleaseLongArrayElements(env, valuesarr, valuesj, JNI_COMMIT); } else { (*env)->ReleaseLongArrayElements(env, valuesarr, valuesj, JNI_ABORT); } DEBUG_PRINT("returning %d (%s)", rc, PAPI_strerror(rc)); return rc; }
Timing::~Timing(){ #ifdef KRIPKE_USE_PAPI long long tmp[16]; PAPI_stop(papi_set, tmp); #endif }
int _hl_rate_calls(float *real_time, float *proc_time, long long * ins, float *rate, int EVENT, HighLevelInfo * state) { long long values[2] = { 0, 0 }; int retval = 0; int level = 0; if (EVENT == PAPI_FP_INS) level = HL_FLIPS; else if (EVENT == PAPI_TOT_INS) level = HL_IPC; else if (EVENT == PAPI_FP_OPS) level = HL_FLOPS; if (state->running != 0 && state->running != level) return (PAPI_EINVAL); if (state->running == 0) { if (PAPI_query_event(EVENT) != PAPI_OK) return (PAPI_ENOEVNT); if ((retval = PAPI_add_event(state->EventSet, EVENT)) != PAPI_OK) { _internal_cleanup_hl_info(state); PAPI_cleanup_eventset(state->EventSet); return (retval); } if (PAPI_query_event(PAPI_TOT_CYC) != PAPI_OK) return (PAPI_ENOEVNT); if ((retval = PAPI_add_event(state->EventSet, PAPI_TOT_CYC)) != PAPI_OK) { _internal_cleanup_hl_info(state); PAPI_cleanup_eventset(state->EventSet); return (retval); } state->initial_time = PAPI_get_real_usec(); if ((retval = PAPI_start(state->EventSet)) != PAPI_OK) return (retval); state->running = level; } else { if ((retval = PAPI_stop(state->EventSet, values)) != PAPI_OK) return (retval); /* Use Multiplication because it is much faster */ *real_time = (float) ((long long)(PAPI_get_real_usec() - state->initial_time) * .000001); *proc_time = (float) (values[1]*.000001/((_papi_hwi_system_info.hw_info.mhz==0)?1:_papi_hwi_system_info.hw_info.mhz)); if (*proc_time > 0) *rate = (float) ((float) values[0]*(EVENT==PAPI_TOT_INS?1:_papi_hwi_system_info.hw_info.mhz)/(values[1]==0?1:values[1])); state->total_proc_time += *proc_time; state->total_ins += values[0]; *proc_time = state->total_proc_time; *ins = (long long)state->total_ins; if ((retval = PAPI_start(state->EventSet)) != PAPI_OK) { state->running = 0; return (retval); } } return PAPI_OK; }
void polybench_papi_stop_counter(int evid) { # ifdef _OPENMP # pragma omp parallel { if (omp_get_thread_num () == polybench_papi_counters_threadid) { # endif int retval; long_long values[1]; values[0] = 0; if ((retval = PAPI_read (polybench_papi_eventset, &values[0])) != PAPI_OK) test_fail (__FILE__, __LINE__, "PAPI_read", retval); if ((retval = PAPI_stop (polybench_papi_eventset, NULL)) != PAPI_OK) test_fail (__FILE__, __LINE__, "PAPI_stop", retval); polybench_papi_values[evid] = values[0]; if ((retval = PAPI_remove_event (polybench_papi_eventset, polybench_papi_eventlist[evid])) != PAPI_OK) test_fail (__FILE__, __LINE__, "PAPI_remove_event", retval); # ifdef _OPENMP } } #pragma omp barrier # endif }
static void resultline( int i, int j, int EventSet ) { float ferror = 0; long long flpins = 0; long long papi, theory; int diff, retval; const PAPI_hw_info_t *hwinfo = NULL; retval = PAPI_stop( EventSet, &flpins ); if ( retval != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); i++; /* convert to 1s base */ theory = 2; while ( j-- ) theory *= i; /* theoretical ops */ papi = flpins << FMA; diff = ( int ) ( papi - theory ); ferror = ( ( float ) abs( diff ) ) / ( ( float ) theory ) * 100; printf( "%8d %12lld %12lld %8d %10.4f\n", i, papi, theory, diff, ferror ); #ifndef DONT_FAIL if ( ( hwinfo = PAPI_get_hardware_info( ) ) == NULL ) test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 1 ); if ( hwinfo->vendor != PAPI_VENDOR_AMD && ferror > MAX_ERROR && abs( diff ) > MAX_DIFF && i > 20 ) test_fail( __FILE__, __LINE__, "Calibrate: error exceeds 10%", PAPI_EMISC ); #endif }
static void measure_event( int index, PAPI_option_t * option ) { int retval; long long value; if ( ( retval = PAPI_add_event( EventSet, PAPI_event[index] ) ) != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_add_event", retval ); if ( index == 0 ) { /* if ((retval = PAPI_get_opt(PAPI_DATA_ADDRESS, option)) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_get_opt(PAPI_DATA_ADDRESS)", retval); */ printf ( "Requested Start Address: %p; Start Offset: 0x%5x; Actual Start Address: %p\n", option->addr.start, option->addr.start_off, option->addr.start - option->addr.start_off ); printf ( "Requested End Address: %p; End Offset: 0x%5x; Actual End Address: %p\n", option->addr.end, option->addr.end_off, option->addr.end + option->addr.end_off ); } PAPI_start( EventSet ); do_malloc_work( NUM ); do_static_work( NUM ); PAPI_stop( EventSet, &value ); printf( "%s: %lld\n", event_name[index], value ); if ( ( retval = PAPI_remove_event( EventSet, PAPI_event[index] ) ) != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_remove_event", retval ); }
void *Thread(void *arg) { int retval, num_tests = 1; int EventSet1=PAPI_NULL; int mask1, papi_event; int num_events1; long long **values; long long elapsed_us, elapsed_cyc; char event_name[PAPI_MAX_STR_LEN]; /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS, depends on the availability of the event on the platform */ EventSet1 = add_two_nonderived_events(&num_events1, &papi_event, hw_info, &mask1); expected[EventSet1] = *(int *)arg / mythreshold; myid[EventSet1] = PAPI_thread_id(); values = allocate_test_space(num_tests, num_events1); elapsed_us = PAPI_get_real_usec(); elapsed_cyc = PAPI_get_real_cyc(); if ((retval = PAPI_overflow(EventSet1, papi_event, mythreshold, 0, handler)) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_overflow", retval); /* start_timer(1); */ if ((retval = PAPI_start(EventSet1)) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_start", retval); do_stuff(); if ((retval = PAPI_stop(EventSet1, values[0])) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_stop", retval); elapsed_us = PAPI_get_real_usec() - elapsed_us; elapsed_cyc = PAPI_get_real_cyc() - elapsed_cyc; if ((retval = PAPI_overflow(EventSet1, papi_event, 0, 0, NULL)) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_overflow", retval); remove_test_events(&EventSet1, mask1); if ((retval = PAPI_event_code_to_name(papi_event, event_name)) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_event_code_to_name", retval); if (!TESTS_QUIET) { printf("Thread 0x%x %s : \t%lld\n", (int) pthread_self(), event_name, (values[0])[0]); printf("Thread 0x%x PAPI_TOT_CYC: \t%lld\n", (int) pthread_self(), (values[0])[1]); printf("Thread 0x%x Real usec : \t%lld\n", (int) pthread_self(), elapsed_us); printf("Thread 0x%x Real cycles : \t%lld\n", (int) pthread_self(), elapsed_cyc); } free_test_space(values, num_tests); pthread_exit(NULL); return (NULL); }
/** * \brief Frees the memory used in the plan * \param [in] plan Points to the memory for free-ing. * \sa parseFFT2Plan * \sa makeFFT2Plan * \sa initFFT2Plan * \sa execFFT2Plan * \sa perfFFT2Plan */ void *killFFT2Plan(void *plan){ Plan *p; FFTdata *d; p = (Plan *)plan; assert(p); d = (FFTdata *)p->vptr; assert(d); pthread_rwlock_wrlock(&FFTW_Lock); if(DO_PERF){ #ifdef HAVE_PAPI TEST_PAPI(PAPI_stop(p->PAPI_EventSet, NULL), PAPI_OK, MyRank, 9999, PRINT_SOME); #endif //HAVE_PAPI } //DO_PERF if(d->in_original){ fftw_free(d->in_original); } if(d->out){ fftw_free(d->out); } if(d->mid){ fftw_free(d->mid); } if(d->forward){ fftw_destroy_plan(d->forward); } if(d->backward){ fftw_destroy_plan(d->backward); } pthread_rwlock_unlock(&FFTW_Lock); free(d); free(p); return (void *)NULL; } /* killFFT2Plan */
void event_stop(int *eventSet, int eventCodeSetSize, long long *PMC, int threadID) { int i, retval; retval = PAPI_stop( *eventSet, PMC ); if ( retval != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); }
void PAPI_HW_COUNTER_close(int tid){ int retval; #ifdef MEASURE_TIME #endif #ifdef MEASURE_HW_COUNTER retval = PAPI_stop( thr_vars[tid].EventSet, thr_vars[tid].values); if (retval != PAPI_OK) { papi_fail(__FILE__, __LINE__, "PAPI_stop()", retval); } retval = PAPI_cleanup_eventset( thr_vars[tid].EventSet ); if (retval != PAPI_OK) { papi_fail(__FILE__, __LINE__, "PAPI_cleanup_eventset()",retval); } retval = PAPI_destroy_eventset( &(thr_vars[tid].EventSet) ); if (retval != PAPI_OK) { papi_fail(__FILE__, __LINE__, "PAPI_destroy_eventset()",retval); } #endif #ifdef MEASURE_ENERGY retval = PAPI_stop( thr_vars[tid].EnergyEventSet, thr_vars[tid].energy_values); if (retval != PAPI_OK) { papi_fail(__FILE__, __LINE__, "PAPI_stop()", retval); } retval = PAPI_cleanup_eventset( thr_vars[tid].EnergyEventSet ); if (retval != PAPI_OK) { papi_fail(__FILE__, __LINE__, "PAPI_cleanup_eventset()",retval); } retval = PAPI_destroy_eventset( &(thr_vars[tid].EnergyEventSet) ); if (retval != PAPI_OK) { papi_fail(__FILE__, __LINE__, "PAPI_destroy_eventset()",retval); } #endif }
void compute() { #if PAPI int EventCode, retval; int EventSet = PAPI_NULL; long long PAPI_Counters[MAX_COUNTERS]; /* Initialize the library */ retval = PAPI_library_init(PAPI_VER_CURRENT); if (retval != PAPI_VER_CURRENT) { fprintf(stderr, "PAPI library init error!\n"); exit(1); } /* PAPI create event */ if (PAPI_create_eventset(&EventSet) != PAPI_OK) { fprintf(stderr, "create event set: %s", PAPI_strerror(retval)); } for (int i = 0; i < NUMCOUNTERS; i++) { if ( (retval = PAPI_add_named_event(EventSet, events[i])) != PAPI_OK) { fprintf(stderr, "add named event: %s", PAPI_strerror(retval)); } } retval = PAPI_start(EventSet); #endif float matice1[rozmer][rozmer]; float matice2[rozmer][rozmer]; float matice3[rozmer][rozmer]; //Main multiply code int j,k,m; for(j = 0; j < rozmer; j++) { for (k = 0; k < rozmer; k++) { float temp = 0; for (m = 0; m < rozmer; m++) { temp = temp + matice1[j][m] * matice2[m][k]; } matice3[j][k] = temp; } } #if PAPI retval = PAPI_stop(EventSet, PAPI_Counters); if (retval != PAPI_OK) exit(1); for (int j = 0; j < NUMCOUNTERS; j++) { printf("%20lld %s\n", PAPI_Counters[j], events[j]); // fprintf(stderr, "%lld\n ", PAPI_Counters[j]); } #endif }
void Thread( int t, int n ) { int retval, num_tests = 1; int EventSet1 = PAPI_NULL; int PAPI_event, mask1; int num_events1; long long **values; long long elapsed_us, elapsed_cyc; char event_name[PAPI_MAX_STR_LEN]; /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS, depending on the availability of the event on the platform */ EventSet1 = add_two_events( &num_events1, &PAPI_event, &mask1 ); retval = PAPI_event_code_to_name( PAPI_event, event_name ); if ( retval != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval ); values = allocate_test_space( num_tests, num_events1 ); retval = PAPI_start( EventSet1 ); if ( retval != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_start", retval ); elapsed_us = PAPI_get_real_usec( ); elapsed_cyc = PAPI_get_real_cyc( ); do_flops( n ); elapsed_us = PAPI_get_real_usec( ) - elapsed_us; elapsed_cyc = PAPI_get_real_cyc( ) - elapsed_cyc; retval = PAPI_stop( EventSet1, values[0] ); if ( retval != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); remove_test_events( &EventSet1, mask1 ); if ( !TESTS_QUIET ) { printf( "Thread %#x %-12s : \t%lld\n", t, event_name, values[0][1] ); printf( "Thread %#x PAPI_TOT_CYC : \t%lld\n", t, values[0][0] ); } free_test_space( values, num_tests ); if ( !TESTS_QUIET ) { printf( "Thread %#x Real usec : \t%lld\n", t, elapsed_us ); printf( "Thread %#x Real cycles : \t%lld\n", t, elapsed_cyc ); } PAPI_unregister_thread( ); }
long long papi_stop(){ if (papi_supported) { if ((papi_err = PAPI_stop(eventSet, &value)) != PAPI_OK) { return -1; } return value; } return -1; }
int main( int argc, char **argv ) { double c, a = 0.999, b = 1.001; int n = 1000; int EventSet = PAPI_NULL; int retval; int i, j = 0; long long g1[2]; tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */ if ( ( retval = PAPI_library_init( PAPI_VER_CURRENT ) ) != PAPI_VER_CURRENT ) test_fail( __FILE__, __LINE__, "PAPI_library_init", retval ); if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval ); if ( PAPI_query_event( PAPI_L2_TCM ) == PAPI_OK ) j++; if ( j == 1 && ( retval = PAPI_add_event( EventSet, PAPI_L2_TCM ) ) != PAPI_OK ) { if ( retval != PAPI_ECNFLCT ) test_fail( __FILE__, __LINE__, "PAPI_add_event", retval ); j--; /* The event was not added */ } i = j; if ( PAPI_query_event( PAPI_L2_DCM ) == PAPI_OK ) j++; if ( j == ( i + 1 ) && ( retval = PAPI_add_event( EventSet, PAPI_L2_DCM ) ) != PAPI_OK ) { if ( retval != PAPI_ECNFLCT ) test_fail( __FILE__, __LINE__, "PAPI_add_event", retval ); j--; /* The event was not added */ } if ( j ) { if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_start", retval ); for ( i = 0; i < n; i++ ) { c = a * b; } if (!TESTS_QUIET) fprintf(stdout,"c=%lf\n",c); if ( ( retval = PAPI_stop( EventSet, g1 ) ) != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_stop", retval ); } test_pass( __FILE__, NULL, 0 ); exit( 1 ); }
static int check_event( int event_code, char *name ) { int retval; char errstring[PAPI_MAX_STR_LEN]; long long values; int EventSet = PAPI_NULL; /* Is there an issue with older machines? */ /* Disable for now, add back once we can reproduce */ // if ( PENTIUM4 ) { // if ( strcmp( name, "REPLAY_EVENT:BR_MSP" ) == 0 ) { // return 1; // } // } retval = PAPI_create_eventset( &EventSet ); if ( retval != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval ); retval = PAPI_add_event( EventSet, event_code ); if ( retval != PAPI_OK ) { printf( "Error adding %s\n", name ); return 0; } else { // printf( "Added %s successfully ", name ); } retval = PAPI_start( EventSet ); if ( retval != PAPI_OK ) { PAPI_perror( retval, errstring, PAPI_MAX_STR_LEN ); fprintf( stdout, "Error starting %s : %s\n", name, errstring ); } else { retval = PAPI_stop( EventSet, &values ); if ( retval != PAPI_OK ) { PAPI_perror( retval, errstring, PAPI_MAX_STR_LEN ); fprintf( stdout, "Error stopping %s: %s\n", name, errstring ); return 0; } else { printf( "Added and Stopped %s successfully.\n", name ); } } retval=PAPI_cleanup_eventset( EventSet ); if (retval != PAPI_OK ) { test_warn( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval); } retval=PAPI_destroy_eventset( &EventSet ); if (retval != PAPI_OK ) { test_warn( __FILE__, __LINE__, "PAPI_destroy_eventset", retval); } return ( 1 ); }
void stop_papi() { if (papi_supported) { if ((papi_err = PAPI_stop(eventSet, values)) != PAPI_OK) { fprintf(stderr, "Could not get values: %s\n", PAPI_strerror(papi_err)); } int i; for (i = 0; i < en; ++i) { printf("%s: %lld\n", event_names[i], values[i]); } } }
void * my_thread( void *v ) { long num = ( long ) v; int n; int EventSet = PAPI_NULL; long long value; int retval = PAPI_register_thread( ); if ( retval != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_register_thread", retval ); pthread_setspecific( key, v ); count[num] = 0; iter[num] = 0; last[num] = start; if ( PAPI_create_eventset( &EventSet ) != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_create_eventset failed", 1 ); if ( PAPI_add_event( EventSet, EVENT ) != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_add_event failed", 1 ); if ( PAPI_overflow( EventSet, EVENT, threshold, 0, my_handler ) != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_overflow failed", 1 ); if ( PAPI_start( EventSet ) != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_start failed", 1 ); printf( "launched timer in thread %ld\n", num ); for ( n = 1; n <= program_time; n++ ) { do_cycles( num, 1 ); print_rate( num ); } PAPI_stop( EventSet, &value ); retval = PAPI_overflow( EventSet, EVENT, 0, 0, my_handler); if ( retval != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_overflow failed to reset the overflow handler", retval ); if ( PAPI_remove_event( EventSet, EVENT ) != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_remove_event", 1 ); if ( PAPI_destroy_eventset( &EventSet ) != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", 1 ); if ( PAPI_unregister_thread( ) != PAPI_OK != retval ) test_fail( __FILE__, __LINE__, "PAPI_unregister_thread", 1 ); return ( NULL ); }
void Thread( int n ){ int retval, num_tests = 1; int EventSet1 = PAPI_NULL; int PAPI_event, mask1; int num_events1; long long **values; long long elapsed_us, elapsed_cyc, L1_DCM; char event_name[PAPI_MAX_STR_LEN]; printf( "Thread %#x started\n", omp_get_thread_num( ) ); num_events1 = 2; EventSet1 = add_two_events( &num_events1, &PAPI_event, &mask1 ); retval = PAPI_event_code_to_name( PAPI_event, event_name ); if ( retval != PAPI_OK ) test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval ); values = allocate_test_space( num_tests, num_events1 ); elapsed_us = PAPI_get_real_usec( ); elapsed_cyc = PAPI_get_real_cyc( ); retval = PAPI_start( EventSet1 ); do_flops( n ); retval = PAPI_stop( EventSet1, values[0] ); elapsed_us = PAPI_get_real_usec( ) - elapsed_us; elapsed_cyc = PAPI_get_real_cyc( ) - elapsed_cyc; remove_test_events( &EventSet1, mask1 ); if ( !TESTS_QUIET ) { printf( "Thread %#x %-12s : \t%lld\n", omp_get_thread_num( ), event_name, values[0][1] ); printf( "Thread %#x PAPI_TOT_CYC: \t%lld\n", omp_get_thread_num( ), values[0][0] ); printf( "Thread %#x Real usec : \t%lld\n", omp_get_thread_num( ), elapsed_us ); printf( "Thread %#x Real cycles : \t%lld\n", omp_get_thread_num( ), elapsed_cyc ); } free_test_space( values, num_tests ); PAPI_unregister_thread( ); printf( "Thread %#x finished\n", omp_get_thread_num( ) ); }
void compute(int *sequence) { #if PAPI int EventCode, retval; int EventSet = PAPI_NULL; long long PAPI_Counters[MAX_COUNTERS]; /* Initialize the library */ retval = PAPI_library_init(PAPI_VER_CURRENT); if (retval != PAPI_VER_CURRENT) { fprintf(stderr, "PAPI library init error!\n"); exit(1); } /* PAPI create event */ if (PAPI_create_eventset(&EventSet) != PAPI_OK) { fprintf(stderr, "create event set: %s", PAPI_strerror(retval)); } int i; for (i = 0; i < NUMCOUNTERS; i++) { if ( (retval = PAPI_add_named_event(EventSet, events[i])) != PAPI_OK) { fprintf(stderr, "add named event: %s", PAPI_strerror(retval)); } } retval = PAPI_start(EventSet); #endif float matice1[SEQUENCE_CNT]; float matice2[SEQUENCE_CNT]; int j, idx; for(j = 0; j < SEQUENCE_CNT; j++) { idx = sequence[j]; matice2[idx] = 13 % (idx + 1); matice1[idx] = matice2[idx] * 231; // printf("%d\t", idx); } //printf("\n"); #if PAPI retval = PAPI_stop(EventSet, PAPI_Counters); if (retval != PAPI_OK) exit(1); int k; for (k = 0; k < NUMCOUNTERS; k++) { printf("%20lld %s\n", PAPI_Counters[k], events[k]); // fprintf(stderr, "%lld\n ", PAPI_Counters[k]); } #endif }
void test_papi_destroy(struct test_statistics_t *test_stat) { int retval; if ((retval = PAPI_stop(test_stat->event_set, test_stat->counters)) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_stop", retval); if ((retval = PAPI_cleanup_eventset(test_stat->event_set)) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_destroy_eventset", retval); if ((retval = PAPI_destroy_eventset(&(test_stat->event_set))) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_destroy_eventset", retval); }
void end_record_cache_access(RRecord & rr) { int retVal; retVal = PAPI_stop(g_event_set, endRecords); assert(retVal == PAPI_OK); retVal = PAPI_cleanup_eventset(g_event_set); assert(retVal == PAPI_OK); retVal = PAPI_destroy_eventset(&g_event_set); assert(retVal == PAPI_OK); PAPI_shutdown(); rr.put("L1-cache-misss", endRecords[0] - startRecords[0]); rr.put("L1-cache-access", endRecords[1] - startRecords[1]); }
void ipm_hpm_stop() { #ifndef HPM_DISABLED int i,rv; #ifdef HPM_PAPI char errstring[PAPI_MAX_STR_LEN]; char event_name[PAPI_MAX_STR_LEN]; long long int papi_hpm[MAXSIZE_HPMCOUNTERS]; #endif if(task.flags & IPM_HPM_CANCELED) { return; } if(task.hpm_eventset < 0) { return; } #ifdef HPM_PAPI #ifdef CPU_PPC450D /* then we are on a bluegene P*/ if (node_rank != 0 ) return; #endif rv = PAPI_stop(papi_eventset[0], papi_hpm); if(rv != PAPI_OK) { PAPI_perror(rv, errstring, PAPI_MAX_STR_LEN); printf("IPM: %d papi_error hpm_stop %d %s\n", task.mpi_rank, rv, errstring); } #endif #ifdef HPM_PMAPI pm_stop_mythread(); #endif /* TAG_EXIT: exit from global is different than exit from non global */ if(task.flags & IPM_HPM_ACTIVE) { if(task.region_current > 0) { printf("IPM: %d exit from region=%d > 0 \n", task.mpi_rank, task.region_current); } } return; #endif }
static void papiEnd() { int rv; /* get the values */ if ((rv = PAPI_stop(papiEventSet, papiResults)) != PAPI_OK) handle_error(rv); /* Remove all events in the eventset */ if ((rv = PAPI_cleanup_eventset(papiEventSet)) != PAPI_OK) handle_error(rv); /* Free all memory and data structures, EventSet must be empty. */ if ((rv = PAPI_destroy_eventset(&papiEventSet)) != PAPI_OK) handle_error(rv); }
long_long stop_PAPI(int ind) { long_long values[1]; if (PAPI_stop(oscrData_timerPAPIEventSet[ind], values) != PAPI_OK) OSCR_error("PAPI stop init error!\n", -1); if (PAPI_cleanup_eventset(&oscrData_timerPAPIEventSet[ind]) != PAPI_OK) OSCR_error("PAPI cleanning Eventset error!\n", -1); if (PAPI_destroy_eventset(&oscrData_timerPAPIEventSet[ind]) != PAPI_OK) OSCR_error("PAPI destroying Eventset error!\n", -1); return (values[0]); }