r/programming • • Sep 03 '26

Branch‑Avoidant Programming

https://easylang.online/blog/branchless
254 Upvotes

92 comments sorted by

View all comments

Show parent comment

1

u/SwingOutStateMachine Sep 04 '26

I don't disagree with any of that. The point I was trying to make was "it is very important to consider the behaviour of threads grouped together in a warp". I would argue that all of the aspects that you describe can be tackled if the code is considered in that way.

But, I think the reason that it seems overemphasised is that it's somewhat unique when writing optimised GPU code, and is often one of the main stumbling blocks for programmers moving from writing CPU code to GPU code. It's also something that can be identified quite easily in a GPU kernel, while effects such as occupancy or memory latency need post-compilation (or runtime) analysis to understand the specific effects, and the impact can vary across different GPU vendors and generations. The latter do typically end up providing the most impactful performance improvements, but at the same time, whenever someone hands me a kernel, my first bit of analysis (before I even compile or run the kernel) is "how uniform is each warp, and are memory accesses coalesced".