Is there a way to make device memory persist between CUDA MEX calls
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Matt J
el 25 de Dic. de 2013
Comentada: Matt J
el 18 de Jun. de 2014
I'm wondering if there is a graceful way to allocate data on or transfer data to the GPU in one MEX file (basically MATLAB interfaces to cudaMalloc or cudaMemcpy) and then process that data on the GPU with a different MEX file. I'm wondering if it is possible to do this without the Parallel Computing Toolbox.
When I do the memory transfer/allocation on the GPU, I will need to keep the pointer to the device memory and have it reside in the MATLAB workspace in some form until it is ready to be passed to the data processing MEX file. I'm wondering what the best way to do that is. Would I just convert the pointer value (not dereferenced) to a MATLAB integer and then convert it back again in the data processing MEX file when needed?
0 comentarios
Respuesta aceptada
Oliver Woodford
el 2 de En. de 2014
Editada: Oliver Woodford
el 2 de En. de 2014
Yes, you can reinterpret_cast the pointer to an integer of a sufficient bit length, e.g. uint64, and return this to MATLAB. Then pass the integer to the new mex file, where it is reinterpreted as the pointer to the GPU memory again.
If you want to use this approach, and minimize chances of leaking memory, then wrap the memory allocation in a C++ class, and use the approach outlined in this FEX submission.
4 comentarios
Oliver Woodford
el 18 de Jun. de 2014
Editada: Oliver Woodford
el 18 de Jun. de 2014
Did this do the trick?
Más respuestas (1)
Eric Sampson
el 2 de En. de 2014
Matt, see if the methods discussed in the following thread could be adapted for your use: http://www.mathworks.com/matlabcentral/newsreader/view_thread/278243
Ver también
Categorías
Más información sobre GPU Computing 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!