|
PAPI
5.0.1.0
|

Go to the source code of this file.
Functions | |
| static CpuInfo_t * | allocate_cpu (unsigned int cpu_num) |
| static void | free_cpu (CpuInfo_t **cpu) |
| static void | insert_cpu (CpuInfo_t *entry) |
| static int | remove_cpu (CpuInfo_t *entry) |
| int | _papi_hwi_initialize_cpu (CpuInfo_t **dest, unsigned int cpu_num) |
| int | _papi_hwi_shutdown_cpu (CpuInfo_t *cpu) |
Variables | |
| volatile CpuInfo_t * | _papi_hwi_cpu_head |
| int _papi_hwi_initialize_cpu | ( | CpuInfo_t ** | dest, |
| unsigned int | cpu_num | ||
| ) |
< Insufficient memory
< No error
Definition at line 185 of file cpus.c.
{
THRDBG("Entry: dest: %p, *dest: %p, cpu_num: %d\n", dest, *dest, cpu_num);
int retval;
CpuInfo_t *cpu;
int i;
if ( ( cpu = allocate_cpu(cpu_num) ) == NULL ) {
*dest = NULL;
return ( PAPI_ENOMEM );
}
/* Call the component to fill in anything special. */
for ( i = 0; i < papi_num_components; i++ ) {
retval = _papi_hwd[i]->init_thread( cpu->context[i] );
if ( retval ) {
free_cpu( &cpu );
*dest = NULL;
return ( retval );
}
}
insert_cpu( cpu );
*dest = cpu;
return ( PAPI_OK );
}


| int _papi_hwi_shutdown_cpu | ( | CpuInfo_t * | cpu | ) |
< No error
< No error
Definition at line 214 of file cpus.c.
{
THRDBG("Entry: cpu: %p, cpu_num: %d\n", cpu, cpu->cpu_num);
int retval = PAPI_OK;
int i, failure = 0;
remove_cpu( cpu );
THRDBG( "Shutting down cpu %d at %p\n", cpu->cpu_num, cpu );
for ( i = 0; i < papi_num_components; i++ ) {
retval = _papi_hwd[i]->shutdown_thread( cpu->context[i] );
if ( retval != PAPI_OK )
failure = retval;
}
free_cpu( &cpu );
return ( failure );
}


| static CpuInfo_t* allocate_cpu | ( | unsigned int | cpu_num | ) | [static] |
Definition at line 36 of file cpus.c.
{
THRDBG("Entry: cpu_num: %d\n", cpu_num);
CpuInfo_t *cpu;
int i;
cpu = ( CpuInfo_t * ) papi_malloc( sizeof ( CpuInfo_t ) );
if ( cpu == NULL )
return ( NULL );
memset( cpu, 0x00, sizeof ( CpuInfo_t ) );
/* identify the cpu this info structure represents */
cpu->cpu_num = cpu_num;
cpu->context = ( hwd_context_t ** ) papi_malloc( sizeof ( hwd_context_t * ) *
( size_t ) papi_num_components );
if ( !cpu->context ) {
papi_free( cpu );
return ( NULL );
}
cpu->running_eventset =
( EventSetInfo_t ** ) papi_malloc( sizeof ( EventSetInfo_t * ) *
( size_t ) papi_num_components );
if ( !cpu->running_eventset ) {
papi_free( cpu->context );
papi_free( cpu );
return ( NULL );
}
for ( i = 0; i < papi_num_components; i++ ) {
cpu->context[i] =
( void * ) papi_malloc( ( size_t ) _papi_hwd[i]->size.context );
cpu->running_eventset[i] = NULL;
if ( cpu->context[i] == NULL ) {
for ( i--; i >= 0; i-- )
papi_free( cpu->context[i] );
papi_free( cpu->context );
papi_free( cpu );
return ( NULL );
}
memset( cpu->context[i], 0x00,
( size_t ) _papi_hwd[i]->size.context );
}
THRDBG( "Allocated CpuInfo: %p\n", cpu );
return ( cpu );
}

Definition at line 86 of file cpus.c.
{
THRDBG( "Entry: *cpu: %p, cpu_num: 0x%x\n", *cpu, ( *cpu )->cpu_num);
int i;
for ( i = 0; i < papi_num_components; i++ ) {
if ( ( *cpu )->context[i] )
papi_free( ( *cpu )->context[i] );
}
if ( ( *cpu )->context )
papi_free( ( *cpu )->context );
if ( ( *cpu )->running_eventset )
papi_free( ( *cpu )->running_eventset );
memset( *cpu, 0x00, sizeof ( CpuInfo_t ) );
papi_free( *cpu );
*cpu = NULL;
}

| static void insert_cpu | ( | CpuInfo_t * | entry | ) | [static] |
< Used with setting up array
< Used with setting up array
Definition at line 107 of file cpus.c.
{
THRDBG("Entry: entry: %p\n", entry);
_papi_hwi_lock( CPUS_LOCK );
if ( _papi_hwi_cpu_head == NULL ) { /* 0 elements */
THRDBG( "_papi_hwi_cpu_head is NULL\n" );
entry->next = entry;
} else if ( _papi_hwi_cpu_head->next == _papi_hwi_cpu_head ) { /* 1 elements */
THRDBG( "_papi_hwi_cpu_head was cpu %d at %p\n",
_papi_hwi_cpu_head->cpu_num, _papi_hwi_cpu_head );
_papi_hwi_cpu_head->next = entry;
entry->next = ( CpuInfo_t * ) _papi_hwi_cpu_head;
} else { /* 2+ elements */
THRDBG( "_papi_hwi_cpu_head was cpu %d at %p\n",
_papi_hwi_cpu_head->cpu_num, _papi_hwi_cpu_head );
entry->next = _papi_hwi_cpu_head->next;
_papi_hwi_cpu_head->next = entry;
}
_papi_hwi_cpu_head = entry;
THRDBG( "_papi_hwi_cpu_head now cpu %d at %p\n",
_papi_hwi_cpu_head->cpu_num, _papi_hwi_cpu_head );
_papi_hwi_unlock( CPUS_LOCK );
}


| static int remove_cpu | ( | CpuInfo_t * | entry | ) | [static] |
< Used with setting up array
< Internal error, please send mail to the developers
< Used with setting up array
< No error
Definition at line 138 of file cpus.c.
{
THRDBG("Entry: entry: %p\n", entry);
CpuInfo_t *tmp = NULL, *prev = NULL;
_papi_hwi_lock( CPUS_LOCK );
THRDBG( "_papi_hwi_cpu_head was cpu %d at %p\n",
_papi_hwi_cpu_head->cpu_num, _papi_hwi_cpu_head );
/* Find the preceding element and the matched element,
short circuit if we've seen the head twice */
for ( tmp = ( CpuInfo_t * ) _papi_hwi_cpu_head;
( entry != tmp ) || ( prev == NULL ); tmp = tmp->next ) {
prev = tmp;
}
if ( tmp != entry ) {
THRDBG( "Cpu %d at %p was not found in the cpu list!\n",
entry->cpu_num, entry );
return ( PAPI_EBUG );
}
/* Only 1 element in list */
if ( prev == tmp ) {
_papi_hwi_cpu_head = NULL;
tmp->next = NULL;
THRDBG( "_papi_hwi_cpu_head now NULL\n" );
} else {
prev->next = tmp->next;
/* If we're removing the head, better advance it! */
if ( _papi_hwi_cpu_head == tmp ) {
_papi_hwi_cpu_head = tmp->next;
THRDBG( "_papi_hwi_cpu_head now cpu %d at %p\n",
_papi_hwi_cpu_head->cpu_num, _papi_hwi_cpu_head );
}
THRDBG( "Removed cpu %p from list\n", tmp );
}
_papi_hwi_unlock( CPUS_LOCK );
return ( PAPI_OK );
}


| volatile CpuInfo_t* _papi_hwi_cpu_head |