access to a gpuArray from a MEX file?

I did a lot of work with CUDA MEX files before gpuArray was an option. Now I would like to simplify my interface to these MEX files by allowing them to access data that the user has stored in gpuArrays -- but I do not want to rewrite all my code.
So: what I need is a way for my MEX code to access a gpuArray's internal pointer to GPU memory, and other metadata. Is there a way to do this?
I suppose I would also need access to the Parallel Computing Toolbox's CUDA context for this to work.

 Respuesta aceptada

Edric Ellis
Edric Ellis el 14 de Jul. de 2011

0 votos

You're right that you need Parallel Computing Toolbox to access gpuArray functionality. We don't offer a MEX interface with gpuArrays, but we do offer the CUDAKernel which allows you to use gpuArrays together with hand-written CUDA code. Here's the doc for CUDAKernel.
We think that CUDAKernel is easier to use than a MEX layer because you only need to write the "__global__" entry points for CUDA, you don't need to write any of the code to marshal data in and out of mxArrays.

4 comentarios

Jim Mutch
Jim Mutch el 14 de Jul. de 2011
Thanks for the reply. It may indeed be easier for new code development, but not necessarily for people with existing CUDA MEX files.
King Fisher
King Fisher el 27 de Nov. de 2011
Edric,
I ve tested the MATLAB .cu code and generate a .ptx file for it. But when I execute it on matlab the following error occurs:
??? Error using ==> iParseToken at 266
Unsupported type in argument specification "fahad.cu".
Error in ==>
/usr/local/Matlab/2011a/toolbox/distcomp/gpu/+parallel/+internal/+gpu/handleKernelArgs.p>iParseCPrototype at 192
Error in ==>
/usr/local/Matlab/2011a/toolbox/distcomp/gpu/+parallel/+internal/+gpu/handleKernelArgs.p>handleKernelArgs at 79
To let you clear that Gpu is funtioning well in my Matlab environment for other functions ,example, gpuarray().
Would you please figure out the problem !
Walter Roberson
Walter Roberson el 27 de Nov. de 2011
King Fisher, I recommend that you start a new Question for this.
Daniel Armyr
Daniel Armyr el 18 de Mzo. de 2013
With the release of 2013a, though, you can do what the original poster wanted. See this: http://www.mathworks.se/help/distcomp/create-and-run-mex-files-containing-cuda-code.html

Iniciar sesión para comentar.

Más respuestas (1)

John Melonakos
John Melonakos el 17 de Jul. de 2011

0 votos

Jacket users have access to the Jacket SDK that has advantages over the other two approaches: http://blog.accelereyes.com/blog/2010/10/29/jacket_sdk_trumps_mex/

1 comentario

Jim Mutch
Jim Mutch el 17 de Jul. de 2011
Perhaps, but in my question I said "I do not want to rewrite all my code". So this is off topic.
Do you guys need to pop up in every GPU-related thread?

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 14 de Jul. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by