Accessing kernel name from .cubin Cuda Applied programming.

Hello everyone.

I found when I use runtime API, the generated cubin file has different kernel name from
what I defined in cu file. Is there anyway to keep the name same or we can get the new
name from cubin file?

Thanks in advance.

SK.

I don’t know of any, but the kernel name does depend only on the function prototype, so you could just read it by hand one, and use constatly :).

That’s what I guessed. It works when using Driver API, not Runtime API.

You may ask back why we need the explicit name from cubin in Runtime API. But
In runtime API, instead of calling matrixMul<<thread, block>> (args…),
I wanted to use driver API.

Actually I was sucessful when use the block of program using driver API with runtime API.
Runtime API : For cudaMalloc(), cudaMemcpy().
driver API: cuModuleLoad(), cuParamSet(), cuFuncSetBlockSize(), cuLaunchGrid().

The problem is that when I generate cubin file, the kernel name matrixMul' in matrixMul_kernel.cu is changed to _Z9matrixMulPfS_S_ii’ in the name field of code block.

How?
matrixMul' -----> _Z9matrixMulPfS_S_ii’

This is one of my question.

Thanks.

SK.

This is because C++ name mangling is applied to the kernels. If you don’t want this, you can delcare the kernel

extern “C” global mykernel(…)

That works great. So I’ve only to focus on the name of kernel I named.

Is name mangling shows always same output? (I generated cubin several times but the

output of mangling was always same…)

SK.

Assuming the function signature is identical, then yes the mangled name will always be identical. That is the point of mangled names after all: a way for the compiler to generate and use unique function names for functions belonging to specific classes or with different template arguments. If it were random, the compiler would have an awfully hard time trying to link libraries and executables ;)

If you add an argument or change the type of an argument, then the mangled name will change.