PAPI_set_thr_specific(3)
πΈ NAME πΈ
Okay bestie, this is PAPI_set_thr_specific(3) from PAPI β the manual page for storing a pointer to a thread specific data structure. Not me being obsessed with per-thread data, but it's highkey iconic. It's giving "tiny but crucial," and if you're doing thread stuff, iykyk. π
π SYNOPSIS π
π Detailed Description π
Here's the whole vibe: prototype, parameters, return values, and the example. No cap, it's all here. β¨
π§ Prototype π§
#include <papi.h>
int PAPI_set_thr_specific( int tag, void *ptr );
π Parameters π
tagβ An identifier, the value of which is eitherPAPI_USR1_TLSorPAPI_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.
π₯ Return values π₯
PAPI_OKPAPI_EINVALβ Thetagargument is out of range. π¨
In C, PAPI_set_thr_specific will save ptr into an array indexed by 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 is no Fortran equivalent function. π« fr fr.
π Example π
This example is literally right here, bestie β keep it exact. It ate. π
int ret;
RateInfo *state = NULL;
ret = PAPI_thread_init(pthread_self);
if (ret != PAPI_OK) handle_error(ret);
// Do we have the thread specific data setup yet?
ret = PAPI_get_thr_specific(PAPI_USR1_TLS, (void *) &state);
if (ret != PAPI_OK || state == NULL) {
state = (RateInfo *) malloc(sizeof(RateInfo));
if (state == NULL) return (PAPI_ESYS);
memset(state, 0, sizeof(RateInfo));
state->EventSet = PAPI_NULL;
ret = PAPI_create_eventset(&state->EventSet);
if (ret != PAPI_OK) return (PAPI_ESYS);
ret = PAPI_set_thr_specific(PAPI_USR1_TLS, state);
if (ret != PAPI_OK) return (ret);
}
π See also π
These are the related besties β go check them out:
PAPI_register_threadPAPI_thread_initPAPI_thread_idPAPI_get_thr_specific
π¦ Author π¦
Generated automatically by Doxygen for PAPI from the source code. No thoughts, just docs energy. π
That's the whole page, bestie! π This PAPI_set_thr_specific(3) page is from PAPI, version 7.2.0.0, dated Wed Jun 25 2025 19:30:49. Now go be a thread-specific main character. π
π¦ where this page comes from
- nixos 26.05: papi 7.2.0
- nixpkgs unstable: papi 7.2.0
- opensuse-leap 16.0: papi-devel 7.2.0-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: papi-devel 7.2.0-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: papi-devel 7.2.0-160000.2.2 Β· BSD-3-Clause
- ubuntu resolute: libpapi-dev 7.2.0-2 Β· BSD-3-Clause
- ubuntu stonking: libpapi-dev 7.2.0-2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms