diff --git a/src/papi.c b/src/papi.c index 92c84bd..9903645 100644 --- a/src/papi.c +++ b/src/papi.c @@ -607,19 +607,19 @@ PAPI_library_init( int version ) papi_return( init_retval ); } - /* Initialize thread globals, including the main threads */ + /* Initialize component globals */ - tmp = _papi_hwi_init_global_threads( ); + tmp = _papi_hwi_init_global( ); if ( tmp ) { init_retval = tmp; _papi_hwi_shutdown_global_internal( ); - _in_papi_library_init_cnt--; + _in_papi_library_init_cnt--; papi_return( init_retval ); } - /* Initialize component globals */ + /* Initialize thread globals, including the main threads */ - tmp = _papi_hwi_init_global( ); + tmp = _papi_hwi_init_global_threads( ); if ( tmp ) { init_retval = tmp; _papi_hwi_shutdown_global_internal( ); diff --git a/src/papi_internal.c b/src/papi_internal.c index 3828aed..fa9f067 100644 --- a/src/papi_internal.c +++ b/src/papi_internal.c @@ -112,27 +112,32 @@ _papi_hwi_free_papi_event_string() { return; } +// A place to keep the current papi event code so some component functions can fetch its value +// The current event code can be stored here prior to component calls and cleared after the component returns +static THREAD_LOCAL_STORAGE_KEYWORD unsigned int papi_event_code = -1; +static THREAD_LOCAL_STORAGE_KEYWORD int papi_event_code_changed = -1; + void _papi_hwi_set_papi_event_code (unsigned int event_code, int update_flag) { INTDBG("new event_code: %#x, update_flag: %d, previous event_code: %#x\n", event_code, update_flag, papi_event_code); // if call is just to reset and start over, set both flags to show nothing saved yet if (update_flag < 0) { - _papi_hwi_my_thread->tls_papi_event_code_changed = -1; - _papi_hwi_my_thread->tls_papi_event_code = -1; + papi_event_code_changed = -1; + papi_event_code = -1; return; } // if 0, it is being set prior to calling a component, if >0 it is being changed by the component - _papi_hwi_my_thread->tls_papi_event_code_changed = update_flag; + papi_event_code_changed = update_flag; // save the event code passed in - _papi_hwi_my_thread->tls_papi_event_code = event_code; + papi_event_code = event_code; return; } unsigned int _papi_hwi_get_papi_event_code () { INTDBG("papi_event_code: %#x\n", papi_event_code); - return _papi_hwi_my_thread->tls_papi_event_code; + return papi_event_code; } /* Get the index into the ESI->NativeInfoArray for the current PAPI event code */ int @@ -552,7 +557,7 @@ _papi_hwi_native_to_eventcode(int cidx, int event_code, int ntv_idx, const char int result; - if (_papi_hwi_my_thread->tls_papi_event_code_changed > 0) { + if (papi_event_code_changed > 0) { result = _papi_hwi_get_papi_event_code(); INTDBG("EXIT: papi_event_code: %#x set by the component\n", result); return result;