|
PAPI
5.0.1.0
|
00001 00008 #ifndef PAPI_CPUS_H 00009 #define PAPI_CPUS_H 00010 00011 #include <stdlib.h> 00012 #include <stdio.h> 00013 #include <unistd.h> 00014 00015 typedef struct _CpuInfo 00016 { 00017 unsigned int cpu_num; 00018 struct _CpuInfo *next; 00019 hwd_context_t **context; 00020 EventSetInfo_t **running_eventset; 00021 EventSetInfo_t *from_esi; /* ESI used for last update this control state */ 00022 } CpuInfo_t; 00023 00024 /* The list of cpus, gets built as user apps set the cpu papi option on an event set */ 00025 extern volatile CpuInfo_t *_papi_hwi_cpu_head; 00026 00027 int _papi_hwi_initialize_cpu( CpuInfo_t ** dest, unsigned int cpu_num ); 00028 int _papi_hwi_shutdown_cpu( CpuInfo_t * cpu ); 00029 00030 inline_static CpuInfo_t * 00031 _papi_hwi_lookup_cpu( unsigned int cpu_num ) 00032 { 00033 THRDBG("Entry:\n"); 00034 CpuInfo_t *tmp; 00035 00036 _papi_hwi_lock( CPUS_LOCK ); 00037 00038 tmp = ( CpuInfo_t * ) _papi_hwi_cpu_head; 00039 while ( tmp != NULL ) { 00040 THRDBG( "Examining cpu 0x%x at %p\n", tmp->cpu_num, tmp ); 00041 if ( tmp->cpu_num == cpu_num ) 00042 break; 00043 tmp = tmp->next; 00044 if ( tmp == _papi_hwi_cpu_head ) { 00045 tmp = NULL; 00046 break; 00047 } 00048 } 00049 00050 if ( tmp ) { 00051 _papi_hwi_cpu_head = tmp; 00052 THRDBG( "Found cpu 0x%x at %p\n", cpu_num, tmp ); 00053 } else { 00054 THRDBG( "Did not find cpu 0x%x\n", cpu_num ); 00055 } 00056 00057 _papi_hwi_unlock( CPUS_LOCK ); 00058 return ( tmp ); 00059 } 00060 00061 inline_static int 00062 _papi_hwi_lookup_or_create_cpu( CpuInfo_t ** here, unsigned int cpu_num ) 00063 { 00064 THRDBG("Entry: here: %p\n", here); 00065 CpuInfo_t *tmp = NULL; 00066 int retval = PAPI_OK; 00067 00068 tmp = _papi_hwi_lookup_cpu(cpu_num); 00069 if ( tmp == NULL ) 00070 retval = _papi_hwi_initialize_cpu( &tmp, cpu_num ); 00071 00072 if ( retval == PAPI_OK ) 00073 *here = tmp; 00074 00075 return ( retval ); 00076 } 00077 00078 #endif