2
$\begingroup$

I work with CUDALink and have some small successes. I use direct calculation on GPU without using CPU (only for sanding commands for CUDA function). Until now I have stored on the hard drive with another kernel the data while GPU calculation (a the same time).

My question: How can I access directly the memory address from other kernel? How can I declarete the memory adress in secound Kernel.

Kernel 1 => CUDA calculation Kernel 2 => Export table on HDD

e.g. on two kernels I do in this way "schematically" (I know, it is a bad way):

ParallelEvaluate[

If[$KernelID==1,CUDAmem = CUDAMemoryAllocate [_Integer, {1000000}]];

];

CUDAmemMatematica=ParallelEvaluate[

If[$KernelID==1,CudaMemoryGet[CUDAmem]]

][[1]];

DistributeDefinitions[CUDAmemMatematica];

ParallelEvaluate [

If[$KernelID==1, Here same calculation on CUDAmem with CUDAFunctions];

,

Export["CUDAmem.dat",CUDAmemMatematica,"TABLE"];

];

I woud like to do this in this way "schematically", but dont know how:

ParallelEvaluate[

If[$KernelID==1,CUDAmem=CUDAMemoryAllocate[_Integer,{1000000}]];

];

ParallelEvaluate[

If[$KernelID==2,CUDAmemMatematica=CudaMemoryGet[CUDAmem]];

];

ParallelEvaluate[

If[$KernelID==1,Here same calculation on CUDAmem with CUDAFunctions;

,

Export["CUDAmem.dat",CUDAmemMatematica,"TABLE"];

]];

Thanks for Your ideas

Corpec

$\endgroup$
1
$\begingroup$

While I am not very familiar with CUDA, this answer on StackOverflow suggests that this is not possible. Quoting the relevant parts:

Q: Is it possible to have two or more linux host processes that can access the same device memory? -- Mark Borgerding

A: My understanding of the CUDA APIs is that this cannot be done. The device pointers are relative to a given CUDA context, and there's no way to share those between processes. -- Edric

Note that Mathematica's subkernels are separate processes.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.