Meaning of various IDs in the exported JSON for Nsight Systems

There are some parts of the exported JSON from Nsight Systems that I can’t quite figure out.
Here is from a CudaEvent:
startNs: ‘3913448975’
endNs: ‘4015230442’
correlationId: 209
deviceId: 0
contextId: ‘1’
streamId: ‘7’
eventClass: 1
globalPid: ‘281919807815680’
memcpy: [1×1 struct]

I assume deviceId is the GPU. It’s easy enough to reverse engineer the memcpy and others like kernel and whatnot({“sizebytes”:“800000000”,“copyKind”:“1”,“srcKind”:0,“dstKind”:2}}})

However, I am curious what the correlationId, streamId, and eventClass values pertain to though, however. Most notably, I’d like to know what the eventClass values map to, as they appear in the TraceProcessEvents too.

A quick rundown on these values, some which you have figured out:

  • startNs: timestamp of event start time, in nanoseconds, since process start
  • endNs: timestamp of event end time, in nanoseconds, since process start
  • correlationId: used to correlate CPU events to GPU events; most often used to correlate a CUDA API event on the CPU to queue a kernel to the kernel execution event on the GPU.
  • deviceId: The CUDA hardware device index.
  • contextId: The CUDA context associated with this event
  • streamId: The CUDA stream associated with this event
  • eventClass: Sub-type of event; in this case, a “memcpy” event; In the same way that Type=80 defines a CudaEvent, the eventClass=1 (under a CudaEvent) defines a memcpy; eventClass mappings are specific to their enclosing Type values; CudaEvent eventClass IDs are: 1=memcpy, 2=memset, 3=kernel, 5=synchronization; eventClass values for the TraceProcessEvents will be different
  • globalPid: GlobalPid or GlobalTid are bitfields that describe the execution environment of the event; they have the format (in hex) 0xHHVVPPPPPPTTTTTT where H (8 bits) has the Hardware ID of the CUDA device, V (8 bits) is the virtual machine ID (or ID of any sub-system that splits a physical GPU into sub-components), P (24 bits) is the PID, and T (24 bits) is the ThreadID

In the bigger picture, please understand that the JSON format is rather tightly tied to our internal data structures and message formats. The data is somewhat low-level and raw and, unfortunately, not well documented. The SQLite exports are a little more abstract, in that the data is processed and presented a bit differently, to make it more stable and more approachable. The documentation on the SQLite format is also much better (see the documentation/nsys-exporters dir of your Nsight Systems install; I don’t believe those docs are online). Even if your project requires JSON, the SQLite documentation will often give hints as to the meaning of a field or value, so it is likely worth a look either way.