Cuda¶
BranchDivergence¶
Since: 0.15
Name: branch divergence
Branch divergence is quite expensive and needs to be avoided as much as possible.
This rule is defined by the following class: oclint-rules/rules/cuda/CudaBranchDivergenceRule.cpp
Example:
if (threadIdx.x == 0) {
foo();
} else {
bar();
}
// This would cause branch divergence,
// as while the first thread working on `foo()`,
// the rest of the threads sit idle;
// similarly, when the others running `bar()`,
// the first thread now stall.
// Go https://bit.ly/2ZxYJVR to read more.