NVlabs / NVBit

199 stars 18 forks source link

Question: Getting kernel arguments, values and type #74

Open nayakajay opened 2 years ago

nayakajay commented 2 years ago

Tool: 1.5.3

I was looking at generated_cuda_meta.h and saw that cuLaunchKernel_params has a member called void ** kernelParams. I am understanding that this is to read arguments passed to the kernel. For example,

foo<<<1,1>>>(abc, def, ghi);

kernelParams should give me a way to read and get information about abc, def, and ghi, such as if it's a scalar like int or a pointer type, and their corresponding values. I couldn't find any example to get this done? Can you give some examples? If I am looking at completely wrong place, can you point me towards which struct to check, possibly with some examples?

x-y-z commented 2 years ago

Based on https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EXEC.html#group__CUDA__EXEC_1g06d753134145c4584c0c62525c1894cb:

Kernel parameters must be specified via kernelParams. If f has N parameters, then kernelParams needs to be an array of N pointers. Each of kernelParams[0] through kernelParams[N-1] must point to a region of memory from which the actual kernel parameter will be copied. The number of kernel parameters and their offsets and sizes do not need to be specified as that information is retrieved directly from the kernel's image.