How to get a kernel function's name through it's pointer?

I’m programming to implement submitting a kernel function on a remote GPU device. I have know that “cuModuleGetFunction” could get the pointer of a function through it’s name. But I still need to get the name of a function through it’s pointer.
How could I do this?

I don’t think there is an API to retrieve the kernel’s function name via it’s pointer. (which is kinda weird… cause you did supply it).

So either store the function name.

Or request a new API to be added ;)

Let me ask you a question though:

Why do you need/want to retrieve the function name via a kernel function pointer ?

Also why are you not storing it ? Sounds like a storage/design problem to me… but that’s ok… it’s kinda weird anyway that there is no way to retrieve… but you did supply it to the cu function, so cuda also didn’t store it ;) remaining question to nvidia would be: Why is it not stored ? ;) What problems would it cause and so forth :)

Although this not officially supported and might break in future releases, you can get a kernel name like this:

CUfunction func;
// [...]
const char* funcName = *(const char**)((uintptr_t)func + 8);

May I suggest using uintptr_t instead of size_t? Use of size_t in this context is so C89 :-)

That makes sense, I’ve edited my answer, thanks for the suggestion!

If i use cuda_runtime_api, can i get the name of the func in cudaLaunchKernel

cudaLaunchKernel (const void *func, dim3 gridDim, dim3 blockDim, void **args, size_t sharedMem, cudaStream_t stream)

no