What happens to the execution time if you remove the atomicAdd from both variants? An if-statement with a condition that is always false at run time is not equivalent to an if-statement with a condition that is known false at compile time, independent of the HW architecture. While they are functionally equivalent, there are performance implications. An if-statement with a condition that is known to be false at compile time can be removed by the compiler as “dead code”. This then may allow additional optimizations (for example, it may significantly lengthen a basic block my merging straight-line code preceeding and following the if-statement). If there is a “fat point” with regard to register pressure inside the if-statement, removal of the if-statement will lower register pressure, thus potentially increasing occupancy and performance.
Hello ! Thanks for your quick answer.
I tried to remove the atomicAdd and i can run my program in 200ms in both cases.
Do you think that confirms what you said?
Your observation doesn’t jibe with my hypothesis. My next hypothesis would be that the condition does not actually always evaluate to false at runtime, as you assume it does. Beyond that I have no further ideas at the moment.
I looked at the value which is stored at “addr” and at the end of my kernel execution it’s still 0, the initial value, so i’m pretty sure that the atomicAdd is never called.
I’ll see tomorrow with my internship manager, maybe he’ll have an idea.