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="Billy Mays, post: 4214487"] On the GPU I am using, threads execute simultaneously as long as they all execute the exact same instructions (ie, they all take the branch). If one of the threads takes a different execution path, then each thread has to run in serial which means the parallel speed gain is lost. It would be cheaper to evaluate the whole expression rather than short-circuit since it would mean that all the threads could take the same path. For example, if(a && b && c) { /* Do stuff */ } Thread 1: a = 1, b = 2, c = 0 Thread 2: a = 0, b = 1, c = 2 Neither thread will execute the body of the if statement, but Thread 2 would branch away while Thread 1 would still be evaluating b and c. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Short-circuiting in C
Top