Ejemplo n.º 1
0
/*
 * Native Event functions
 */
int
_net_ntv_enum_events( unsigned int *EventCode, int modifier )
{
    int index;
    int cidx = PAPI_COMPONENT_INDEX( *EventCode );

    switch ( modifier ) {
        case PAPI_ENUM_FIRST:
            if (num_events==0) {
                return PAPI_ENOEVNT;
            }
            *EventCode = PAPI_NATIVE_MASK | PAPI_COMPONENT_MASK(cidx);
            return PAPI_OK;
            break;

        case PAPI_ENUM_EVENTS:
            index = *EventCode & PAPI_NATIVE_AND_MASK & PAPI_COMPONENT_AND_MASK;
            if ( index < num_events - 1 ) {
                *EventCode = *EventCode + 1;
                return PAPI_OK;
            } else {
                return PAPI_ENOEVNT;
            }
            break;

        default:
            return PAPI_EINVAL;
            break;
    }
    return PAPI_EINVAL;
}
Ejemplo n.º 2
0
/*
 * Native Event functions
 */
int
CNKUNIT_ntv_enum_events( unsigned int *EventCode, int modifier )
{
#ifdef DEBUG_BGQ
//	printf( "CNKUNIT_ntv_enum_events\n" );
#endif
	int cidx = PAPI_COMPONENT_INDEX( *EventCode );

	switch ( modifier ) {
	case PAPI_ENUM_FIRST:
		*EventCode = PAPI_NATIVE_MASK | PAPI_COMPONENT_MASK( cidx );

		return ( PAPI_OK );
		break;

	case PAPI_ENUM_EVENTS:
	{
		int index = ( *EventCode & PAPI_NATIVE_AND_MASK & PAPI_COMPONENT_AND_MASK ) + OFFSET;

		if ( index < CNKUNIT_MAX_COUNTERS ) {
			*EventCode = *EventCode + 1;
			return ( PAPI_OK );
		} else
			return ( PAPI_ENOEVNT );

		break;
	}
	default:
		return ( PAPI_EINVAL );
	}
	return ( PAPI_EINVAL );
}
Ejemplo n.º 3
0
/** Enumerate Native Events 
   @param EventCode is the event of interest
   @param modifier is one of PAPI_ENUM_FIRST, PAPI_ENUM_EVENTS
*/
int coretemp_ntv_enum_events (unsigned int *EventCode, int modifier)
{
	int cidx = PAPI_COMPONENT_INDEX( *EventCode );

	switch ( modifier )
	{
		/* return EventCode of first event */
		case PAPI_ENUM_FIRST:
		*EventCode = PAPI_NATIVE_MASK | PAPI_COMPONENT_MASK( cidx );
		return PAPI_OK;
		break;

		/* return EventCode of passed-in Event */
		case PAPI_ENUM_EVENTS:
		{
			int index = *EventCode & PAPI_NATIVE_AND_MASK & PAPI_COMPONENT_AND_MASK;

			if ( index < CORETEMP_NUM_EVENTS - 1 )
			{
				*EventCode = *EventCode + 1;
				return PAPI_OK;
			}
			else
				return PAPI_ENOEVNT;
			break;
		}

		default:
			return PAPI_EINVAL;
	}

	return PAPI_EINVAL;
}
Ejemplo n.º 4
0
/* 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");
}
Ejemplo n.º 5
0
struct esd_metv* esd_metric_create()
{
  struct esd_metv* metv;
  int retval, i, /* KF */ comp;
  
  if ( nmetrics == 0 )
    return NULL;
  
  metv = malloc(sizeof(struct esd_metv));
  if ( metv == NULL )
    elg_error();
  
  /* create event set */
  /* KF: create one per component */
  for( i=0; i<ELG_PAPIC_MAX_COMP; i++ ) {
    metv->EventSet[i]  = PAPI_NULL;
    metv->NumEvents[i] = 0;
      
    retval = PAPI_create_eventset(&metv->EventSet[i]);
    if ( retval != PAPI_OK)
      esd_metric_error(retval, "PAPI_create_eventset");
  }
  
  for ( i = 0; i < nmetrics; i++ ) {
    /* add event to event set */
      
    /* KF: figure out the right component and track mapping*/
    comp = PAPI_COMPONENT_INDEX( metricv[i]->papi_code );
    metv->Comp2Metr[comp][metv->NumEvents[comp]]=i;

    retval = PAPI_add_event(metv->EventSet[comp], metricv[i]->papi_code);
    if ( retval != PAPI_OK )
      esd_metric_error(retval, "PAPI_add_event");
    else /* KF: success */
      metv->NumEvents[comp]++;
  }

  /* KF: start only those event sets with events added */
  for( i=0; i<ELG_PAPIC_MAX_COMP; i++ ) {
    if( metv->NumEvents[i]>0 ) {
      retval = PAPI_start(metv->EventSet[i]);
      if ( retval != PAPI_OK )
        esd_metric_error(retval, "PAPI_start");
    }
  }

  elg_cntl_msg("Counters started");

  return metv;
}
Ejemplo n.º 6
0
void esd_metric_test()
{
  int i, j, comp;
  int retval;
  int EventSet[ELG_PAPIC_MAX_COMP]; /* KF */
  
  for( i=0; i<ELG_PAPIC_MAX_COMP; i++ ) {
    EventSet[i] = PAPI_NULL;

    /* create event set */
    retval = PAPI_create_eventset(&(EventSet[i]));
    if ( retval != PAPI_OK)
      esd_metric_error(retval, "PAPI_create_eventset");
  }
      
  for ( j = 0; j < nmetrics; j++ ) {
    /* add event to event set */
    /*fprintf(stderr,"Checking Metric %s, Component indes: %d,\n\n",metricv[j]->name,PAPI_COMPONENT_INDEX( metricv[j]->papi_code ));*/
    comp = PAPI_COMPONENT_INDEX( metricv[j]->papi_code );
    retval = PAPI_add_event(EventSet[comp], metricv[j]->papi_code);
    
      
    if ( retval != PAPI_OK ) {
      char errstring[PAPI_MAX_STR_LEN];
      sprintf(errstring, "PAPI_add_event(%d:\"%s\")", j, metricv[j]->name);
      esd_metric_error(retval, errstring);
    }
    elg_cntl_msg("Event %s added to event set", metricv[j]->name);
  }
  
  for( i=0; i<ELG_PAPIC_MAX_COMP; i++ ) {
    retval = PAPI_cleanup_eventset(EventSet[i]);
    if ( retval != PAPI_OK )
      esd_metric_error(retval, "PAPI_cleanup_eventset");
      
    retval = PAPI_destroy_eventset(&(EventSet[i]));
    if ( retval != PAPI_OK )
      esd_metric_error(retval, "PAPI_destroy_eventset");
  }
  elg_cntl_msg("Event set tested OK");
}
Ejemplo n.º 7
0
/** Enumerate Native Events
 *   @param EventCode is the event of interest
 *   @param modifier is one of PAPI_ENUM_FIRST, PAPI_ENUM_EVENTS
 *  If your component has attribute masks then these need to
 *   be handled here as well.
 */
		int
_papi_nvml_ntv_enum_events( unsigned int *EventCode, int modifier )
{
		int cidx,index;

		/* Get our component index number, this can change depending */
		/* on how PAPI was configured.                               */

		cidx = PAPI_COMPONENT_INDEX( *EventCode );

		switch ( modifier ) {

				/* return EventCode of first event */
				case PAPI_ENUM_FIRST:
						/* return the first event that we support */

						*EventCode = PAPI_NATIVE_MASK | PAPI_COMPONENT_MASK( cidx );
						return PAPI_OK;

						/* return EventCode of next available event */
				case PAPI_ENUM_EVENTS:
						index = *EventCode & PAPI_NATIVE_AND_MASK & PAPI_COMPONENT_AND_MASK;

						/* Make sure we are in range */
						if ( index < num_events - 1 ) {

								/* This assumes a non-sparse mapping of the events */
								*EventCode = *EventCode + 1;
								return PAPI_OK;
						} else {
								return PAPI_ENOEVNT;
						}
						break;

				default:
						return PAPI_EINVAL;
		}

		return PAPI_EINVAL;
}
Ejemplo n.º 8
0
/**
 * Native Event functions
 */
int
ACPI_ntv_enum_events( unsigned int *EventCode, int modifier )
{
    int cidx = PAPI_COMPONENT_INDEX( *EventCode );

    if ( modifier == PAPI_ENUM_FIRST ) {
        /* assumes first native event is always 0x4000000 */
        *EventCode = PAPI_NATIVE_MASK | PAPI_COMPONENT_MASK( cidx );
        return ( PAPI_OK );
    }

    if ( modifier == PAPI_ENUM_EVENTS ) {
        int index = *EventCode & PAPI_NATIVE_AND_MASK & PAPI_COMPONENT_AND_MASK;

        if ( acpi_native_table[index + 1].resources.selector ) {
            *EventCode = *EventCode + 1;
            return ( PAPI_OK );
        } else
            return ( PAPI_ENOEVNT );
    } else
        return ( PAPI_EINVAL );
}
Ejemplo n.º 9
0
int
_mx_ntv_enum_events( unsigned int *EventCode, int modifier )
{
	int cidx = PAPI_COMPONENT_INDEX( *EventCode );

	if ( modifier == PAPI_ENUM_FIRST ) {
	   if (num_events==0) return PAPI_ENOEVNT;
	   *EventCode = PAPI_NATIVE_MASK | PAPI_COMPONENT_MASK( cidx );
	   return PAPI_OK;
	}

	if ( modifier == PAPI_ENUM_EVENTS ) {
		int index = *EventCode & PAPI_NATIVE_AND_MASK & PAPI_COMPONENT_AND_MASK;

		if ( mx_native_table[index + 1].resources.selector ) {
			*EventCode = *EventCode + 1;
			return PAPI_OK;
		} else {
			return PAPI_ENOEVNT;
		}
	}
		
        return PAPI_EINVAL;
}
Ejemplo n.º 10
0
struct vt_metv* vt_metric_create()
{
  struct vt_metv* metv;
  int retval, i,j;
  int component;

  if ( nmetrics == 0 )
    return NULL;

  metv = (struct vt_metv*)malloc(sizeof(struct vt_metv));
  if ( metv == NULL )
    vt_error();

  /* create event set */
  for (i=0; i<VT_METRIC_MAXNUM; i++)
    metv->EventSet[i] = NULL;

  for (i=0; i < nmetrics; i++)
  {
    struct eventmap_t *eventset;

#ifdef PAPIC
    component = PAPI_COMPONENT_INDEX(metricv[i]->papi_code);
#else
    component = 0;
#endif
    /* search for the eventset that matches the counter */
    j=0;
    while (metv->EventSet[j]!=NULL && j < VT_METRIC_MAXNUM && metv->EventSet[j]->ComponentId!=component){
      j++;
    }
    if (metv->EventSet[j]==NULL) /* no event of this component yet! */
    {
      metv->EventSet[j] = (struct eventmap_t*)malloc(sizeof(eventmap_t));
      metv->EventSet[j]->EventId=PAPI_NULL;
      metv->EventSet[j]->nEvents = 0;
      retval = PAPI_create_eventset(&(metv->EventSet[j]->EventId));
      if ( retval != PAPI_OK)
        metric_error(retval, "PAPI_create_eventset");
      metv->EventSet[j]->ComponentId=component;
    }
    eventset = metv->EventSet[j];

    /* add event to event set */
    retval = PAPI_add_event(eventset->EventId, metricv[i]->papi_code);
    if ( retval != PAPI_OK )
      metric_error(retval, "PAPI_add_event");
    /* for demux the values from eventset -> returnvector */
    metv->Values[i] = &(eventset->Values[eventset->nEvents]);
    eventset->nEvents++;
  }

  /* foreach used eventset */
  for (i=0; i < VT_METRIC_MAXNUM && metv->EventSet[i]!=NULL; i++)
  {
    retval = PAPI_start(metv->EventSet[i]->EventId);
    if ( retval != PAPI_OK )
      metric_error(retval, "PAPI_start");
  }

  return metv;
}