3 ms·
What I wish we had is a portable version of SIMD that runs on any CPU and any GPU as part of all programming languages, so that taking advantage of those does n
by jiehong 2y ago
What I wish we had is a portable version of SIMD that runs on any CPU and any GPU as part of all programming languages, so that taking advantage of those does not suck.
Just like we have for loops and threads that work on all CPU architectures and cores.
Instead we have a mess of various CPU instructions (SSE, AVX, NEON, SVE) along with incompatible GPU frameworks (CUDA, rocm?).
Java is trying to do that with Vector api but only for stuff on CPUs, so GPUs are not included [0].
If we had a unified way to take advantage of CPU and GPU, I’m sure devs would do it more.
[0]: https://openjdk.org/jeps/426 https://openjdk.org/jeps/426
- dragontamer 2y ago#pragma openmp simd for(int i=0; i<1000; i++){ z[i] = x[i] + y[i]; // Look ma, I'm parallel! } Relies very heavily on the autovectorizer of GCC / LLVM, but it works somewhat well if you know what you're doing. Also, I'm pretty sure #pragma openmp simd doesn't actually do anything but maybe makes the "failed to vectorize" warnings a bit more obvious?? I dunno, I don't play with the auto-vectorizer that much actually.