3 ms·
I don't think it's controversial at all to wish everything was simple. That said... > Basically if you know how to deal with memory in C, you already know how
by kllrnohj 4y ago
I don't think it's controversial at all to wish everything was simple. That said...
> Basically if you know how to deal with memory in C, you already know how to deal with GPU memory in CUDA.
is not even remotely true in the slightest. Using memory in CUDA is massively more complex than in C. The actual allocation & deallocation API isn't meaningfully different, no, but that's not where the story ends. The story ends with ensuring memory accesses are friendly for the GPU, meaning coalesced or strided. It means adjusting the behavior of L2 cache for the workload. It means optimizing how you actually get data to and from the GPU in the first place. And, last but certainly not least, cudaMalloc and cudaFree are much more expensive than malloc & free are. Like, orders of magnitude more expensive.
Yes you can do all that micro-optimization for CPUs, of course. But for GPGPU it's actually super critical or your performance is just dreadfully bad. Like, don't even bother using the GPU at all bad.
- jpgvm 4y agoNot to mention how insanely difficult heterogeneous memory management can get if you start needing coherence and/or relaxed atomics. I have taken multiple swings at getting good at mixed computing and decided in most cases it's better to just pick CPU or GPU, trying to use both at the same time increases the difficulty by orders of magnitude. Hats off to people that are good at that shit.