A kernel is using 54 registers per thread with an occupancy of 0.33. It has an if statement in it for debugging purpose:
if ( -1 == val ) // val is INT32
{
printf( "Invalid value!\n" );
}
If I comment out this if statement, the kernel uses 33 registers per thread and the occupancy also improves to 0.5. But, the strange part is that this new leaner kernel actually takes 15% more time to execute! All other code and launch parameters (blocks, threads) are constant. Can anyone explain how this performance degradation could happen?
I am using CUDA 4.0 on a GTX 580, with code compiled to CUDA capability 2.0.