1PAPI_get_thr_specific(3)             PAPI             PAPI_get_thr_specific(3)
2
3
4

NAME

6       PAPI_get_thr_specific,  PAPI_set_thr_specific  -  Store  or  retrieve a
7       pointer to a thread specific data structure
8
9

SYNOPSIS

11       #include <papi.h>
12       int PAPI_get_thr_specific(int tag, void **ptr);
13       int PAPI_set_thr_specific(int tag, void *ptr);
14
15

DESCRIPTION

17       In C, PAPI_set_thr_specific will save ptr into an array indexed by tag.
18       PAPI_get_thr_specific  will  retrieve  the  pointer from the array with
19       index tag.  There are 2 user available locations and tag can be  either
20       PAPI_USR1_TLS  or  PAPI_USR2_TLS.  The array mentioned above is managed
21       by PAPI and allocated to each thread which has called PAPI_thread_init.
22       There are no Fortran equivalent functions.
23
24

ARGUMENTS

26       tag  --   An  identifier, the value of which is either PAPI_USR1_TLS or
27       PAPI_USR2_TLS. This identifier indicates which of several  data  strucā€
28       tures associated with this thread is to be accessed.
29
30       ptr --  A pointer to the memory containing the data structure.
31
32

RETURN VALUES

34       On success, this function returns PAPI_OK.
35        On error, a negative error value is returned.
36
37

ERRORS

39       PAPI_EINVAL
40              The tag argument is out of range.
41
42

EXAMPLE

44          HighLevelInfo *state = NULL;
45
46          if (retval = PAPI_thread_init(pthread_self) != PAPI_OK)
47             handle_error(retval);
48
49          /*
50           * Do we have the thread specific data setup yet?
51           */
52          if ((retval = PAPI_get_thr_specific(PAPI_USR1_TLS, (void *) &state))
53              != PAPI_OK || state == NULL) {
54             state = (HighLevelInfo *) malloc(sizeof(HighLevelInfo));
55             if (state == NULL)
56                return (PAPI_ESYS);
57
58             memset(state, 0, sizeof(HighLevelInfo));
59             state->EventSet = PAPI_NULL;
60
61             if ((retval = PAPI_create_eventset(&state->EventSet)) != PAPI_OK)
62                return (PAPI_ESYS);
63
64             if ((retval=PAPI_set_thr_specific(PAPI_USR1_TLS, state))!=PAPI_OK)
65                return (retval);
66          }
67
68
69

BUGS

71       There are no known bugs in these functions.
72
73

SEE ALSO

75       PAPI_thread_init(3), .BR PAPI_thread_id (3), PAPI_register_thread(3)
76
77
78
79PAPI Programmer's Reference     September, 2004       PAPI_get_thr_specific(3)
Impressum