当前位置: 首页>>代码示例>>C++>>正文


C++ PAPI_cleanup_eventset函数代码示例

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


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

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

示例2: free_energy_data

void free_energy_data(pwr_ctx_t *ctx) {
    if (ctx == NULL) {
        return;
    }

    if (!pwr_is_initialized(ctx, PWR_MODULE_ENERGY)) {
        ctx->error = PWR_UNINITIALIZED;
        return;
    }


    if (ctx->emeas_running) {
        pwr_stop_energy_count(ctx);
    }

    PAPI_cleanup_eventset(ctx->event_set);
    PAPI_destroy_eventset(&ctx->event_set);
    PAPI_shutdown();

    for (unsigned int i = 0; i < ctx->emeas->nbValues; ++i) {
        free(ctx->emeas->units[i]);
        free(ctx->emeas->names[i]);
    }
    free(ctx->emeas->values);
    free(ctx->emeas->units);
    free(ctx->emeas->names);
    free(ctx->emeas);

    ctx->error = PWR_OK;
}
开发者ID:reservoirlabs,项目名称:power-api,代码行数:30,代码来源:energy.c

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

示例4: PAPI_stop_counters

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

示例5: vt_metric_free

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);
}
开发者ID:315234,项目名称:OpenFOAM-2.2.x-OSX,代码行数:33,代码来源:vt_metric_papi.c

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

示例7: handle_error

/** @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;
}
开发者ID:bpgriner01,项目名称:pbdPAPI,代码行数:70,代码来源:papi_hl.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: mpx_remove_unused

/** Remove events that are not used any longer from the run 
 * list of events to multiplex by the handler
 * MUST BE CALLED WITH THE SIGNAL HANDLER DISABLED
 */
static void
mpx_remove_unused( MasterEvent ** head )
{
	MasterEvent *mev, *lastmev = NULL, *nextmev;
	Threadlist *thr = ( *head == NULL ) ? NULL : ( *head )->mythr;
	int retval;

	/* Clean up and remove unused master events. */
	for ( mev = *head; mev != NULL; mev = nextmev ) {
		nextmev = mev->next; /* get link before mev is freed */
		if ( !mev->uses ) {
			if ( lastmev == NULL ) {	/* this was the head event */
				*head = nextmev;
			} else {
				lastmev->next = nextmev;
			}
			retval=PAPI_cleanup_eventset( mev->papi_event );
			retval=PAPI_destroy_eventset( &( mev->papi_event ) );
			if (retval!=PAPI_OK) PAPIERROR("Error destroying event\n");
			papi_free( mev );
		} else {
			lastmev = mev;
		}
	}

	/* Always be sure the head master event points to the thread */
	if ( *head != NULL ) {
		( *head )->mythr = thr;
	}
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:34,代码来源:sw_multiplex.c

示例10: vt_metric_free

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");*/
    }
}
开发者ID:rjrpaz,项目名称:MyOpenMPI,代码行数:28,代码来源:vt_metric_papi.c

示例11: esd_metric_free

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

示例12: GPTL_PAPIfinalize

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;
}
开发者ID:ACME-Climate,项目名称:cime,代码行数:25,代码来源:gptl_papi.c

示例13: PAPI_HW_COUNTER_close

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

}
开发者ID:LaminarIR,项目名称:framework,代码行数:44,代码来源:papi_hw_counter.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: 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


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