Пример #1
0
void papi_init(int eventNumber){
	if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT) {
		fprintf(stderr, "PAPI is unsupported.\n");
		papi_supported = false;
	}

	if (PAPI_num_counters() < 5) {
		fprintf(stderr, "PAPI is unsupported.\n");
		papi_supported = false;
	}

	if ((papi_err = PAPI_create_eventset(&eventSet)) != PAPI_OK) {
		fprintf(stderr, "Could not create event set: %s\n", PAPI_strerror(papi_err));
	}

    /* force program to run on a single CPU */
    cpu_set_t my_set;        /* Define your cpu_set bit mask. */
    CPU_ZERO(&my_set);       /* Initialize it all to 0, i.e. no CPUs selected. */
	CPU_SET(0, &my_set);
	if (sched_setaffinity(0, sizeof(cpu_set_t), &my_set) != 0) {
		perror("sched_setaffinity error");
	}

	if ((papi_err = PAPI_add_event(eventSet, events[eventNumber])) != PAPI_OK ) {
		fprintf(stderr, "Could not add event: %s\n", PAPI_strerror(papi_err));
	}
}
void start_papi() {
    values = calloc(en, sizeof(long long));

    if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT) {
        fprintf(stderr, "PAPI is unsupported.\n");
        papi_supported = 0;
    }

    if (PAPI_num_counters() < en) {
        fprintf(stderr, "PAPI is unsupported.\n");
        papi_supported = 0;
    }
    
    if ((papi_err = PAPI_create_eventset(&eventSet)) != PAPI_OK) {
        fprintf(stderr, "Could not create event set: %s\n", PAPI_strerror(papi_err));
    }

    for (int i=0; i<en; ++i) {
        if ((papi_err = PAPI_add_event(eventSet, events[i])) != PAPI_OK ) {
            fprintf(stderr, "Could not add event: %s %s\n", event_names[i], PAPI_strerror(papi_err));
        }
    }

    /* start counters */

    if (papi_supported) {
        if ((papi_err = PAPI_start(eventSet)) != PAPI_OK) {
            fprintf(stderr, "Could not start counters: %s\n", PAPI_strerror(papi_err));
        }
    }
}
Пример #3
0
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
}
Пример #4
0
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
}
Пример #5
0
void papi_init_eventset(pid_t pid, int *EventSet) {

  int retval;
  if ( (retval = PAPI_create_eventset(EventSet) ) != PAPI_OK) {    
    fprintf(stderr, "PAPI EventSet init error!\n%s\n", PAPI_strerror(retval));
  }

  if ( (retval = PAPI_add_events(*EventSet, global_config.native_events, global_config.nb_papi_events) ) != PAPI_OK) {
    fprintf(stderr, "PAPI add events error!\n%s\n", PAPI_strerror(retval));
  }

  if ( (retval = PAPI_attach(*EventSet, pid) ) != PAPI_OK) {
    fprintf(stderr, "PAPI attach error!\n%s\n", PAPI_strerror(retval));
  }
}
Пример #6
0
void HWCBE_PAPI_Initialize (int TRCOptions)
{
	UNREFERENCED_PARAMETER(TRCOptions);

	int rc;
	void *thread_identifier_function;

	/* PAPI initialization */
	rc = PAPI_library_init (PAPI_VER_CURRENT);
	if (rc != PAPI_VER_CURRENT)
	{
		if (rc > 0)
		{
			fprintf (stderr,
				PACKAGE_NAME": PAPI library version mismatch!\n"
				"          "PACKAGE_NAME" is compiled against PAPI v%d.%d , and \n"
				"          PAPI_library_init reported v%d.%d ,\n"
				"          Check that LD_LIBRARY_PATH points to the correct PAPI library.\n",
				PAPI_VERSION_MAJOR(PAPI_VER_CURRENT),
				PAPI_VERSION_MINOR(PAPI_VER_CURRENT),
				PAPI_VERSION_MAJOR(rc),
				PAPI_VERSION_MINOR(rc));
		}
		fprintf (stderr, PACKAGE_NAME": Can't use hardware counters!\n");
		fprintf (stderr, PACKAGE_NAME": PAPI library error: %s\n", PAPI_strerror (rc));

		if (rc == PAPI_ESYS)
			perror (PACKAGE_NAME": PAPI system error is ");

		return;
	}

#if defined(PAPI_SAMPLING_SUPPORT)
	/* Use any kind of sampling -- software or hardware */
	SamplingSupport = TRUE;
#endif

	thread_identifier_function = Extrae_get_thread_number_function();

	if (thread_identifier_function != NULL)
	{
		if ((rc = PAPI_thread_init ((unsigned long (*)(void)) thread_identifier_function)) != PAPI_OK)
		{
			fprintf (stderr, PACKAGE_NAME": PAPI_thread_init failed! Reason: %s\n", PAPI_strerror(rc));
			return;
		}
	}
}
Пример #7
0
/* Use a positive value of retval to simply print an error message */
void
test_warn( char *file, int line, char *call, int retval )
{

  int line_pad;

  line_pad=(int)(50-strlen(file));
  if (line_pad<0) line_pad=0;

	char buf[128];
	memset( buf, '\0', sizeof ( buf ) );

	if (TESTS_COLOR) {
	  fprintf( stdout, "%-*s %sWARNING%s\nLine # %d\n", line_pad, file, 
		   YELLOW, NORMAL, line );
	}
	else {
	  fprintf( stdout, "%-*s WARNING\nLine # %d\n", line_pad, file, line );
	}

	if ( retval == PAPI_ESYS ) {
		sprintf( buf, "System warning in %s", call );
		perror( buf );
	} else if ( retval > 0 ) {
		fprintf( stdout, "Warning: %s\n", call );
	} else if ( retval == 0 ) {
		fprintf( stdout, "Warning: %s\n", call );
	} else {
		fprintf( stdout, "Warning in %s: %s\n", call, PAPI_strerror( retval ));
	}

	fprintf( stdout, "\n" );
	TEST_WARN++;

}
Пример #8
0
int
main( int argc, char **argv )
{
	int i;

	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 );


	printf( "\n----------------------------------\n" );
	printf( "For PAPI Version: %d.%d.%d.%d\n", 
			PAPI_VERSION_MAJOR( PAPI_VERSION ),
			PAPI_VERSION_MINOR( PAPI_VERSION ),
			PAPI_VERSION_REVISION( PAPI_VERSION ),
			PAPI_VERSION_INCREMENT( PAPI_VERSION ) );
	printf( "There are %d error codes defined\n", PAPI_NUM_ERRORS );
	printf( "----------------------------------\n" );
	for (i = 0; i < PAPI_NUM_ERRORS; i++) {
		char *errstr, *errdescr;
		errstr = PAPI_strerror( -i );
		errdescr = PAPI_descr_error( -i );
		printf( "Error code %4d: %-15s | %s\n", -i, errstr, errdescr );
	}
	printf( "----------------------------------\n\n" );
	exit( 1 );
}
Пример #9
0
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;
}
Пример #10
0
void
test_skip( char *file, int line, char *call, int retval )
{
	char buf[128];

	memset( buf, '\0', sizeof ( buf ) );
	fprintf( stdout, "%-40s SKIPPED\n", file );
	if ( !TESTS_QUIET ) {
		if ( retval == PAPI_ESYS ) {
			fprintf( stdout, "Line # %d\n", line );
			sprintf( buf, "System error in %s:", call );
			perror( buf );
		} else if ( retval == PAPI_EPERM ) {
			fprintf( stdout, "Line # %d\n", line );
			fprintf( stdout, "Invalid permissions for %s.", call );
		} else if ( retval == PAPI_ECMP ) {
			fprintf( stdout, "Line # %d\n", line );
			fprintf( stdout, "%s.", call );
		} else if ( retval >= 0 ) {
			fprintf( stdout, "Line # %d\n", line );
			fprintf( stdout, "Error calculating: %s\n", call );
		} else if ( retval < 0 ) {
			fprintf( stdout, "Line # %d\n", line );
			fprintf( stdout, "Error in %s: %s\n", call, PAPI_strerror(retval) );
		}
		fprintf( stdout, "\n" );
	}
	exit( 0 );
}
Пример #11
0
JNIEXPORT jint JNICALL Java_papi_Wrapper_eventSetAddEvents
		(JNIEnv *env, jclass UNUSED_ARG(self), jlong eventsetid, jintArray eventsarr) {
	DEBUG_PRINT("enter");
	if (eventsarr == NULL) {
		DEBUG_PRINT("events array is NULL!");
		return PAPI_EINVAL;
	}

	int events_count = (*env)->GetArrayLength(env, eventsarr);
	if (events_count == 0) {
		return PAPI_OK;
	}

	int eventset = (int) eventsetid;
	DEBUG_PRINT("eventset is %d", eventset);

	jint *eventsj = (*env)->GetIntArrayElements(env, eventsarr, NULL);
	int *events = (int *) eventsj;
	int rc = PAPI_add_events(eventset, events, events_count);
	(*env)->ReleaseIntArrayElements(env, eventsarr, eventsj, JNI_ABORT);

	DEBUG_PRINT("returning %d (%s)", rc, PAPI_strerror(rc));

	return rc;
}
Пример #12
0
void papi_global_init() {
  int retval;
  if ( (retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) {
    fprintf(stderr, "PAPI library init error!\n%s\n", PAPI_strerror(retval));
  }
  //papi_init_counters_name_non_thread_safe();
}
Пример #13
0
int GPTL_PAPIstop (const int t,         /* thread number */
		   Papistats *aux)      /* struct containing PAPI stats */
{
  int ret;          /* return code from PAPI lib calls */
  int n;            /* loop index */
  long_long delta;  /* change in counters from previous read */

  /* If no events are to be counted just return */

  if (npapievents == 0)
    return 0;

  /* Read the counters */

  if ((ret = PAPI_read (EventSet[t], papicounters[t])) != PAPI_OK)
    return GPTLerror ("GPTL_PAPIstop: %s\n", PAPI_strerror (ret));
  
  /* 
  ** Accumulate the difference since timer start in aux.
  ** Negative accumulation can happen when multiplexing is enabled, so don't
  ** set count to BADCOUNT in that case.
  */

  for (n = 0; n < npapievents; n++) {
#ifdef DEBUG
    printf ("GPTL_PAPIstop: event %d counter value is %ld\n", n, (long) papicounters[t][n]);
#endif
    delta = papicounters[t][n] - aux->last[n];
    if ( ! is_multiplexed && delta < 0)
      aux->accum[n] = BADCOUNT;
    else
      aux->accum[n] += delta;
  }
  return 0;
}
Пример #14
0
int GPTL_PAPIstart (const int t,          /* thread number */
		    Papistats *aux)       /* struct containing PAPI stats */
{
  int ret;  /* return code from PAPI lib calls */
  int n;    /* loop index */
  
  /* If no events are to be counted just return */

  if (npapievents == 0)
    return 0;

  /* Read the counters */

  if ((ret = PAPI_read (EventSet[t], papicounters[t])) != PAPI_OK)
    return GPTLerror ("GPTL_PAPIstart: %s\n", PAPI_strerror (ret));

  /* 
  ** Store the counter values.  When GPTL_PAPIstop is called, the counters
  ** will again be read, and differenced with the values saved here.
  */

  for (n = 0; n < npapievents; n++)
    aux->last[n] = papicounters[t][n];
  
  return 0;
}
Пример #15
0
void timer_handler(int signo, siginfo_t *info, void *context){
	int i, ret;
	//Read the values with PAPI
	if(signo == SIGRTMIN){
        scheduler_value = 0;

        if((ret = PAPI_accum(scheduler_eventset, &scheduler_value)) != PAPI_OK){
    		fprintf(stderr, "PAPI error: Couldn't read the values %s\n", PAPI_strerror(ret));
    		exit(20);
    	}
    	//Test the quota and send the sigstop
        //fprintf(stderr, "%lld\n", scheduler_value);
    	rt_quota_l3 -= scheduler_value;

    	if((rt_quota_l3 <= 0) && (send == 0)){
            fprintf(stderr, "Scheduler (%d) > Quota exceeded will stop attackers\n", getpid());
    		for(i=0; i<nb_attackers; i++)
    			kill(pid_attacker[i],SIGSTOP);
            send = 1;
    	}

    	new_window --;

    	//If new window send SIGCONT to attackers
        if(!new_window){
            fprintf(stderr, "Scheduler (%d) > New window\n", getpid());
            for(i=0; i<nb_attackers; i++)
        	   kill(pid_attacker[i], SIGCONT);
            new_window = 200;
            rt_quota_l3 = MEMORY_QUOTA;
            send = 0;
        }
    }
}
Пример #16
0
/// Output user error message, PAPI error message and exit
static void papi_fail(int rc, const char *msg)
{
    const char *papi_err = PAPI_strerror(rc);
    std::cerr << "Error: " << msg << '\n'
              << papi_err << " (" << rc << ")\n";
    exit(EXIT_FAILURE);
}
Пример #17
0
int main(int argc, char *argv[]) {
  
    #ifdef SCOREP
    SCOREP_USER_REGION_DEFINE(handle_initialization);
    SCOREP_USER_REGION_DEFINE(handle_computation);
    SCOREP_USER_REGION_DEFINE(handle_finalization);
    #endif
  
    #ifdef SCOREP
    SCOREP_USER_REGION_BEGIN( handle_initialization, "INITIALIZATION",SCOREP_USER_REGION_TYPE_COMMON );
    #endif
    
    int my_rank, num_procs, i;

    const int max_iters = 10000;    /// maximum number of iteration to perform

    /** Simulation parameters parsed from the input datasets */
    int nintci, nintcf;    /// internal cells start and end index
    /// external cells start and end index. The external cells are only ghost cells.
    /// They are accessed only through internal cells
    int nextci, nextcf;
    int **lcc;    /// link cell-to-cell array - stores neighboring information
    /// Boundary coefficients for each volume cell (South, East, North, West, High, Low)
    double *bs, *be, *bn, *bw, *bh, *bl;
    double *bp;    /// Pole coefficient
    double *su;    /// Source values

    double residual_ratio;    /// the ratio between the reference and the current residual
    double *var;    /// the variation vector -> keeps the result in the end

    /** Additional vectors required for the computation */
    double *cgup, *oc, *cnorm;

    /** Geometry data */
    int points_count;    /// total number of points that define the geometry
    int** points;    /// coordinates of the points that define the cells - size [points_cnt][3]
    int* elems;    /// definition of the cells using their nodes (points) - each cell has 8 points

    /** Mapping between local and remote cell indices */
    int* local_global_index;    /// local to global index mapping
    int* global_local_index;    /// global to local index mapping
  

    /** Lists for neighbouring information */
    int nghb_cnt = 0;    /// total number of neighbors of the current process
    int *nghb_to_rank;  /// mapping of the neighbour index to the corresponding process rank
    int *send_cnt;    /// number of cells to be sent to each neighbour (size: nghb_cnt)
    int **send_lst;    /// lists of cells to be sent to each neighbour (size: nghb_cnt x send_cnt[*])
    int *recv_cnt;    /// number of cells to be received from each neighbour (size: nghb_cnt)
    int **recv_lst;    /// lists of cells to be received from each neighbour (size: nghb_cnt x recv_cnt[*])

    /* PAPI Parameters*/
    float rtime, ptime, mflops;
    long long flpops;

    void handle_error (int retval)
        {
             printf("PAPI error %d: %s\n", retval, PAPI_strerror(retval));
          exit(1);
        }
Пример #18
0
/* Helper function to test PAPI return codes */
inline void TEST_PAPI(int res, int test, int rank, int tnum, int debug){
    char message[512];

    if(res != test){
        snprintf(message, 512, "PAPI error %d: %s\n", res, PAPI_strerror(res));
        EmitLog(rank, tnum, message, -1, debug);
    }
}
Пример #19
0
void papi_start(){
	if (papi_supported) {
		if ((papi_err = PAPI_start(eventSet)) != PAPI_OK) {
			fprintf(stderr, "Could not start counters: %s\n", PAPI_strerror(papi_err));
		}
	}

}
Пример #20
0
void 
monitor_init_thread_support(void)
{
  int rval;
  if ((rval = PAPI_thread_init(pthread_self)) != PAPI_OK) {
    DIEx("error: PAPI error (%d): %s.", rval, PAPI_strerror(rval));
  }
}
int main () 
{
    float t0, t1;
    int iter, i, j;
    int events[2] = {PAPI_L1_DCM, PAPI_FP_OPS }, ret;
    long_long values[2];

    if (PAPI_num_counters() < 2) {
        fprintf(stderr, "No hardware counters here, or PAPI not supported.\n");
        exit(1);
    }
    for (i = 0; i < MX; i++) {
        if ((ad[i] = malloc(sizeof(double)*MX)) == NULL) {
            fprintf(stderr,"malloc failed\n");
            exit(1);
        }
    }
    for (j = 0; j < MX; j++) { 
        for (i = 0; i < MX; i++) {
            ad[i][j] = 1.0/3.0; /* Initialize the data */
        }
    }
    t0 = gettime();
    if ((ret = PAPI_start_counters(events, 2)) != PAPI_OK) {
        fprintf(stderr, "PAPI failed to start counters: %s\n", PAPI_strerror(ret));
        exit(1);
    }
    for (iter = 0; iter < NITER; iter++) {
        for (j = 0; j < MX; j++) {
            for (i = 0; i < MX; i++) {
                ad[i][j] += ad[i][j] * 3.0;
            }
        }
    }
    if ((ret = PAPI_read_counters(values, 2)) != PAPI_OK) {
        fprintf(stderr, "PAPI failed to read counters: %s\n", PAPI_strerror(ret));
        exit(1);
    }
    t1 = gettime();

    printf("Total software flops = %f\n",(float)TOT_FLOPS);
    printf("Total hardware flops = %lld\n",(float)values[1]);
    printf("MFlop/s = %f\n", (float)(TOT_FLOPS/MEGA)/(t1-t0));
    printf("L1 data cache misses is %lld\n", values[0]);
}
Пример #22
0
void flops_init()
{
    #ifdef HAVE_PAPI
    int err = PAPI_library_init( PAPI_VER_CURRENT );
    if ( err != PAPI_VER_CURRENT ) {
        fprintf( stderr, "Error: PAPI couldn't initialize: %s (%d)\n",
                 PAPI_strerror(err), err );
    }
    
    // read flops
    err = PAPI_create_eventset( &gPAPI_flops_set );
    if ( err != PAPI_OK ) {
        fprintf( stderr, "Error: PAPI_create_eventset failed\n" );
    }
    
    err = PAPI_assign_eventset_component( gPAPI_flops_set, 0 );
    if ( err != PAPI_OK ) {
        fprintf( stderr, "Error: PAPI_assign_eventset_component failed: %s (%d)\n",
                 PAPI_strerror(err), err );
    }
    
    PAPI_option_t opt;
    memset( &opt, 0, sizeof(PAPI_option_t) );
    opt.inherit.inherit  = PAPI_INHERIT_ALL;
    opt.inherit.eventset = gPAPI_flops_set;
    err = PAPI_set_opt( PAPI_INHERIT, &opt );
    if ( err != PAPI_OK ) {
        fprintf( stderr, "Error: PAPI_set_opt failed: %s (%d)\n",
                 PAPI_strerror(err), err );
    }
    
    err = PAPI_add_event( gPAPI_flops_set, PAPI_FP_OPS );
    if ( err != PAPI_OK ) {
        fprintf( stderr, "Error: PAPI_add_event failed: %s (%d)\n",
                 PAPI_strerror(err), err );
    }
    
    err = PAPI_start( gPAPI_flops_set );
    if ( err != PAPI_OK ) {
        fprintf( stderr, "Error: PAPI_start failed: %s (%d)\n",
                 PAPI_strerror(err), err );
    }
    #endif  // HAVE_PAPI
}
Пример #23
0
void esd_metric_warning(int errcode, char *note)
{
  char *errstring;

  errstring = PAPI_strerror(errcode);
  if (errcode == PAPI_ESYS) {
      errstring = strcat(errstring,": ");
      errstring = strcat(errstring,strerror(errno));
  }
  elg_warning("%s: %s (ignored)", note?note:"PAPI", errstring);
}
Пример #24
0
void papi_base::start( ) {
	
	std::vector<int> eventsMutable( counters_.data(), counters_.data() + counters_.size() );
	int retval = PAPI_start_counters( &eventsMutable[ 0 ], counters_.size() );
	if (retval == PAPI_OK) {
		papi_started_ = true;
	} else {
		std::cerr << "PAPI error " << retval << ": " << PAPI_strerror( retval ) << std::endl;
		papi_started_ = false;
	}
}
Пример #25
0
void esd_metric_error(int errcode, char *note)
{
  char *errstring;

  errstring = PAPI_strerror(errcode);
  if (errcode == PAPI_ESYS) {
      errstring = strcat(errstring,": ");
      errstring = strcat(errstring,strerror(errno));
  }
  elg_error_msg("%s: %s (fatal)", note?note:"PAPI", errstring);
}
Пример #26
0
void my_papi_start(int *events, int NUM_EVENTS)
{
	values = (long long *)malloc(sizeof(long long)*NUM_EVENTS);
	int ret;
	
	/* Start counting events */
	if ((ret = PAPI_start_counters(events, NUM_EVENTS)) != PAPI_OK) {
		 fprintf(stderr, "PAPI failed to start counters: %s\n", PAPI_strerror(ret));
		 // fprintf(stderr, "PAPI_start_counters - FAILED\n");
			exit(1);
	}
}
Пример #27
0
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]);
        }
    }
}
Пример #28
0
/*
** GPTL_PAPIlibraryinit: Call PAPI_library_init if necessary
**
** Return value: 0 (success) or GPTLerror (failure)
*/
int GPTL_PAPIlibraryinit ()
{
  int ret;
  static const char *thisfunc = "GPTL_PAPIlibraryinit";

  if ((ret = PAPI_is_initialized ()) == PAPI_NOT_INITED) {
    if ((ret = PAPI_library_init (PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) {
      fprintf (stderr, "%s: ret=%d PAPI_VER_CURRENT=%d\n", thisfunc, ret, (int) PAPI_VER_CURRENT);
      return GPTLerror ("%s: PAPI_library_init failure:%s\n", thisfunc, PAPI_strerror (ret));
    }
  }
  return 0;
}
Пример #29
0
int GPTL_PAPIlibraryinit ()
{
  int ret;

  if ((ret = PAPI_is_initialized ()) == PAPI_NOT_INITED) {
    if ((ret = PAPI_library_init (PAPI_VER_CURRENT)) != PAPI_VER_CURRENT) {
      fprintf (stderr, "GPTL_PAPIlibraryinit: ret=%d PAPI_VER_CURRENT=%d\n", 
	       ret, (int) PAPI_VER_CURRENT);
      return GPTLerror ("GPTL_PAPIlibraryinit: PAPI_library_init failure:%s\n",
			PAPI_strerror (ret));
    }
  }
  return 0;
}
Пример #30
0
/* Use a positive value of retval to simply print an error message */
void
test_fail( char *file, int line, char *call, int retval )
{

  int line_pad;
  char buf[128];

  line_pad=(int)(50-strlen(file));
  if (line_pad<0) line_pad=0;

  memset( buf, '\0', sizeof ( buf ) );

  if (TESTS_COLOR) {
     fprintf( stdout, "%-*s %sFAILED%s\nLine # %d\n", line_pad, file, 
		    RED,NORMAL,line );
  }
  else {
     fprintf( stdout, "%-*s FAILED\nLine # %d\n", line_pad, file, line );
  }

  if ( retval == PAPI_ESYS ) {
     sprintf( buf, "System error in %s", call );
     perror( buf );
  } else if ( retval > 0 ) {
     fprintf( stdout, "Error: %s\n", call );
  } else if ( retval == 0 ) {
#if defined(sgi)
		fprintf( stdout, "SGI requires root permissions for this test\n" );
#else
		fprintf( stdout, "Error: %s\n", call );
#endif
  } else {
     fprintf( stdout, "Error in %s: %s\n", call, PAPI_strerror( retval ) );
  }

  fprintf( stdout, "\n" );

	/* NOTE: Because test_fail is called from thread functions, 
	   calling PAPI_shutdown here could prevent some threads
	   from being able to free memory they have allocated.
	 */

	/* This is stupid.  Threads are the rare case */
	/* and in any case an exit() should clear everything out */
	/* adding back the exit() call */

	exit(1);
}