PAPI_detach(3)

okay so welcome to the PAPI manual’s PAPI_detach(3) page, bestie πŸ’– this one is short but iconic, and we are keeping every single detail, no cap.

πŸ’… NAME πŸ’…

PAPI_detach β€” detach a PAPI event set from a previously specified thread id and restore it to the executing thread. literally that’s the whole vibe ✨


🌸 SYNOPSIS 🌸

the C interface is sitting right below in the Detailed Description section, bestie πŸ‘‡

✨ Detailed Description ✨

πŸ’» C Interface: πŸ’»

#include <papi.h>
int PAPI_detach( int  EventSet, unsigned long  tid );

okay so PAPI_detach is a wrapper function that calls PAPI_set_opt to allow PAPI to monitor performance counts on a thread other than the one currently executing πŸ‘€ this is sometimes referred to as third party monitoring. PAPI_attach connects the specified EventSet to the specified thread; PAPI_detach breaks that connection and restores the EventSet to the original executing thread. periodt πŸ’…

πŸŽ€ Parameters πŸŽ€

  • EventSet β€” an integer handle for a PAPI EventSet as created by PAPI_create_eventset 🫢
  • tid β€” a thread id as obtained from, for example, PAPI_list_threads or PAPI_thread_id 🌸

πŸ’€ Return values πŸ’€

  • PAPI_ECMP β€” this feature is unsupported on this component 😭
  • 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: πŸ“

here’s the example, copied exactly because we do not mess with code, ever 🧚

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 );

πŸ¦‹ See also πŸ¦‹

  • PAPI_set_opt
  • PAPI_list_threads
  • PAPI_thread_id
  • PAPI_thread_init

πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for PAPI from the source code.


and that’s the vibe check, bestie πŸ’– this page is Version 7.2.0.0, dated Wed Jun 25 2025 19:30:48, and it’s the PAPI_detach(3) page. slay, bye 🫢✨