Thread safety of Cupti activity api callbacks

Hi. I do not seem to find any information regarding thread safety of cupti activity callback functions, and thus was curious what their behavior is.
Can two or more CUPTI threads invoke cupti activity callbacks concurrently? Can there be two invocations of void ( *CUpti_BuffersCallbackRequestFunc )( uint8_t* *buffer, size_t* size, size_t* maxNumRecords ) by CUPTI at the same time? Also curious what is the behavior for the CompleteFunc?

Thank you

Hi,
The CUPTI activity callback functions are thread safe.
Only one CUPTI thread will invoke CUPTI activity callbacks. The buffer completed callback i.e. CUpti_BuffersCallbackCompleteFunc is invoked by the CUPTI worker thread.
The buffer requested callback CUpti_BuffersCallbackRequestFunc is issued by the application thread.
Activity buffers are global i.e. all threads use the same activity buffer. A buffer requested by a thread can be used by other threads.
CUPTI ensures that two or more threads cannot request the buffer simultaneously.

1 Like