How to properly use the generic resource object introduced in NVTX 2?

Consider the following code snippet that attempts to rename a given device. The “old way” works, while the “new way” does not: The new device name is not reflected in Nsight System. Did I miss anything in setting up the resource attribute?

nvtxResourceHandle_t RenameGpu(int deviceIdx, const std::string& name) {
    nvtxResourceHandle_t handle{};

    // Old way (only applicable to the default domain)
    // nvtxNameCudaDevice(deviceIdx, name.c_str());

    // New way
    nvtxResourceAttributes_t resourceAttrib;
    std::memset(&resourceAttrib, 0, NVTX_RESOURCE_ATTRIB_STRUCT_SIZE);
    resourceAttrib.version = NVTX_VERSION;
    resourceAttrib.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
    resourceAttrib.identifierType = nvtxResourceCUDARTType_t::NVTX_RESOURCE_TYPE_CUDART_DEVICE;
    resourceAttrib.identifier.ullValue = deviceIdx;
    resourceAttrib.messageType = nvtxMessageType_t::NVTX_MESSAGE_TYPE_ASCII;
    resourceAttrib.message.ascii = name.c_str();
    handle = nvtxDomainResourceCreate(GetMyCustomDomain(), &resourceAttrib);

    return handle;

@jasoncohen can you please respond to this.

1 Like

Hi @King_Crimson,

Nsight Systems doesn’t currently support that particular function. Since we don’t have rows for tracking arbitrary resources yet, it would be a fairly big change to support all uses of this function. We should at least fix it to support the subset of use cases that overlaps with the older v1 functions, since that already works. And then we should issue a warning in the report if you used the function in a way the tool doesn’t provide any visualization for. I filed a case to do this, but not sure how soon we’ll get to it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.