Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Short-circuiting in C
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Nobody, post: 4215067"] I was (initially) under the impression that he wanted consistency between CPU and GPU performance, and GPUs can't do short-circuit evaluation. On a SIMD architecture (e.g. a GPU), you only have one program counter for all processing units, so a branch where the test result can vary between units cannot be implemented in the conventional manner (by modifying the program counter). An if-else construct involves executing both branches on all units; each unit ignores the instructions in one of the branches depending upon whether the test is true or false on that particular unit. OTOH, the OP may have just misunderstood what "branches are slow" means in the context of GPU programming. They're slow in the sense that branching over a set of instructions takes just as long as executing them. That doesn't mean that tricks which eliminate branches will necessarily be any faster. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Short-circuiting in C
Top