In nvprof I can see the stream IDs for each cuda execution stream I am using (0, 13, 15, etc.)
Given a stream variable, I'd like to be able to print out the stream ID. Currently I cannot find any API to do this and casting the cudaStream_t
to an int or uint does not yield a reasonable ID. sizeof()
says cudaStream_t
is 8 bytes.
Briefly: I don't know of a method to access these IDs directly, but you can give streams explicit names for profiling purposes.
cudaStream_t
is an opaque "resource handle" type. A resource handle is something like a pointer; so it stands to reason that the stream ID is not contained in the pointer (handle) itself, but somehow in what it refers to.Since it is opaque (no definition of what it points to, provided by CUDA) and as you point out there is no direct API for this, I don't think you'll find a method to extract the stream ID from a
cudaStream_t
at runtime.For these assertions that
cudaStream_t
is a resource handle and that it is opaque, refer to the CUDA header filedriver_types.h
However, the NV Tools Extension API gives you the capability to "name" a particular stream (or other resources). This would allow you to associate a particular stream in source code with a particular name in the profiler.
Here's a trivial worked example: