29 lines · plain
1.. title:: clang-tidy - altera-id-dependent-backward-branch2 3altera-id-dependent-backward-branch4===================================5 6Finds ID-dependent variables and fields that are used within loops. This causes7branches to occur inside the loops, and thus leads to performance degradation.8 9.. code-block:: c++10 11 // The following code will produce a warning because this ID-dependent12 // variable is used in a loop condition statement.13 int ThreadID = get_local_id(0);14 15 // The following loop will produce a warning because the loop condition16 // statement depends on an ID-dependent variable.17 for (int i = 0; i < ThreadID; ++i) {18 std::cout << i << std::endl;19 }20 21 // The following loop will not produce a warning, because the ID-dependent22 // variable is not used in the loop condition statement.23 for (int i = 0; i < 100; ++i) {24 std::cout << ThreadID << std::endl;25 }26 27Based on the `Altera SDK for OpenCL: Best Practices Guide28<https://www.altera.com/en_US/pdfs/literature/hb/opencl-sdk/aocl_optimization_guide.pdf>`_.29