NAME

PAPI_get_thr_specific, PAPI_set_thr_specific - Store or retrieve a pointer to a thread specific data structure

CONTENTS

Synopsis
Description
Arguments
Return Values
Errors
Example
Authors
Bugs
See Also

SYNOPSIS


#include <papi.h> 

int PAPI_get_thr_specific(int tag, void **ptr); 

int PAPI_set_thr_specific(int tag, void *ptr); 

DESCRIPTION

In 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. 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.

ARGUMENTS

tag -- An identifier, the value of which is between 0 and PAPI_MAX_THREAD_STORAGE (currently 4). 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

On success, this function returns PAPI_OK.
On error, a negative error value is returned.

ERRORS

PAPI_EINVAL
  The tag argument is out of range.

EXAMPLE


   unsigned long int tid;
   HighLevelInfo *state = NULL;

if (retval = PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT) handle_error(retval);

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(1, (void *) &state)) != PAPI_OK || state == NULL) { state = (HighLevelInfo *) malloc(sizeof(HighLevelInfo)); if (state == NULL) return (PAPI_ESYS);

memset(state, 0, sizeof(HighLevelInfo)); state->EventSet = -1;

if ((retval = PAPI_create_eventset(&state->EventSet)) != PAPI_OK) return (PAPI_ESYS);

if ((retval = PAPI_set_thr_specific(1, state)) != PAPI_OK) return (retval); }

AUTHORS

The PAPI Team. See them at the PAPI Web Site: http://icl.cs.utk.edu/projects/papi

BUGS

There are no known bugs in these functions.

SEE ALSO

PAPI_thread_init (3), PAPI_thread_id (3), PAPI_register_thread (3)


PAPI Programmer’s Reference PAPI_get_thr_specific (3) November, 2003

  Innovative Computing Laboratory
2001 R&D Winner  
Contact PAPI: papi@cs.utk.edu Computer Science Department
  University of Tennessee