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?


This is a duplicate post of (moderators should delete this one)