本文整理汇总了C++中PAPI_create_eventset函数的典型用法代码示例。如果您正苦于以下问题:C++ PAPI_create_eventset函数的具体用法?C++ PAPI_create_eventset怎么用?C++ PAPI_create_eventset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PAPI_create_eventset函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: vt_metric_create
struct vt_metv* vt_metric_create()
{
struct vt_metv* metv;
int retval, i;
if ( nmetrics == 0 )
return NULL;
metv = (struct vt_metv*)malloc(sizeof(struct vt_metv));
if ( metv == NULL )
vt_error();
/* create event set */
metv->EventSet = PAPI_NULL;
retval = PAPI_create_eventset(&metv->EventSet);
if ( retval != PAPI_OK)
vt_metric_error(retval, "PAPI_create_eventset");
for ( i = 0; i < nmetrics; i++ )
{
/* add event to event set */
retval = PAPI_add_event(metv->EventSet, metricv[i]->papi_code);
if ( retval != PAPI_OK )
vt_metric_error(retval, "PAPI_add_event");
}
retval = PAPI_start(metv->EventSet);
if ( retval != PAPI_OK )
vt_metric_error(retval, "PAPI_start");
/*vt_cntl_msg("Counters started");*/
return metv;
}
开发者ID:rjrpaz,项目名称:MyOpenMPI,代码行数:33,代码来源:vt_metric_papi.c
示例2: initialize_papi
void initialize_papi (int eventCode) {
/* Initialize the PAPI library */
retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT) {
fprintf(stderr, "PAPI library init error! %d\n",PAPI_EINVAL);
handle_error(1);
}
if (EventSet==PAPI_NULL) {
if (PAPI_create_eventset(&EventSet) != PAPI_OK) {
printf("PAPI create eventset error\n");
handle_error(1);
}
} else {
if (PAPI_cleanup_eventset(EventSet) != PAPI_OK) {
printf("PAPI cleanup error\n");
handle_error(1);
}
}
if (PAPI_add_event(EventSet, eventCode) != PAPI_OK) {
printf("PAPI add event error: %x\n", eventCode);
handle_error(1);
}
}
开发者ID:Ruekov,项目名称:hwquery,代码行数:25,代码来源:papif.c
示例3: check_papi_counter
int
check_papi_counter(char * counter_name)
{
PAPI_event_info_t * info;
int EventSet = PAPI_NULL;
unsigned int event_code = 0x0;
int err;
if ((err=PAPI_create_eventset (&EventSet)) != PAPI_OK){
fprintf(stderr,"Failed to create a PAPI eventset\n");
exit(1);
}
if((err = PAPI_event_name_to_code(counter_name,&event_code)) != PAPI_OK){
return err;
}
if((err = PAPI_add_event (EventSet, event_code)) != PAPI_OK) {
return err;
}
PAPI_remove_named_event (EventSet, counter_name);
if ( PAPI_destroy_eventset( &EventSet ) != PAPI_OK ){
printf("********** Call to destroy eventset failed when trying to validate event '%s' **********\n", counter_name);
}
return err;
}
开发者ID:NicolasDenoyelle,项目名称:dynamic_lstopo,代码行数:25,代码来源:list_avail.c
示例4: UNUSED_ARG
JNIEXPORT jint JNICALL Java_papi_Wrapper_eventSetCreate
(JNIEnv *env, jclass UNUSED_ARG(self), jlongArray eventsetidoutarr) {
if (eventsetidoutarr == NULL) {
return PAPI_EINVAL;
}
if ((*env)->GetArrayLength(env, eventsetidoutarr) != 1) {
return PAPI_EINVAL;
}
int eventset = PAPI_NULL;
int rc = PAPI_create_eventset(&eventset);
if (rc != PAPI_OK) {
return rc;
}
jlong *eventsetidoutj = (*env)->GetLongArrayElements(env, eventsetidoutarr, NULL);
long long *eventsetidout = (long long *) eventsetidoutj;
eventsetidout[0] = eventset;
(*env)->ReleaseLongArrayElements(env, eventsetidoutarr, eventsetidoutj, JNI_COMMIT);
DEBUG_PRINT("new eventset is %d", eventset);
return PAPI_OK;
}
开发者ID:vhotspur,项目名称:papi-java,代码行数:25,代码来源:eventset.c
示例5: counter_init
void counter_init( int *eventset, int *num_papi_events )
{
char error_str[PAPI_MAX_STR_LEN];
// int events[] = {PAPI_TOT_INS,PAPI_BR_INS,PAPI_SR_INS};
int events[] = {PAPI_TOT_CYC,PAPI_L3_TCM};
int stat;
int thread = omp_get_thread_num();
if( thread == 0 )
printf("Initializing PAPI counters...\n");
*num_papi_events = sizeof(events) / sizeof(int);
if ((stat = PAPI_thread_init((long unsigned int (*)(void)) omp_get_thread_num)) != PAPI_OK) {
PAPI_perror("PAPI_thread_init");
exit(1);
}
if ( (stat= PAPI_create_eventset(eventset)) != PAPI_OK) {
PAPI_perror("PAPI_create_eventset");
exit(1);
}
for( int i = 0; i < *num_papi_events; i++ ) {
if ((stat=PAPI_add_event(*eventset,events[i])) != PAPI_OK) {
PAPI_perror("PAPI_add_event");
exit(1);
}
}
if ((stat=PAPI_start(*eventset)) != PAPI_OK) {
PAPI_perror("PAPI_start");
exit(1);
}
}
开发者ID:AMDComputeLibraries,项目名称:ComputeApps,代码行数:35,代码来源:papi.cpp
示例6: papi_init
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));
}
}
开发者ID:gronostajo,项目名称:oora_lab6,代码行数:27,代码来源:papi.c
示例7: my_papi_start
void my_papi_start( int myrank )
{
#ifdef PAPI_MONITOR
int retval, index ;
char EventCodeStr[PAPI_MAX_STR_LEN];
if(myrank == 0)
DO_TEST = 1;
retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT)
{
fprintf(stderr, "PAPI library init error! %d\n", retval);
exit(1);
}
fprintf(stderr,"PAPI Library start ...\n");
if (PAPI_create_eventset(&PAPI_EventSet) != PAPI_OK)
exit(1);
for (index = 0 ; index < NEVENTS ; index ++)
{
PAPI_event_code_to_name(PAPI_events[index], EventCodeStr);
/*fprintf(stderr,"Adding event %s ... ",EventCodeStr); */
if (PAPI_add_event(PAPI_EventSet,PAPI_events[index]) != PAPI_OK)
exit(1);
/*fprintf(stderr," DONE !\n"); */
}
/*fprintf(stderr,"\n"); */
if (PAPI_start(PAPI_EventSet) != PAPI_OK)
exit(1);
#endif /*PAPI_MONITOR */
}
开发者ID:ParaStation,项目名称:psmpi2,代码行数:34,代码来源:papi_defs.c
示例8: vt_metric_test
static void vt_metric_test(void)
{
int i;
int retval;
int EventSet = PAPI_NULL;
/* create event set */
retval = PAPI_create_eventset(&EventSet);
if ( retval != PAPI_OK)
vt_metric_error(retval, "PAPI_create_eventset");
for ( i = 0; i < nmetrics; i++ )
{
/* add event to event set */
retval = PAPI_add_event(EventSet, metricv[i]->papi_code);
if ( retval != PAPI_OK ) {
char errstring[PAPI_MAX_STR_LEN];
sprintf(errstring, "PAPI_add_event(%d:\"%s\")", i, metricv[i]->name);
vt_metric_error(retval, errstring);
}
vt_cntl_msg("Event %s added to event set", metricv[i]->name);
}
retval = PAPI_cleanup_eventset(EventSet);
if ( retval != PAPI_OK )
vt_metric_error(retval, "PAPI_cleanup_eventset");
retval = PAPI_destroy_eventset(&EventSet);
if ( retval != PAPI_OK )
vt_metric_error(retval, "PAPI_destroy_eventset");
vt_cntl_msg("Event set tested OK");
}
开发者ID:rjrpaz,项目名称:MyOpenMPI,代码行数:32,代码来源:vt_metric_papi.c
示例9: start_papi
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));
}
}
}
开发者ID:kuba13,项目名称:optymalizacje,代码行数:31,代码来源:compressed_mat_register.c
示例10: int
MeasureTimePAPI::MeasureTimePAPI(unsigned long int (*threadHandle)()) : MeasureTime(), threadHandle(threadHandle)
{
_events = new int[NUM_PAPI_EVENTS];
#ifdef USE_PAPI
_events[0] = PAPI_TOT_CYC;
_events[1] = PAPI_L2_TCM;
_events[2] = PAPI_TOT_INS;
_eventSet = PAPI_NULL;
int initRetVal = PAPI_library_init(PAPI_VER_CURRENT);
if (initRetVal != PAPI_VER_CURRENT && initRetVal > 0)
{
std::cerr << "PAPI library init failed!" << std::endl;
exit(1);
}
if (PAPI_thread_init(threadHandle) != PAPI_OK)
{
std::cerr << "PAPI thread init failed!" << std::endl;
exit(1);
}
if (PAPI_create_eventset(&_eventSet) != PAPI_OK)
{
std::cerr << "PAPI create eventset failed!" << " Error: " << PAPI_create_eventset(&_eventSet) << std::endl;
exit(1);
}
if (PAPI_add_events(_eventSet, _events, NUM_PAPI_EVENTS) != PAPI_OK)
{
std::cerr << "PAPI add events failed!" << std::endl;
exit(1);
}
if (PAPI_start(_eventSet) != PAPI_OK)
{
std::cerr << "PAPI_start_counters - FAILED" << std::endl;
throw ModelicaSimulationError(UTILITY,"PAPI_start_counters - FAILED");
}
#else
_eventSet = 0;
throw ModelicaSimulationError(UTILITY,"Papi not supported!");
#endif
}
开发者ID:AntonDV235,项目名称:OMCompiler,代码行数:46,代码来源:measure_time_papi.cpp
示例11: compute
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
}
开发者ID:goyalankit,项目名称:benchmark-tools,代码行数:56,代码来源:test2.c
示例12: main
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 );
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:55,代码来源:case1.c
示例13: check_event
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 );
}
开发者ID:naps62,项目名称:CPD_PAPI,代码行数:54,代码来源:all_native_events.c
示例14: metric_test
/* Test whether requested event combination valid */
static void metric_test(void)
{
int i, j;
int retval;
int component;
struct eventmap_t * EventSet[VT_METRIC_MAXNUM];
for (i=0; i<VT_METRIC_MAXNUM; i++)
EventSet[i] = NULL;
for (i=0; i < nmetrics; i++) {
#ifdef PAPIC
/* Preset-counter belong to Component 0! */
component = PAPI_COMPONENT_INDEX(metricv[i]->papi_code);
#else
component = 0;
#endif
/* search for the eventset that matches the counter */
j=0;
while (EventSet[j]!=NULL && j < VT_METRIC_MAXNUM && EventSet[j]->ComponentId!=component){
j++;
}
if (EventSet[j]==NULL) /* create eventset, if no matching found */
{
EventSet[j] = malloc(sizeof(eventmap_t));
EventSet[j]->EventId=PAPI_NULL;
retval = PAPI_create_eventset(&(EventSet[j]->EventId));
if ( retval != PAPI_OK)
metric_error(retval, "PAPI_create_eventset");
EventSet[j]->ComponentId=component;
}
/* add event to event set */
retval = PAPI_add_event(EventSet[j]->EventId, metricv[i]->papi_code);
if ( retval != PAPI_OK ) {
char errstring[PAPI_MAX_STR_LEN];
sprintf(errstring, "PAPI_add_event(%d:\"%s\")", i, metricv[i]->name);
metric_error(retval, errstring);
}
vt_cntl_msg(2, "Event %s added to event set", metricv[i]->name);
}
/* foreach used eventset */
for (i=0; i < VT_METRIC_MAXNUM && EventSet[i]!=NULL; i++)
{
retval = PAPI_cleanup_eventset(EventSet[i]->EventId);
if ( retval != PAPI_OK )
metric_error(retval, "PAPI_cleanup_eventset");
retval = PAPI_destroy_eventset(&(EventSet[i]->EventId));
if ( retval != PAPI_OK )
metric_error(retval, "PAPI_destroy_eventset");
free(EventSet[i]);
}
vt_cntl_msg(2, "Event set tested OK");
}
开发者ID:315234,项目名称:OpenFOAM-2.2.x-OSX,代码行数:55,代码来源:vt_metric_papi.c
示例15: my_thread
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 );
}
开发者ID:arm-hpc,项目名称:papi,代码行数:53,代码来源:krentel_pthreads.c
示例16: compute
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
}
开发者ID:goyalankit,项目名称:benchmark-tools,代码行数:52,代码来源:random_access.c
示例17: start_EVENTPAPI
void start_EVENTPAPI(int ind, int EventCode)
{
/* Create the Event Set */
if (PAPI_create_eventset(&oscrData_timerPAPIEventSet[ind]) != PAPI_OK)
OSCR_error("PAPI create eventset error!\n", -1);
/* Add Total Instructions Executed to our EventSet */
if (PAPI_add_event(&oscrData_timerPAPIEventSet[ind], EventCode) != PAPI_OK)
OSCR_error("PAPI add events error!\n", -1);
if (PAPI_start(oscrData_timerPAPIEventSet[ind]) != PAPI_OK)
OSCR_error("PAPI start init error!\n", -1);
}
开发者ID:shayany,项目名称:openmp,代码行数:13,代码来源:ompscrCommon.cpp
示例18: CheckInOrder
/* CheckInOrder
Check if we can add all the counters in the order given.
This will just iterate through all counters trying to add them in the
eventset.
*/
void CheckInOrder (int ncounters, unsigned *counters)
{
int rc;
int i;
int naddedcounters;
int EventSet = PAPI_NULL;
char EventName[PAPI_MAX_STR_LEN];
#if 0
fprintf (stdout, "\n** Checking in order the following counters: ");
for (i = 0; i < ncounters; i++)
{
rc = PAPI_event_code_to_name (counters[i], EventName);
if (rc == PAPI_OK)
fprintf (stdout, "%s%s", i>0?",":"", EventName);
else
fprintf (stdout, "%s%08x", i>0?",":"", counters[i]);
}
fprintf (stdout, "\n");
#endif
if (PAPI_create_eventset(&EventSet) != PAPI_OK)
{
fprintf (stderr, "Error! Failed to create the eventset!\n");
return;
}
fprintf (stdout, "Suggested compatible counters preserving the given priority:\n");
for (naddedcounters = 0, i = 0; i < ncounters; i++)
{
if (PAPI_add_event (EventSet, counters[i]) == PAPI_OK)
{
rc = PAPI_event_code_to_name (counters[i], EventName);
if (rc == PAPI_OK)
fprintf (stdout, "%s%s", i>0?",":"", EventName);
else
fprintf (stdout, "%s%08x", i>0?",":"", counters[i]);
naddedcounters++;
}
}
if (naddedcounters > 0)
fprintf (stdout, " (set of %d counters)\n\n", naddedcounters);
else
fprintf (stdout, "NONE!\n\n");
if (PAPI_cleanup_eventset(EventSet) != PAPI_OK)
fprintf (stderr, "Error! Failed to cleanup the eventset\n");
if (PAPI_destroy_eventset (&EventSet) != PAPI_OK)
fprintf (stderr, "Error! Failed to destroy the eventset\n");
}
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00010,代码行数:57,代码来源:papi_best_set.c
示例19: PAPI_library_init
void Timing::setPapiEvents(std::vector<std::string> names){
#ifdef KRIPKE_USE_PAPI
static bool papi_initialized = false;
if(!papi_initialized){
//printf("PAPI INIT\n");
int retval = PAPI_library_init(PAPI_VER_CURRENT);
papi_initialized = true;
if(retval != PAPI_VER_CURRENT){
fprintf(stderr, "ERROR INITIALIZING PAPI\n");
exit(1);
}
}
//printf("PAPI VERSION=%x\n",
// PAPI_VERSION);
papi_set = PAPI_NULL;
PAPI_create_eventset(&papi_set);
for(int i = 0;i < names.size();++ i){
// Convert text string to PAPI id
int event_code;
PAPI_event_name_to_code(
const_cast<char*>(names[i].c_str()),
&event_code);
// TODO: error checking?
// Add to our list of PAPI events
papi_names.push_back(names[i]);
papi_event.push_back(event_code);
int retval = PAPI_add_event(papi_set, event_code);
if(retval != PAPI_OK){
fprintf(stderr, "ERROR ADDING %s, retval=%d, ID=0x%-10x\n", names[i].c_str(), retval, event_code);
}
//printf("EVT=%s, ID=0x%-10x\n", names[i].c_str(), event_code);
}
PAPI_start(papi_set);
#else
if(names.size() > 0){
fprintf(stderr, "WARNING: PAPI NOT ENABLED, IGNORING PAPI EVENTS\n");
}
#endif
}
开发者ID:DavidPoliakoff,项目名称:performance-test-suite,代码行数:50,代码来源:Timing.cpp
示例20: MBStartPAPI
int MBStartPAPI(void)
{
system("rm -f *.mbo");
#ifdef EXETIME
gettimeofday(&MB_Start, NULL);
#else
MB_EventSet = PAPI_NULL;
PAPI_library_init(PAPI_VER_CURRENT);
PAPI_create_eventset(&MB_EventSet);
PAPI_add_event(MB_EventSet, PAPI_TOT_CYC);
PAPI_start(MB_EventSet);
#endif
return 0;
}
开发者ID:Bootz,项目名称:multicore-opimization,代码行数:14,代码来源:Functions_IPB.c
注:本文中的PAPI_create_eventset函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论