4 ms·
Shared virtual memory: when a CPU allocates a region of memory, and then the GPU synchronizes to the same region of memory. Any reads / writes to that virtual
by dragontamer 9y ago
Shared virtual memory: when a CPU allocates a region of memory, and then the GPU synchronizes to the same region of memory.
Any reads / writes to that virtual memory address work in both CPU and GPU code. So the CPU can do highly sequential tasks like balancing a binary tree (with all of the pointers involved), while the GPU can do highly parallel tasks like traversing the tree exhaustively. Pointers inside of this shared region remain legitimate, because each address is correctly identified between the CPU and GPU.
See this for example: https://software.intel.com/en-us/articles/opencl-20-shared-virtual-memory-overview https://software.intel.com/en-us/articles/opencl-20-shared-v...
I'm describing "Fine Grained Shared Virtual Memory" btw, in case anyone wants to know what to search for.
In effect, it works because the CPU does an mmap, and then the GPU does an mmap, and then the PCIe drivers work to keep the mmap'd region in sync. With modern acquire / release memory fence semantics + atomics properly defined, its even possible to write "Heterogeneous" code where the CPU and GPU works simultaneously on the same memory space.
In theory. I haven't tested these features out yet, and its quite possible that current implementations are buggy. But the features exist and its totally possible (to attempt) to do this sort of stuff on hardware today.
- chubot 9y agoHm I hadn't heard of this, that's interesting. That seems fragile but I'm not an expert in this area. I found this recent CppCon video pretty interesting. It's about running vanilla C++ on (nvidia) GPUs and what the implications are for the C++ memory model: https://www.youtube.com/watch?v=86seb-iZCnI https://www.youtube.com/watch?v=86seb-iZCnI