1.. title:: clang-tidy - altera-id-dependent-backward-branch 2 3altera-id-dependent-backward-branch 4=================================== 5 6Finds ID-dependent variables and fields that are used within loops. This causes 7branches 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-dependent 12 // 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 condition 16 // 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-dependent 22 // 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 Guide 28<https://www.altera.com/en_US/pdfs/literature/hb/opencl-sdk/aocl_optimization_guide.pdf>`_. 29