Matlab and GPU Running a cuda code on matlab

Hi everyone,

I’m doing a simulation on Matlab. I wrote a kernel code on cuda and try to run in matlab. My code is like that :

global Kernel;

% Preparation of Kernel

nvcc (‘’)

Kernel = parallel.gpu.CUDAKernel(‘example.ptx’,‘’);

Kernel.ThreadBlockSize=[64 2 1];


h_Array _Input = (reshape (single (samples),1,size));

d_In=gpuArray (h_Array _Input);

o=feval (Kernel,d_In,-1);

Out=gather (o);

This code is working. But I want to divide size by 2 and calculate with 2 kernel at same time becausee I have 2 gpu cores. When I generate second kernel, I lose datas of first one.

How can I run two gpu at same time?


Your question is confusing. Can you clarify the terms “two gpu” and “2 gpu cores”?

    Do you have two separate GPU devices in the system?

    Or do you have just 1 GPU and want to launch 2 consecutive GPU kernels?

    Note: 1 GPU definitely has much for than just 2 gpu cores.

In your code you are trying to use the Parallel Computing Toolbox from MathWorks.

As a disclaimer: I’m with AccelerEyes and can tell you that this code would be much better accomplished in Jacket. With Jacket you would be able to do multi-GPU or consecutive kernel launches more efficiently. See how Jacket compares. If you would like us to show you how you can do this in Jacket, let me know in this thread or email me (see my signature below for the address).