Reputation: 11416
Suppose I have a pointer to a __global__
function in CUDA. Is there a way to programmatically ask CUDART for a string containing its name?
Upvotes: 3
Views: 147
Reputation: 72339
I don't believe this is possible by any public API.
I have previously tried poking around in the driver itself, but that doesn't look too promising. The compiler emitted code for <<< >>>
kernel invocation clearly registers the mangled function name with the runtime via __cudaRegisterFunction
, but I couldn't see any obvious way to perform a lookup by name/value in the runtime library. The driver API equivalent cuModuleGetFunction
leads to an equally opaque type from which it doesn't seem possible to extract the function name.
Edited to add:
The host compiler itself doesn't support reflection, so there are no obvious fancy language tricks that could be pulled at runtime. One possibility would be to add another preprocessor pass to the compilation trajectory to build a static kernel function lookup table before the final build. That would be rather a lot of work, but it could be done, at least for "classic" compilation where everything winds up in a single translation unit.
Upvotes: 1