3 ms·
C++Amp has the easiest GPU allocation. array<int, 128> myGPUArray; That's it. Thanks to RAII, this will be malloc() upon the constructor being called, and
by dragontamer 4y ago
C++Amp has the easiest GPU allocation.
array<int, 128> myGPUArray;
That's it. Thanks to RAII, this will be malloc() upon the constructor being called, and free() when the destructor is called.
A proper C++ language, with proper RAII and integration would be best. C++Amp played around a little bit with some concepts, but it seems to have died off in 2014.
There's also "array_view", which serves as an automagic pointer, that copies data "when the system determines it needs to be copied". (Using a C++ future-like system to block when the CPU-side is accessing before the GPU-side is done writing, and vice versa).
"Array" in C++Amp is similar to cudaMalloc. array_view is pretty nifty overall, and I like the idea of transfers being abstracted away by blocking / futures (besides: CUDA itself has blocking calls to kernels, so its not a completely alien concept).
High speed CPU/GPU interaction would be hampered by array_view (too much automagic), but having a simpler interface and less boilerplate code is a good idea IMO.
- brandmeyer 4y agoIs this under another namespace or something? std::array<T, Size> doesn't call malloc or free at all. Its entire reason for being is that it provides a fixed-sized type which models a RandomAccessContainer while being allocated inline to the parent object.
- dragontamer 4y agoconcurrency::array from C++ AMP. EDIT: It doesn't really call malloc/free, but instead is the equivalent to cudaMalloc / cudaFree.