Hacker News new | ask | show | jobs
by dahart 1471 days ago
Math & logic are rarely the bottleneck over memory & allocation bottlenecks, right? Does Godbolt assume x86? Does the answer change depending on whether you’re using an AMD or NVIDIA GPU, or an Apple, ARM or Intel processor? Does it depend on which instruction pipelines are full or stalled from the surrounding code, e.g., logic vs math? Hard to say if one of these will always be better. There are also other alternatives, e.g. bitmasking, that might generate fewer instructions… maybe “abs(num) > x” will beat both of those examples?
1 comments

> Does Godbolt assume x86?

Godbolt uses whatever compilers, targets, and optimisations you ask it to.

It is, in fact, a very useful tool for comparing different compilers, architectures, and optimization settings.

Ah, yes, thank you, it looks awesome! It doesn't have GPU options (which is fair, since this is standard C++). But I see now I could have figured out the answer to my question in just a few seconds. :)
Compiler Explorer does have GPU options, actually. It has well-established CUDA support and I have been meaning to help add HIP support.
Oh sweet, I missed it then! Where do you go to switch to CUDA?
In the language tab, you can just select "CUDA C++" (or OpenCL C for that matter) instead of C++ or Rust.