papi_attach(3) - Linux man page
Name
PAPI_attach - attach PAPI event set to the specified thread id PAPI_detach - detach PAPI event set from previously specified thread id and restore to executing thread
Synopsis
C Interface#include <papi.h>int PAPI_attach(int EventSet, unsigned long tid);int PAPI_detach(int EventSet);Fortran Interface
<none>
Description
Arguments
EventSet -- an integer handle for a PAPI Event Set as created by papi_create_eventset(3)tid -- a thread id as obtained from, for example, papi_list_threads(3) or papi_thread_id(3).
Return Values
On success, these functions return PAPI_OK. On error, a negative error code is returned.Errors
- PAPI_ESBSTR
- This feature is unsupported on this substrate.
- PAPI_EINVAL
- One or more of the arguments is invalid.
- PAPI_ENOEVST
- The event set specified does not exist.
- PAPI_EISRUN
- The event set is currently counting events.
Examples
int EventSet = PAPI_NULL; unsigned long pid; pid = fork(); if (pid <= 0) exit(1); if (PAPI_create_eventset(&EventSet) != PAPI_OK) exit(1); /* Add Total Instructions Executed to our EventSet */ if (PAPI_add_event(EventSet, PAPI_TOT_INS) != PAPI_OK) exit(1); /* Attach this EventSet to the forked process */ if (PAPI_attach(EventSet, pid) != PAPI_OK) exit(1);