How can I run my own CUDA code?

2 visualizaciones (últimos 30 días)
Question Mr
Question Mr el 6 de Jun. de 2021
Comentada: Question Mr el 7 de Jun. de 2021
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:
like this:
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)

Respuesta aceptada

Edric Ellis
Edric Ellis el 7 de Jun. de 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
limit, m);
There is another option instead of using CUDAKernel that might be more appropriate: use cudamex instead.

Más respuestas (0)

Categorías

Más información sobre Get Started with GPU Coder en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by