How can I run my own CUDA code?

2 vues (au cours des 30 derniers jours)
Question Mr
Question Mr le 6 Juin 2021
Commenté : Question Mr le 7 Juin 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)

Réponse acceptée

Edric Ellis
Edric Ellis le 7 Juin 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.
  1 commentaire
Question Mr
Question Mr le 7 Juin 2021
Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with GPU Coder dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by