%\pagebreak \section{\kcode{loop} Construct} \label{sec:loop} \index{constructs!loop@\kcode{loop}} \index{loop construct@\kcode{loop} construct} The following example illustrates the use of the OpenMP 5.0 \kcode{loop} construct for the execution of a loop. The \kcode{loop} construct asserts to the compiler that the iterations of the loop are free of data dependencies and may be executed concurrently. It allows the compiler to use heuristics to select the parallelization scheme and compiler-level optimizations for the concurrency. \cexample[5.0]{loop}{1} \ffreeexample[5.0]{loop}{1} The following example shows the use of the orphaned \kcode{loop} construct. Since the function \ucode{foo()} is not lexically nested inside of the \kcode{teams} region it needs to specify the \kcode{bind} clause. The first \kcode{loop} construct binds to the \kcode{teams} region from where the function \ucode{foo} is called. Binding to \kcode{teams} allows thread-level parallelism to be available for the second \kcode{loop} construct. The loop iterations can be executed concurrently, thus allowing implementations to perform various loop nest optimizations including reordering of the \ucode{i} and \ucode{j} loops. The \kcode{loop} construct can be implemented with the use of additional threads or some other concurrency mechanism, which allows better use of hardware resources while also allowing sequential optimizations, reordering, tiling etc. For example, the first \kcode{loop} construct could be implemented as if it was specified as \kcode{distribute parallel for} and the second \kcode{loop} construct as if it was specified as \kcode{simd} if the hardware can support SIMD operations. % \\ % OR % \\ % For example, the first \kcode{loop} construct could be implemented as % \kcode{distribute parallel for} and the second \kcode{loop} construct as \kcode{simd} % if the hardware can support SIMD operations. \cexample[5.0]{loop}{2} \ffreeexample[5.0]{loop}{2}