How can I run my own CUDA code?
1 view (last 30 days)
I have a ptx, and a cu files and I want to implement into my code but I dont know how.
I have read this section but I dont understand how can I call my code
I have created a kernel:
k = parallel.gpu.CUDAKernel('kernel.ptx','kernel.cu');
and that's all
here is the inputs what use the cuda code:
limit = 50;
m = 4;
and here is how can I call
kernel<<<grid, block>>>(surfacePoints, d_surface_x, d_surface_y, d_surface_z,
d_electrodes_x, d_electrodes_y, d_electrodes_z,
d_potential, d_laplacian, d_mX, limit, m)
So my problem is, how can I implement a cuda code into the matlab script use that values (the d_ values are known)
Edric Ellis on 7 Jun 2021
To call the kernel, you must first set up the ThreadBlockSize and GridSize properties of k. See this page for more https://www.mathworks.com/help/parallel-computing/cudakernel.html . Then, you call the feval method, supplying either standard MATLAB arrays or gpuArray data for each input. something a little bit like this:
k.ThreadBlockSize = <>;
k.GridSize = <>;
feval(k, d_surface_x, ... % d_surface_x is a standard array or a gpuArray
... % more inputs
There is another option instead of using CUDAKernel that might be more appropriate: use cudamex instead.