|
  PAPIC:PAPI get thr specific.3
| |
ViewsFrom PAPIDocs
(Redirected from PAPIC:PAPI set thr specific.3)
NAME
Synopsis'''C Interface''' #include <papi.h> int PAPI_get_thr_specific(int tag, void **ptr); int PAPI_set_thr_specific(int tag, void *ptr); DescriptionIn C, PAPI_set_thr_specific will save ptr into an array indexed by tag. PAPI_get_thr_specific will retrieve the pointer from the array with index tag. There are 2 user available locations and tag can be either PAPI_USR1_TLS or PAPI_USR2_TLS. The array mentioned above is managed by PAPI and allocated to each thread which has called PAPI_thread_init. There are no Fortran equivalent functions. Argumentstag -- An identifier, the value of which is either PAPI_USR1_TLS or PAPI_USR2_TLS. This identifier indicates which of several data structures associated with this thread is to be accessed. ptr -- A pointer to the memory containing the data structure. ErrorsPAPI_EINVAL The tag argument is out of range. BugsThere are no known bugs in these functions. EXAMPLEHighLevelInfo *state = NULL; if (retval = PAPI_thread_init(pthread_self) != PAPI_OK) handle_error(retval); /* * Do we have the thread specific data setup yet? */ if ((retval = PAPI_get_thr_specific(PAPI_USR1_TLS, (void *) &state)) != PAPI_OK || state == NULL) { state = (HighLevelInfo *) malloc(sizeof(HighLevelInfo)); if (state == NULL) return (PAPI_ESYS); memset(state, 0, sizeof(HighLevelInfo)); state->EventSet = PAPI_NULL; if ((retval = PAPI_create_eventset(&state->EventSet)) != PAPI_OK) return (PAPI_ESYS); if ((retval=PAPI_set_thr_specific(PAPI_USR1_TLS, state))!=PAPI_OK) return (retval); } See AlsoPAPI_register_thread(3), PAPI_thread_init(3), PAPI_thread_id(3) |