NVTX  v3
NVIDIA Tools Extension Library
Synchronization

This section covers a subset of the API that allow users to track additional synchronization details of their application. Naming OS synchronization primitives may allow users to better understand the data collected by traced synchronization APIs. Additionally, a user defined synchronization object can allow the users to to tell the tools when the user is building their own synchronization system that do not rely on the OS to provide behaviors and instead use techniques like atomic operations and spinlocks.

See module Synchronization for details.

Example:
class MyMutex
{
volatile long bLocked;
public:
MyMutex(const char* name, nvtxDomainHandle_t d){
bLocked = 0;
nvtxSyncUserAttributes_t attribs = { 0 };
attribs.version = NVTX_VERSION;
attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
attribs.message.ascii = name;
hSync = nvtxDomainSyncUserCreate(d, &attribs);
}
~MyMutex() {
}
bool Lock() {
bool acquired = __sync_bool_compare_and_swap(&bLocked, 0, 1);//atomic compiler intrinsic
if (acquired) {
}
else {
}
return acquired;
}
void Unlock() {
bLocked = false;
}
};
Version