[NVTX]how to use nvtxDomainResourceCreate and nvtxDomainResourceDestroy

how to use nvtxDomainResourceCreate and nvtxDomainResourceDestroy, i write a simple demo below and profile it with nsys, open the report with nsys-ui, in which i can’t find the resource defined

include <stdio.h>
include <unistd.h>
include <sys/syscall.h>
include <pthread.h>
include <nvtx3/nvToolsExt.h>
include <nvtx3/nvToolsExtSync.h>

int main(void) {
nvtxDomainHandle_t d = nvtxDomainCreateA(“probe-domain”);
printf(“domain=%p\n”, (void*)d);

/* dedicated thread naming */
nvtxNameOsThreadA((uint32_t)syscall(SYS_gettid), "MainThread-via-NvtxNameOsThread");

/* resource create: native thread */
nvtxResourceAttributes_t ra = {0};
ra.version=NVTX_VERSION; ra.size=NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
ra.identifierType=NVTX_RESOURCE_TYPE_GENERIC_THREAD_NATIVE;
ra.identifier.ullValue=(uint64_t)syscall(SYS_gettid);
ra.messageType=NVTX_MESSAGE_TYPE_ASCII; ra.message.ascii="MainThread-via-ResourceCreate";
nvtxResourceHandle_t r = nvtxDomainResourceCreate(d, &ra);
printf("resource(GENERIC_THREAD_NATIVE)=%p\n", (void*)r);

/* resource create: sync pthread mutex */
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
ra.identifierType=NVTX_RESOURCE_TYPE_SYNC_PTHREAD_MUTEX;
ra.identifier.pValue=&m; ra.message.ascii="NamedMutex";
nvtxResourceHandle_t r2 = nvtxDomainResourceCreate(d, &ra);
printf("resource(SYNC_PTHREAD_MUTEX)=%p\n", (void*)r2);

/* sync user */
nvtxSyncUserAttributes_t sa={0}; sa.version=NVTX_VERSION; sa.size=NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
sa.messageType=NVTX_MESSAGE_TYPE_ASCII; sa.message.ascii="MySpinLock";
nvtxSyncUser_t s = nvtxDomainSyncUserCreate(d, &sa);
printf("syncUser=%p\n", (void*)s);

return 0;

}

Your resource attributes look reasonable, but resource annotations do not guarantee standalone timeline objects.

Can I get your nsys --version and collection command to check support in your release?

Looping in @rdietrich

Nsight Systems doesn’t currently support nvtxDomainResourceCreate, nvtxDomainResourceDestroy, or nvtxDomainSyncUserCreate, so these annotations aren’t collected.

nvtxNameOsThreadA is supported, and your demo calls it correctly, so the thread name should be visible in the GUI.

As a workaround to visualize mutex activity, you could use NVTX ranges (nvtxDomainRangePushEx/nvtxDomainRangePop): for example, one range around the pthread_mutex_lock call to show waiting time, and one around the protected work to show holding time. A dedicated domain or category keeps these separate from your other NVTX annotations. This won’t give you the resource or sync-object semantics, but it makes lock contention visible on the timeline.

ok, thanks very much