jean-claude

Double memory copy in CAL ? What about calCtxResCreate ?

Discussion created by jean-claude on Dec 28, 2008
Latest reply on Jan 14, 2009 by rick.weber
Optimizing memory exchanges between CPU & GPU

Hi ,

I have some basic question related to explicit/implicit memory exchanges between CPU and the GPU

Here is some case:

CALresource  Mrem;
calResAllocRemote1D(&Mrem, &device, 1, 1024, CAL_FORMAT_INT_1, CAL_RESALLOC_CACHEABLE);


This should allocate a 1024 int buffer in the PCI memory zone, correct?
Moreover we ask this resource to be cacheable to get better CPU R/W access perf.

Now consider:

CALuint ptchx = 0;
CALuint *pMem;

calResMap((CALvoid**)&pMem, &ptchx, Mrem, 0);
     for (int i=0; i<1024; i++) *pMem++ = i; // or whatever CPU treatment
calResUnmap(Mrem);


(0) Should Mrem have been allocated as a local GPU resource, my understanding is that an intermediate PCI memory zone would be implicitly allocated at calResMap and that this PCI zone would be implicitly copied to local GPU mem at calResUnmap. Right?

(1) Now since here Mrem is a remote resource:
Is the writing directly done in Mrem, or does it occur first on an
intermediate PCI memory zone and then is implicitly copied  to Mrem at the time of CalResUnMap(Mrem)?? Should it be the case then we face a hidden double copy...

(2) The documentation suggests that double copy can be avoided through careful use of "calCtxResCreate" which doesn't appear to be accessible in the SDK.
Is "calCtxResCreate" a ghost API?? How to use it?

Thanks

Jean-Claude

Outcomes