A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://clang.llvm.org/doxygen/classclang_1_1OMPCanonicalLoop.html below:

clang: clang::OMPCanonicalLoop Class Reference

Representation of an OpenMP canonical loop.

OpenMP 1.0 C/C++, section 2.4.1 for Construct; canonical-shape OpenMP 2.0 C/C++, section 2.4.1 for Construct; canonical-shape OpenMP 2.5, section 2.5.1 Loop Construct; canonical form OpenMP 3.1, section 2.5.1 Loop Construct; canonical form OpenMP 4.0, section 2.6 Canonical Loop Form OpenMP 4.5, section 2.6 Canonical Loop Form OpenMP 5.0, section 2.9.1 Canonical Loop Form OpenMP 5.1, section 2.11.1 Canonical Loop Nest Form

An OpenMP canonical loop is a for-statement or range-based for-statement with additional requirements that ensure that the number of iterations is known before entering the loop and allow skipping to an arbitrary iteration. The OMPCanonicalLoop AST node wraps a ForStmt or CXXForRangeStmt that is known to fulfill OpenMP's canonical loop requirements because of being associated to an OMPLoopBasedDirective. That is, the general structure is:

OMPLoopBasedDirective [- CapturedStmt ] [- CapturedDecl] OMPCanonicalLoop - ForStmt/CXXForRangeStmt `- Stmt

One or multiple CapturedStmt/CapturedDecl pairs may be inserted by some directives such as OMPParallelForDirective, but others do not need them (such as OMPTileDirective). In The OMPCanonicalLoop and ForStmt/CXXForRangeStmt pair is repeated for loop associated with the directive. A OMPCanonicalLoop must not appear in the AST unless associated with a OMPLoopBasedDirective. In an imperfectly nested loop nest, the OMPCanonicalLoop may also be wrapped in a CompoundStmt:

[...] OMPCanonicalLoop - ForStmt/CXXForRangeStmt `- CompoundStmt |- Leading in-between code (if any) |- OMPCanonicalLoop | - ForStmt/CXXForRangeStmt |- ... `- Trailing in-between code (if any)

The leading/trailing in-between code must not itself be a OMPCanonicalLoop to avoid confusion which loop belongs to the nesting.

There are three different kinds of iteration variables for different purposes:

This AST node provides two captured statements:

These captured statements provide the link between C/C++ semantics and the logical iteration counters used by the OpenMPIRBuilder which is language-agnostic and therefore does not know e.g. how to advance a random-access iterator. The OpenMPIRBuilder will use this information to apply simd, workshare-loop, distribute, taskloop and loop directives to the loop. For compatibility with the non-OpenMPIRBuilder codegen path, an OMPCanonicalLoop can itself also be wrapped into the CapturedStmts of an OMPLoopDirective and skipped when searching for the associated syntactical loop.

Example: std::vector<std::string> Container{1,2,3}; for (std::string Str : Container) Body(Str); which is syntactic sugar for approximately: auto &&__range = Container; auto __begin = std::begin(__range); auto __end = std::end(__range); for (; __begin != __end; ++__begin) { std::String Str = *__begin; Body(Str); } In this example, the loop user variable is Str, the loop iteration variable is __begin of type std::vector<std::string>::iterator and the logical iteration number type is size_t (unsigned version of std::vector<std::string>::iterator::difference_type aka ptrdiff_t). Therefore, the distance function will be [&](size_t &Result) { Result = __end - __begin; } and the loop variable function is [&,__begin](std::vector<std::string>::iterator &Result, size_t Logical) { Result = __begin + Logical; } The variable __begin, aka the loop iteration variable, is captured by value because it is modified in the loop body, but both functions require the initial value. The OpenMP specification explicitly leaves unspecified when the loop expressions are evaluated such that a capture by reference is sufficient.

Definition at line 142 of file StmtOpenMP.h.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4