I wonder if pagelocked memory is visible from the cpu outside the .cu file.
To explain: I call a .cu file from a .cpp file. In .cu file i allocate some bytes of pinned memory where both cpu and gpu read and write.
Can I pass a pointer to that memory as parameter to the .cpp file and have access (read) to pinned memory or is it visible only inside .cu file?
The answer seems yes since the memory is pagelocked but so far I don’t have any success.
Any example code / pseudocode would help.
Yes, pinned memory is just like ordinary memory in that regard. Only if you want to use the pinned memory from other GPUs as well you have to mark it as portable during allocation.
I have only one gpu.
I would like to see an example of how we can read/ write from .cpp file to pinned memory which has been allocated in a .cu file.
If all the code is in .cu file I did it, but I would like to be able to read/ write mapped memory from other functions / other files.
Could anyone post some code or some links to stg relative?
You were printing the addresses where the pointers reside in memory, not the addresses they are pointing to.
P.S.: You can post code on the forums between [font=“Courier New”][code][/font]…[font=“Courier New”][/code][/font] tags for the nice formatting as shown above.