3 ms·
> CPU centric languages. What does a "GPU centric language" look like? The most commonly used languages in terms of GPU: - CUDA: C++ like - OpenCL: C like
by raincole 1y ago
> CPU centric languages.
What does a "GPU centric language" look like?
The most commonly used languages in terms of GPU:
- CUDA: C++ like
- OpenCL: C like
- HLSL/GLSL: C like
- arjonagelhout 1y agoTo add to this list, Apple has MSL, which uses a subset of C++
- bsder 1y agoAnnoyingly, everything is converging to C++-ish via Slang now that DirectX supports SPIR-V. OpenCL and GLSL might as well be dead given the vast difference in development resources between them and HLSL/Slang. Slang is effectively HLSL++. Metal is the main odd man out, but is C++-like.
- pjmlp 1y agoSlang is inspired in C#, , beyond the HLSL common subset, whereas HLSL is moving more towards C++ feature. The module system, generics and operators definitions.
- corysama 1y agoCUDA is full-on C++20. The trick is learning how to write C++ that works with the hardware instead of against it.
- pjmlp 1y agoMinus modules though.
- Calavar 1y agoC++ is "C like" and uses manual memory management. The major idiom is RAII, which is based on deterministic destructor execution. Java is "C like" and uses garbage collection for dynamic memory management. It doesn't have determistic destructors. The major idiom is inheritance and overriding virtual methods. GLSL is "C like" and doesn’t even support dynamic memory allocation, manual or otherwise. The major idiom is an implicit fixed function pipeline that executes around your code - you don't write the whole program. So what does "C like" actually mean? IMHO it refers to superficial syntax elements like curly braces, return type before the function name, prefix and postfix increment operators, etc. It tells you almost nothing about the semantics, which is the part that determines how code in that language will map to CPU machine code vs. a GPU IR like SPIR-V. For example, CUDA is based on C++ but it has to introduce a new memory model to match the realities of GPU silicon.