|
PAPI
5.1.0.2
|
This file has the source code for a component that enables PAPI-C to access hardware monitoring counters for BG/Q through the BGPM library. More...

Go to the source code of this file.
Tested version of bgpm (early access)
Definition in file linux-bgq.c.
| #define get_cycles GetTimeBase |
Definition at line 48 of file linux-bgq.c.
| #define OPCODE_EVENT_CHUNK 8 |
Definition at line 63 of file linux-bgq.c.
| int _bgq_allocate_registers | ( | EventSetInfo_t * | ESI | ) |
Definition at line 317 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf("_bgq_allocate_registers\n");
#endif
int i, natNum;
int xEventId;
/*
* Start monitoring the events...
*/
natNum = ESI->NativeCount;
for ( i = 0; i < natNum; i++ ) {
xEventId = ( ESI->NativeInfoArray[i].ni_event & PAPI_NATIVE_AND_MASK ) + 1;
ESI->NativeInfoArray[i].ni_position = i;
}
return PAPI_OK;
}
| int _bgq_cleanup_eventset | ( | hwd_control_state_t * | ctrl | ) |
Definition at line 345 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_cleanup_eventset\n" );
#endif
// set multiplexing flag to OFF (0)
ctrl->muxOn = 0;
// set overflow flag to OFF (0)
ctrl->overflow = 0;
ctrl->overflow_threshold = 0;
ctrl->overflow_EventIndex = 0;
// set BGPM eventGroup flag back to NOT applied yet (0)
ctrl->bgpm_eventset_applied = 0;
return ( PAPI_OK );
}
| int _bgq_ctl | ( | hwd_context_t * | ctx, |
| int | code, | ||
| _papi_int_option_t * | option | ||
| ) |
Definition at line 873 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_ctl\n" );
#endif
( void ) ctx;
int retval;
switch ( code ) {
case PAPI_MULTIPLEX:
{
hwd_control_state_t * bgq_state = ( ( hwd_control_state_t * ) option->multiplex.ESI->ctl_state );
bgq_state->muxOn = 1;
retval = _bgq_multiplex( bgq_state );
return ( retval );
}
default:
return ( PAPI_OK );
}
}

| void _bgq_dispatch_timer | ( | int | signal, |
| hwd_siginfo_t * | info, | ||
| void * | uc | ||
| ) |
Definition at line 645 of file linux-bgq.c.
| int _bgq_get_dmem_info | ( | PAPI_dmem_info_t * | pDmemInfo | ) |
Definition at line 53 of file linux-bgq-memory.c.
{
// pid_t xPID = getpid();
// prpsinfo_t xInfo;
// char xFile[256];
// int xFD;
// sprintf(xFile, "/proc/%05d", xPID);
// if ((fd = open(xFile, O_RDONLY)) < 0) {
// SUBDBG("PAPI_get_dmem_info can't open /proc/%d\n", xPID);
// return (PAPI_ESYS);
// }
// if (ioctl(xFD, PIOCPSINFO, &xInfo) < 0) {
// return (PAPI_ESYS);
// }
// close(xFD);
pDmemInfo->size = PAPI_EINVAL;
pDmemInfo->resident = PAPI_EINVAL;
pDmemInfo->high_water_mark = PAPI_EINVAL;
pDmemInfo->shared = PAPI_EINVAL;
pDmemInfo->text = PAPI_EINVAL;
pDmemInfo->library = PAPI_EINVAL;
pDmemInfo->heap = PAPI_EINVAL;
pDmemInfo->locked = PAPI_EINVAL;
pDmemInfo->stack = PAPI_EINVAL;
pDmemInfo->pagesize = PAPI_EINVAL;
return PAPI_OK;
}
| int _bgq_get_memory_info | ( | PAPI_hw_info_t * | pHwInfo, |
| int | pCPU_Type | ||
| ) |
Definition at line 33 of file linux-bgq-memory.c.
{
int retval = 0;
switch ( pCPU_Type ) {
default:
//fprintf(stderr,"Default CPU type in %s (%d)\n",__FUNCTION__,__LINE__);
retval = init_bgq( &pHwInfo->mem_hierarchy );
break;
}
return retval;
}


| long long _bgq_get_real_cycles | ( | void | ) |
Definition at line 920 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_get_real_cycles\n" );
#endif
return ( ( long long ) get_cycles( ) );
}

| long long _bgq_get_real_usec | ( | void | ) |
Definition at line 898 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_get_real_usec\n" );
#endif
/*
* NOTE: _papi_hwi_system_info.hw_info.mhz is really a representation of unit of time per cycle.
* On BG/P, it's value is 8.5e-4. Therefore, to get cycles per sec, we have to multiply
* by 1.0e12. To then convert to usec, we have to divide by 1.0e-3.
*/
return ( ( long long ) ( ( ( float ) get_cycles( ) ) /
( ( _papi_hwi_system_info.hw_info.cpu_max_mhz ) ) ) );
}

| int _bgq_get_system_info | ( | papi_mdi_t * | mdi | ) |
Definition at line 138 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_get_system_info\n" );
#endif
( void ) mdi;
Personality_t personality;
int retval;
/* Hardware info */
retval = Kernel_GetPersonality( &personality, sizeof( Personality_t ) );
if ( retval ) {
fprintf( stdout, "Kernel_GetPersonality returned %d (sys error=%d).\n"
"\t%s\n", retval, errno, strerror( errno ) );
return PAPI_ESYS;
}
/* Returns the number of processors that are associated with the currently
* running process */
_papi_hwi_system_info.hw_info.ncpu = Kernel_ProcessorCount( );
// TODO: HJ Those values need to be fixed
_papi_hwi_system_info.hw_info.nnodes = Kernel_ProcessCount( );
_papi_hwi_system_info.hw_info.totalcpus = _papi_hwi_system_info.hw_info.ncpu;
_papi_hwi_system_info.hw_info.cpu_max_mhz = personality.Kernel_Config.FreqMHz;
_papi_hwi_system_info.hw_info.cpu_min_mhz = personality.Kernel_Config.FreqMHz;
_papi_hwi_system_info.hw_info.mhz = ( float ) personality.Kernel_Config.FreqMHz;
SUBDBG( "_bgq_get_system_info: Detected MHZ is %f\n",
_papi_hwi_system_info.hw_info.mhz );
return ( PAPI_OK );
}

| long long _bgq_get_virt_cycles | ( | void | ) |
Definition at line 951 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_get_virt_cycles\n" );
#endif
return _bgq_get_real_cycles( );
}

| long long _bgq_get_virt_usec | ( | void | ) |
Definition at line 936 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_get_virt_usec\n" );
#endif
return _bgq_get_real_usec( );
}

| int _bgq_init | ( | hwd_context_t * | ctx | ) |
Definition at line 233 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_init\n" );
#endif
( void ) ctx;
int retval;
#ifdef DEBUG_BGPM
Bgpm_PrintOnError(1);
Bgpm_ExitOnError(0);
#else
Bgpm_PrintOnError(0);
// avoid bgpm default of exiting when error occurs - caller will check return code instead.
Bgpm_ExitOnError(0);
#endif
retval = Bgpm_Init( BGPM_MODE_SWDISTRIB );
CHECK_BGPM_ERROR( retval, "Bgpm_Init" );
//_common_initBgpm();
return PAPI_OK;
}
| int _bgq_init_component | ( | int | cidx | ) |
Definition at line 968 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf("_bgq_init_substrate\n");
//printf("_bgq_init_substrate: 1. BGPM_INITIALIZED = %d \n", BGPM_INITIALIZED);
#endif
int retval;
int i;
/* allocate the opcode event structure */
GenericEvent = calloc( OPCODE_EVENT_CHUNK, sizeof( struct bgq_generic_events_t ) );
if ( NULL == GenericEvent ) {
return PAPI_ENOMEM;
}
/* init opcode event stuff */
allocated_opcode_events = OPCODE_EVENT_CHUNK;
num_opcode_events = 0;
_bgq_vectors.cmp_info.CmpIdx = cidx;
/*
* Fill in what we can of the papi_system_info
*/
SUBDBG( "Before _bgq_get_system_info()...\n" );
retval = _bgq_get_system_info( &_papi_hwi_system_info );
SUBDBG( "After _bgq_get_system_info(), retval=%d...\n", retval );
if ( retval != PAPI_OK )
return ( retval );
/*
* Setup memory info
*/
SUBDBG( "Before _bgq_get_memory_info...\n" );
retval = _bgq_get_memory_info( &_papi_hwi_system_info.hw_info,
( int ) _papi_hwi_system_info.hw_info.
model );
SUBDBG( "After _bgq_get_memory_info, retval=%d...\n", retval );
if ( retval )
return ( retval );
#if 1
/* Setup Locks */
for ( i = 0; i < PAPI_MAX_LOCK; i++ )
thdLocks[i] = 0; // MUTEX_OPEN
#else
for( i = 0; i < PAPI_MAX_LOCK; i++ ) {
pthread_mutex_init( &thdLocks[i], NULL );
}
#endif
/* Setup presets */
retval = _papi_load_preset_table( "BGQ", 0, cidx );
if ( retval ) {
return retval;
}
return ( PAPI_OK );
}

| int _bgq_init_control_state | ( | hwd_control_state_t * | ptr | ) |
Definition at line 179 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_init_control_state\n" );
#endif
ptr->EventGroup = Bgpm_CreateEventSet();
CHECK_BGPM_ERROR( ptr->EventGroup, "Bgpm_CreateEventSet" );
// initialize multiplexing flag to OFF (0)
ptr->muxOn = 0;
// initialize overflow flag to OFF (0)
ptr->overflow = 0;
ptr->overflow_threshold = 0;
ptr->overflow_EventIndex = 0;
// initialized BGPM eventGroup flag to NOT applied yet (0)
ptr->bgpm_eventset_applied = 0;
return PAPI_OK;
}
| int _bgq_multiplex | ( | hwd_control_state_t * | bgq_state | ) |
Definition at line 260 of file linux-bgq.c.
{
int retval;
uint64_t bgpm_period;
double Sec, Hz;
#ifdef DEBUG_BGQ
printf("_bgq_multiplex BEGIN: Num of Events = %d (vs %d)\n", Bgpm_NumEvents( bgq_state->EventGroup ), bgq_state->count );
#endif
// convert Mhz to Hz ( = cycles / sec )
Hz = (double) _papi_hwi_system_info.hw_info.cpu_max_mhz * 1000 * 1000;
// convert PAPI multiplex period (in ns) to BGPM period (in cycles)
Sec = (double) _papi_os_info.itimer_ns / ( 1000 * 1000 * 1000 );
bgpm_period = Hz * Sec;
// if EventGroup is not empty -- which is required by BGPM before
// we can call SetMultiplex() -- then drain the events from the
// BGPM EventGroup, turn on multiplex flag, and rebuild BGPM EventGroup.
if ( 0 < bgq_state->count ) {
// Delete and re-create BGPM eventset
_common_deleteRecreate( &bgq_state->EventGroup );
// turn on multiplex for BGPM
retval = Bgpm_SetMultiplex( bgq_state->EventGroup, bgpm_period, BGPM_NORMAL );
CHECK_BGPM_ERROR( retval, "Bgpm_SetMultiplex" );
// rebuild BGPM EventGroup
_common_rebuildEventgroup( bgq_state->count,
bgq_state->EventGroup_local,
&bgq_state->EventGroup );
}
else {
// need to pass either BGPM_NORMAL or BGPM_NOTNORMAL
// BGPM_NORMAL: numbers reported by Bgpm_ReadEvent() are normalized
// to the maximum time spent in a multiplexed group
retval = Bgpm_SetMultiplex( bgq_state->EventGroup, bgpm_period, BGPM_NORMAL );
CHECK_BGPM_ERROR( retval, "Bgpm_SetMultiplex" );
}
#ifdef DEBUG_BGQ
printf("_bgq_multiplex END: Num of Events = %d (vs %d) --- retval = %d\n",
Bgpm_NumEvents( bgq_state->EventGroup ), bgq_state->count, retval );
#endif
return ( retval );
}


| int _bgq_ntv_code_to_bits | ( | unsigned int | EventCode, |
| hwd_register_t * | bits | ||
| ) |
Definition at line 1195 of file linux-bgq.c.
| int _bgq_ntv_code_to_descr | ( | unsigned int | EventCode, |
| char * | name, | ||
| int | len | ||
| ) |
Definition at line 1170 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_ntv_code_to_descr\n" );
#endif
int retval;
int index = ( EventCode & PAPI_NATIVE_AND_MASK ) + 1;
retval = Bgpm_GetLongDesc( index, name, &len );
CHECK_BGPM_ERROR( retval, "Bgpm_GetLongDesc" );
return ( PAPI_OK );
}
| int _bgq_ntv_code_to_name | ( | unsigned int | EventCode, |
| char * | name, | ||
| int | len | ||
| ) |
Definition at line 1139 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_ntv_code_to_name\n" );
#endif
int index = ( EventCode & PAPI_NATIVE_AND_MASK ) + 1;
if ( index >= MAX_COUNTERS )
return PAPI_ENOEVNT;
strncpy( name, Bgpm_GetEventIdLabel( index ), len );
if ( name == NULL ) {
#ifdef DEBUG_BGPM
printf ("Error: ret value is NULL for BGPM API function Bgpm_GetEventIdLabel.\n" );
#endif
return PAPI_ENOEVNT;
}
#ifdef DEBUG_BGQ
printf( "name = ===%s===\n", name );
#endif
return ( PAPI_OK );
}
| int _bgq_ntv_enum_events | ( | unsigned int * | EventCode, |
| int | modifier | ||
| ) |
Definition at line 1212 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_ntv_enum_events\n" );
#endif
switch ( modifier ) {
case PAPI_ENUM_FIRST:
*EventCode = PAPI_NATIVE_MASK;
return ( PAPI_OK );
break;
case PAPI_ENUM_EVENTS:
{
int index = ( *EventCode & PAPI_NATIVE_AND_MASK ) + 1;
if ( index < BGQ_PUNIT_MAX_COUNTERS ) {
*EventCode = *EventCode + 1;
return ( PAPI_OK );
} else
return ( PAPI_ENOEVNT );
break;
}
default:
return ( PAPI_EINVAL );
}
return ( PAPI_EINVAL );
}
| int _bgq_ntv_name_to_code | ( | char * | name, |
| unsigned int * | event_code | ||
| ) |
Definition at line 1038 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_ntv_name_to_code\n" );
#endif
int ret;
#ifdef DEBUG_BGQ
printf( "name = ===%s===\n", name );
#endif
/* Treat events differently if BGPM Opcodes are used */
/* Opcode group selection values are "OR"ed together to create a desired
mask of instruction group events to accumulate in the same counter */
if ( 0 == strncmp( name, "PEVT_INST_XU_GRP_MASK", strlen( "PEVT_INST_XU_GRP_MASK" ) ) ||
0 == strncmp( name, "PEVT_INST_QFPU_GRP_MASK", strlen( "PEVT_INST_QFPU_GRP_MASK" ) ) ) {
char *pcolon;
pcolon = strchr( name, ':' );
// Found colon separator
if ( pcolon != NULL ) {
int mask_len = pcolon - name;
strncpy( GenericEvent[num_opcode_events].mask, name, mask_len );
strncpy( GenericEvent[num_opcode_events].opcode, pcolon+1, strlen(name) - 1 - mask_len );
/* opcode_mask needs to be 'uint64_t',
hence we use strtoull() which returns an 'unsigned long long int' */
GenericEvent[num_opcode_events].opcode_mask = strtoull( GenericEvent[num_opcode_events].opcode, (char **)NULL, 16 );
GenericEvent[num_opcode_events].idx = OPCODE_BUF + num_opcode_events;
/* Return event id matching the generic XU/QFPU event string */
GenericEvent[num_opcode_events].eventId = Bgpm_GetEventIdFromLabel( GenericEvent[num_opcode_events].mask );
if ( GenericEvent[num_opcode_events].eventId <= 0 ) {
#ifdef DEBUG_BGPM
printf ("Error: ret value is %d for BGPM API function '%s'.\n",
ret, "Bgpm_GetEventIdFromLabel" );
#endif
return PAPI_ENOEVNT;
}
*event_code = GenericEvent[num_opcode_events].idx;
num_opcode_events++;
/* If there are too many opcode events than allocated, then allocate more room */
if( num_opcode_events >= allocated_opcode_events ) {
SUBDBG("Allocating more room for BGPM opcode events (%d %ld)\n",
( allocated_opcode_events + NATIVE_OPCODE_CHUNK ),
( long )sizeof( struct bgq_generic_events_t ) *
( allocated_opcode_events + NATIVE_OPCODE_CHUNK ) );
GenericEvent = realloc( GenericEvent, sizeof( struct bgq_generic_events_t ) *
( allocated_opcode_events + OPCODE_EVENT_CHUNK ) );
if ( NULL == GenericEvent ) {
return PAPI_ENOMEM;
}
allocated_opcode_events += OPCODE_EVENT_CHUNK;
}
}
else {
SUBDBG( "Error: Found a generic BGPM event mask without opcode string\n" );
return PAPI_ENOEVNT;
}
#ifdef DEBUG_BGQ
printf(_AT_ " _bgq_ntv_name_to_code: GenericEvent no. %d: \n", num_opcode_events-1 );
printf( "idx = %d\n", GenericEvent[num_opcode_events-1].idx);
printf( "eventId = %d\n", GenericEvent[num_opcode_events-1].eventId);
printf( "mask = %s\n", GenericEvent[num_opcode_events-1].mask);
printf( "opcode = %s\n", GenericEvent[num_opcode_events-1].opcode);
printf( "opcode_mask = %" PRIX64 " (%" PRIu64 ")\n", GenericEvent[num_opcode_events-1].opcode_mask,
GenericEvent[num_opcode_events-1].opcode_mask );
#endif
}
else {
/* Return event id matching a given event label string */
ret = Bgpm_GetEventIdFromLabel ( name );
if ( ret <= 0 ) {
#ifdef DEBUG_BGPM
printf ("Error: ret value is %d for BGPM API function '%s'.\n",
ret, "Bgpm_GetEventIdFromLabel" );
#endif
return PAPI_ENOEVNT;
}
else if ( ret > BGQ_PUNIT_MAX_COUNTERS ) // not a PUnit event
return PAPI_ENOEVNT;
else
*event_code = ( ret - 1 );
}
return PAPI_OK;
}
| int _bgq_read | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ptr, | ||
| long_long ** | dp, | ||
| int | flags | ||
| ) |
Definition at line 540 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_read\n" );
#endif
( void ) ctx;
( void ) flags;
int i, numEvts;
numEvts = Bgpm_NumEvents( ptr->EventGroup );
if ( numEvts == 0 ) {
#ifdef DEBUG_BGPM
printf ("Error: ret value is %d for BGPM API function Bgpm_NumEvents.\n", numEvts );
//return ( EXIT_FAILURE );
#endif
}
for ( i = 0; i < numEvts; i++ )
ptr->counters[i] = _common_getEventValue( i, ptr->EventGroup );
*dp = ptr->counters;
return ( PAPI_OK );
}

| int _bgq_reset | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ptr | ||
| ) |
Definition at line 572 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_reset\n" );
#endif
( void ) ctx;
int retval;
/* we can't simply call Bgpm_Reset() since PAPI doesn't have the
restriction that an EventSet has to be stopped before resetting is
possible. However, BGPM does have this restriction.
Hence we need to stop, reset and start */
retval = Bgpm_Stop( ptr->EventGroup );
CHECK_BGPM_ERROR( retval, "Bgpm_Stop" );
retval = Bgpm_ResetStart( ptr->EventGroup );
CHECK_BGPM_ERROR( retval, "Bgpm_ResetStart" );
return ( PAPI_OK );
}
| int _bgq_set_domain | ( | hwd_control_state_t * | cntrl, |
| int | domain | ||
| ) |
Definition at line 205 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_set_domain\n" );
#endif
int found = 0;
( void ) cntrl;
if ( PAPI_DOM_USER & domain )
found = 1;
if ( PAPI_DOM_KERNEL & domain )
found = 1;
if ( PAPI_DOM_OTHER & domain )
found = 1;
if ( !found )
return ( PAPI_EINVAL );
return ( PAPI_OK );
}
| int _bgq_set_overflow | ( | EventSetInfo_t * | ESI, |
| int | EventIndex, | ||
| int | threshold | ||
| ) |
Definition at line 758 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf("BEGIN _bgq_set_overflow\n");
#endif
hwd_control_state_t * this_state = ( hwd_control_state_t * ) ESI->ctl_state;
int retval;
int evt_idx;
/*
* In case an BGPM eventGroup HAS BEEN applied or attached before
* overflow is set, delete the eventGroup and create an new empty one,
* and rebuild as it was prior to deletion
*/
#ifdef DEBUG_BGQ
printf( "_bgq_set_overflow: bgpm_eventset_applied = %d\n",
this_state->bgpm_eventset_applied );
#endif
if ( 1 == this_state->bgpm_eventset_applied ) {
_common_deleteRecreate( &this_state->EventGroup );
_common_rebuildEventgroup( this_state->count,
this_state->EventGroup_local,
&this_state->EventGroup );
/* set BGPM eventGroup flag back to NOT applied yet (0)
* because the eventGroup has been recreated from scratch */
this_state->bgpm_eventset_applied = 0;
}
evt_idx = ESI->EventInfoArray[EventIndex].pos[0];
//evt_id = ( ESI->NativeInfoArray[EventIndex].ni_event & PAPI_NATIVE_AND_MASK ) + 1;
SUBDBG( "Hardware counter %d (vs %d) used in overflow, threshold %d\n",
evt_idx, EventIndex, threshold );
#ifdef DEBUG_BGQ
printf( "Hardware counter %d (vs %d) used in overflow, threshold %d\n",
evt_idx, EventIndex, threshold );
#endif
/* If this counter isn't set to overflow, it's an error */
if ( threshold == 0 ) {
/* Remove the signal handler */
retval = _papi_hwi_stop_signal( _bgq_vectors.cmp_info.hardware_intr_sig );
if ( retval != PAPI_OK )
return ( retval );
}
else {
this_state->overflow = 1;
this_state->overflow_threshold = threshold;
this_state->overflow_EventIndex = evt_idx;
#ifdef DEBUG_BGQ
printf( "_bgq_set_overflow: Enable the signal handler\n" );
#endif
/* Enable the signal handler */
retval = _papi_hwi_start_signal( _bgq_vectors.cmp_info.hardware_intr_sig,
NEED_CONTEXT,
_bgq_vectors.cmp_info.CmpIdx );
if ( retval != PAPI_OK )
return ( retval );
_common_set_overflow_BGPM( this_state->EventGroup,
this_state->overflow_EventIndex,
this_state->overflow_threshold,
user_signal_handler );
}
return ( PAPI_OK );
}

| int _bgq_set_profile | ( | EventSetInfo_t * | ESI, |
| int | EventIndex, | ||
| int | threshold | ||
| ) |
Definition at line 836 of file linux-bgq.c.
| int _bgq_shutdown | ( | hwd_context_t * | ctx | ) |
Definition at line 602 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "_bgq_shutdown\n" );
#endif
( void ) ctx;
int retval;
/* Disable BGPM library */
retval = Bgpm_Disable();
CHECK_BGPM_ERROR( retval, "Bgpm_Disable" );
return ( PAPI_OK );
}
| int _bgq_start | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ptr | ||
| ) |
Definition at line 486 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "BEGIN _bgq_start\n" );
#endif
( void ) ctx;
int retval;
retval = Bgpm_Apply( ptr->EventGroup );
CHECK_BGPM_ERROR( retval, "Bgpm_Apply" );
// set flag to 1: BGPM eventGroup HAS BEEN applied
ptr->bgpm_eventset_applied = 1;
#ifdef DEBUG_BGQ
int i;
int numEvts = Bgpm_NumEvents( ptr->EventGroup );
for ( i = 0; i < numEvts; i++ ) {
printf("%d = %s\n", i, Bgpm_GetEventLabel( ptr->EventGroup, i) );
}
#endif
/* Bgpm_Apply() does an implicit reset;
hence no need to use Bgpm_ResetStart */
retval = Bgpm_Start( ptr->EventGroup );
CHECK_BGPM_ERROR( retval, "Bgpm_Start" );
return ( PAPI_OK );
}
| int _bgq_stop | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ptr | ||
| ) |
Definition at line 520 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "BEGIN _bgq_stop\n" );
#endif
( void ) ctx;
int retval;
retval = Bgpm_Stop( ptr->EventGroup );
CHECK_BGPM_ERROR( retval, "Bgpm_Stop" );
return ( PAPI_OK );
}
| int _bgq_stop_profiling | ( | ThreadInfo_t * | master, |
| EventSetInfo_t * | ESI | ||
| ) |
Definition at line 855 of file linux-bgq.c.
| int _bgq_update_control_state | ( | hwd_control_state_t * | ptr, |
| NativeInfo_t * | native, | ||
| int | count, | ||
| hwd_context_t * | ctx | ||
| ) |
Definition at line 372 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( _AT_ " _bgq_update_control_state: count = %d, EventGroup=%d\n", count, ptr->EventGroup );
#endif
( void ) ctx;
int i, j, index, retval;
unsigned evtIdx;
// Delete and re-create BGPM eventset
_common_deleteRecreate( &ptr->EventGroup );
#ifdef DEBUG_BGQ
printf( _AT_ " _bgq_update_control_state: EventGroup=%d, muxOn = %d, overflow = %d\n",
ptr->EventGroup, ptr->muxOn, ptr->overflow );
#endif
// add the events to the eventset
for ( i = 0; i < count; i++ ) {
index = ( native[i].ni_event & PAPI_NATIVE_AND_MASK ) + 1;
ptr->EventGroup_local[i] = index;
// we found an opcode event
if ( index > BGQ_PUNIT_MAX_COUNTERS ) {
for( j = 0; j < num_opcode_events; j++ ) {
#ifdef DEBUG_BGQ
printf(_AT_ " _bgq_update_control_state: %d out of %d OPCODES\n",
j, num_opcode_events );
#endif
#ifdef DEBUG_BGQ
printf(_AT_ " _bgq_update_control_state: j's idx = %d, index = %d\n",
GenericEvent[j].idx, index );
#endif
if ( GenericEvent[j].idx == ( index - 1) ) {
/* Add events to the BGPM eventGroup */
retval = Bgpm_AddEvent( ptr->EventGroup, GenericEvent[j].eventId );
CHECK_BGPM_ERROR( retval, "Bgpm_AddEvent" );
#ifdef DEBUG_BGQ
printf(_AT_ " _bgq_update_control_state: ADD event: i = %d, eventId = %d\n", i, GenericEvent[j].eventId );
#endif
evtIdx = Bgpm_GetEventIndex( ptr->EventGroup,
GenericEvent[j].eventId,
i );
#ifdef DEBUG_BGQ
printf(_AT_ " _bgq_update_control_state: evtIdx in EventGroup = %d\n",
evtIdx );
#endif
if ( 0 == strcmp( GenericEvent[j].mask, "PEVT_INST_XU_GRP_MASK" ) ) {
retval = Bgpm_SetXuGrpMask( ptr->EventGroup,
evtIdx,
GenericEvent[j].opcode_mask );
CHECK_BGPM_ERROR( retval, "Bgpm_SetXuGrpMask" );
#ifdef DEBUG_BGQ
printf(_AT_ " _bgq_update_control_state: it's PEVT_INST_XU_GRP_MASK\n" );
#endif
} else if ( 0 == strcmp( GenericEvent[j].mask, "PEVT_INST_QFPU_GRP_MASK" ) ) {
retval = Bgpm_SetQfpuGrpMask( ptr->EventGroup,
evtIdx,
GenericEvent[j].opcode_mask );
CHECK_BGPM_ERROR( retval, "Bgpm_SetQfpuGrpMask" );
#ifdef DEBUG_BGQ
printf(_AT_ " _bgq_update_control_state: it's PEVT_INST_QFPU_GRP_MASK\n" );
#endif
}
}
}
}
else {
#ifdef DEBUG_BGQ
printf(_AT_ " _bgq_update_control_state: no OPCODE\n" );
#endif
/* Add events to the BGPM eventGroup */
retval = Bgpm_AddEvent( ptr->EventGroup, index );
CHECK_BGPM_ERROR( retval, "Bgpm_AddEvent" );
#ifdef DEBUG_BGQ
printf(_AT_ " _bgq_update_control_state: ADD event: i = %d, index = %d\n", i, index );
#endif
}
}
// store how many events we added to an EventSet
ptr->count = count;
// if muxOn and EventGroup is not empty -- which is required by BGPM before
// we can call SetMultiplex() -- then drain the events from the
// BGPM EventGroup, turn on multiplex flag, and rebuild BGPM EventGroup.
if ( 1 == ptr->muxOn ) {
retval = _bgq_multiplex( ptr );
}
// since update_control_state trashes overflow settings, this puts things
// back into balance for BGPM
if ( 1 == ptr->overflow ) {
_common_set_overflow_BGPM( ptr->EventGroup,
ptr->overflow_EventIndex,
ptr->overflow_threshold,
user_signal_handler );
}
return ( PAPI_OK );
}

| int _bgq_write | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | cntrl, | ||
| long_long * | from | ||
| ) |
Definition at line 625 of file linux-bgq.c.
| void _papi_hwd_lock | ( | int | lock | ) |
Definition at line 93 of file linux-bgq.c.
| void _papi_hwd_unlock | ( | int | lock | ) |
| int _papi_hwi_init_os | ( | void | ) |
Definition at line 1246 of file linux-bgq.c.
{
struct utsname uname_buffer;
/* Get the kernel info */
uname(&uname_buffer);
strncpy(_papi_os_info.name,uname_buffer.sysname,PAPI_MAX_STR_LEN);
strncpy(_papi_os_info.version,uname_buffer.release,PAPI_MAX_STR_LEN);
_papi_os_info.itimer_sig = PAPI_INT_MPX_SIGNAL;
_papi_os_info.itimer_num = PAPI_INT_ITIMER;
_papi_os_info.itimer_res_ns = 1;
return PAPI_OK;
}
| void user_signal_handler | ( | int | hEvtSet, |
| uint64_t | address, | ||
| uint64_t | ovfVector, | ||
| const ucontext_t * | pContext | ||
| ) |
Definition at line 666 of file linux-bgq.c.
{
#ifdef DEBUG_BGQ
printf( "user_signal_handler start\n" );
#endif
( void ) address;
int retval;
unsigned i;
int isHardware = 1;
int cidx = _bgq_vectors.cmp_info.CmpIdx;
long_long overflow_bit = 0;
caddr_t address1;
_papi_hwi_context_t ctx;
ctx.ucontext = ( hwd_ucontext_t * ) pContext;
ThreadInfo_t *thread = _papi_hwi_lookup_thread( 0 );
//printf(_AT_ " thread = %p\n", thread); // <<<<<<<<<<<<<<<<<<
EventSetInfo_t *ESI;
ESI = thread->running_eventset[cidx];
// Get the indices of all events which have overflowed.
unsigned ovfIdxs[BGPM_MAX_OVERFLOW_EVENTS];
unsigned len = BGPM_MAX_OVERFLOW_EVENTS;
retval = Bgpm_GetOverflowEventIndices( hEvtSet, ovfVector, ovfIdxs, &len );
if ( retval < 0 ) {
#ifdef DEBUG_BGPM
printf ( "Error: ret value is %d for BGPM API function Bgpm_GetOverflowEventIndices.\n",
retval );
#endif
return;
}
if ( thread == NULL ) {
PAPIERROR( "thread == NULL in user_signal_handler!" );
return;
}
if ( ESI == NULL ) {
PAPIERROR( "ESI == NULL in user_signal_handler!");
return;
}
if ( ESI->overflow.flags == 0 ) {
PAPIERROR( "ESI->overflow.flags == 0 in user_signal_handler!");
return;
}
for ( i = 0; i < len; i++ ) {
uint64_t hProf;
Bgpm_GetEventUser1( hEvtSet, ovfIdxs[i], &hProf );
if ( hProf ) {
overflow_bit ^= 1 << ovfIdxs[i];
break;
}
}
if ( ESI->overflow.flags & PAPI_OVERFLOW_FORCE_SW ) {
#ifdef DEBUG_BGQ
printf("OVERFLOW_SOFTWARE\n");
#endif
address1 = GET_OVERFLOW_ADDRESS( ctx );
_papi_hwi_dispatch_overflow_signal( ( void * ) &ctx, address1, NULL, 0, 0, &thread, cidx );
return;
}
else if ( ESI->overflow.flags & PAPI_OVERFLOW_HARDWARE ) {
#ifdef DEBUG_BGQ
printf("OVERFLOW_HARDWARE\n");
#endif
address1 = GET_OVERFLOW_ADDRESS( ctx );
_papi_hwi_dispatch_overflow_signal( ( void * ) &ctx, address1, &isHardware, overflow_bit, 0, &thread, cidx );
}
else {
#ifdef DEBUG_BGQ
printf("OVERFLOW_NONE\n");
#endif
PAPIERROR( "ESI->overflow.flags is set to something other than PAPI_OVERFLOW_HARDWARE or PAPI_OVERFLOW_FORCE_SW (%x)", thread->running_eventset[cidx]->overflow.flags);
}
}


Definition at line 60 of file linux-bgq.c.
Definition at line 61 of file linux-bgq.c.
{
.get_memory_info = _bgq_get_memory_info,
.get_dmem_info = _bgq_get_dmem_info,
.get_real_cycles = _bgq_get_real_cycles,
.get_real_usec = _bgq_get_real_usec,
.get_virt_cycles = _bgq_get_virt_cycles,
.get_virt_usec = _bgq_get_virt_usec,
.get_system_info = _bgq_get_system_info
}
Definition at line 1327 of file linux-bgq.c.
int allocated_opcode_events = 0 [static] |
Definition at line 64 of file linux-bgq.c.
struct bgq_generic_events_t* GenericEvent [static] |
Definition at line 75 of file linux-bgq.c.
int num_opcode_events = 0 [static] |
Definition at line 65 of file linux-bgq.c.
| UPC_Lock_t thdLocks[PAPI_MAX_LOCK] |
Definition at line 52 of file linux-bgq.c.