• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PAPI_add_event函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PAPI_add_event函数的典型用法代码示例。如果您正苦于以下问题:C++ PAPI_add_event函数的具体用法?C++ PAPI_add_event怎么用?C++ PAPI_add_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PAPI_add_event函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PAPI_add_env_event

int PAPI_add_env_event(int *EventSet, int *EventCode, char *env_variable){
  int real_event=*EventCode;
  char *eventname;
  int retval;
 
  if ( env_variable != NULL ){
    if ( (eventname=getenv(env_variable)) ) {
        if ( eventname[0] == 'P' ) {  /* Use the PAPI name */
           retval=PAPI_event_name_to_code(eventname, &real_event );
           if ( retval != PAPI_OK ) real_event = *EventCode;
        }
        else{
           if ( strlen(eventname)>1 && eventname[1]=='x')
                sscanf(eventname, "%#x", &real_event);
           else
               real_event = atoi(eventname);
        }
    }
  }
  if ( (retval = PAPI_add_event( *EventSet, real_event))!= PAPI_OK ){
        if ( real_event != *EventCode ) {
                if ( (retval = PAPI_add_event( *EventSet, *EventCode)) == PAPI_OK
){
                        real_event = *EventCode;
                }
        }
  }
  *EventCode = real_event;
  return retval;
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:30,代码来源:Papi_add_env_event.c


示例2: _hl_rate_calls

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;
}
开发者ID:tcreech,项目名称:papi-4.0.0-64-solaris11.2,代码行数:60,代码来源:papi_hl.c


示例3: 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


示例4: 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


示例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: 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


示例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: PAPI_start_counters

int PAPI_start_counters(int *events, int array_len)
{
   int i, retval;
   HighLevelInfo *state = NULL;

   if ((retval = _internal_check_state(&state)) != PAPI_OK)
      return (retval);

   if(state->running != 0)
	return(PAPI_EINVAL);

   /* load events to the new EventSet */
   for (i = 0; i < array_len; i++) {
      retval = PAPI_add_event(state->EventSet, events[i]);
      if (retval == PAPI_EISRUN)
         return (retval);

      if (retval) {
         /* remove any prior events that may have been added 
          * and cleanup the high level information
          */
         _internal_cleanup_hl_info(state);
         PAPI_cleanup_eventset(state->EventSet);
         return (retval);
      }
   }
   /* start the EventSet */
   if ((retval = _internal_start_hl_counters(state)) == PAPI_OK) {
      state->running = HL_START_COUNTERS;
      state->num_evts = array_len;
   }
   return (retval);
}
开发者ID:tcreech,项目名称:papi-4.0.0-64-solaris11.2,代码行数:33,代码来源:papi_hl.c


示例11: 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


示例12: measure_event

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 );
}
开发者ID:naps62,项目名称:CPD_PAPI,代码行数:34,代码来源:data_range.c


示例13: polybench_papi_start_counter

int polybench_papi_start_counter(int evid)
{
# ifndef POLYBENCH_NO_FLUSH_CACHE
    polybench_flush_cache();
# endif

# ifdef _OPENMP
# pragma omp parallel
  {
    if (omp_get_thread_num () == polybench_papi_counters_threadid)
      {
# endif

	int retval = 1;
	char descr[PAPI_MAX_STR_LEN];
	PAPI_event_info_t evinfo;
	PAPI_event_code_to_name (polybench_papi_eventlist[evid], descr);
	if (PAPI_add_event (polybench_papi_eventset,
			    polybench_papi_eventlist[evid]) != PAPI_OK)
	  test_fail (__FILE__, __LINE__, "PAPI_add_event", 1);
	if (PAPI_get_event_info (polybench_papi_eventlist[evid], &evinfo)
	    != PAPI_OK)
	  test_fail (__FILE__, __LINE__, "PAPI_get_event_info", retval);
	if ((retval = PAPI_start (polybench_papi_eventset)) != PAPI_OK)
	  test_fail (__FILE__, __LINE__, "PAPI_start", retval);
# ifdef _OPENMP
      }
  }
#pragma omp barrier
# endif
  return 0;
}
开发者ID:andrewliberis,项目名称:PolyBench-ACC,代码行数:32,代码来源:polybench.c


示例14: 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


示例15: 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


示例16: 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


示例17: 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


示例18: add_remove_event

static int add_remove_event(int EventSet, int evt)
{
	int retval;

	if((retval=PAPI_add_event(EventSet, evt)) != PAPI_OK) {
		printf("Error adding event.\n");
	} else {
		if((retval=PAPI_remove_event(EventSet,evt))!=PAPI_OK)
			printf("Error removing event.\n");
	}
	return(retval);
}
开发者ID:tcreech,项目名称:papi-4.0.0-64-solaris11.2,代码行数:12,代码来源:event_chooser.c


示例19: init_test

void 
init_test(int SoftwareMPX, int KernelMPX, int* Events)
{
  int i;
  int retval;
  PAPI_option_t option, itimer;

  if ( ( retval = PAPI_assign_eventset_component( SoftwareMPX, 0 ) ) != PAPI_OK )
	test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component", retval);

  if ( ( retval = PAPI_assign_eventset_component( KernelMPX, 0 ) ) != PAPI_OK )
	test_fail( __FILE__, __LINE__, "PAPI_assign_eventset_component", retval);

  if ( ( retval = PAPI_set_multiplex( KernelMPX ) ) != PAPI_OK )
	test_fail( __FILE__, __LINE__, "PAPI_set_multiplex", retval );

  PAPI_get_opt(PAPI_DEF_ITIMER,&itimer);

  memset(&option,0x0,sizeof(option));

  option.multiplex.flags = PAPI_MULTIPLEX_FORCE_SW;
  option.multiplex.eventset = SoftwareMPX;
  option.multiplex.ns = itimer.itimer.ns;

  PAPI_set_opt( PAPI_MULTIPLEX, &option );

  for (i = 0; i < options.min - 1; i++) {
	if ( options.kernel_mpx ) {
	  if ( ( retval = PAPI_add_event( KernelMPX, Events[i]) ) != PAPI_OK ) {
		test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
	  }
	}

	if ( options.force_sw ) {
	  if ( ( retval = PAPI_add_event( SoftwareMPX, Events[i]) ) != PAPI_OK ) {
		test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
	  }
	}
  }
}
开发者ID:FMCalisto,项目名称:SMP,代码行数:40,代码来源:multiplex_cost.c


示例20: 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



注:本文中的PAPI_add_event函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PAPI_cleanup_eventset函数代码示例发布时间:2022-05-30
下一篇:
C++ PAPIERROR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap