J3/04-243 Date: 13-Feb-2004 To: J3 From: Bill Long Subject: Concurrent - f03++ proposal Fortran currently lacks an effective method of specifying that a loop does not contain interateration dependencies. Such information enables generation of optimized code on essentially every recent hardware architecture. Many compilers do provide directives to convey this dependency information. The CONCURRENT construct would provide a standard and portable way to accomplish this. The CONCURRENT construct effectively provides a method for specifying fine grained parallelism in a code. It is intended to compliment coarse grained parallelism specifications such as co-arrays. Number: Title: CONCURRENT Construct Submitted By: J3 Status: For Consideration References: Basic Functionality: The CONCURRENT construct would specify a loop construct similar to a nest of DO loops, but using a syntax like that of FORALL. It would specify that the iterations of the loop nest could be executed in any order or in parallel. Equivalently, it would specify that there are no data dependencies between any two interations. While that condition does place restrictions on the statements that may appear in the construct, those restrictions are significantly fewer than for FORALL constructs. Rationale: Some statement constructs in a loop nest, such as gather/scatter operations or procedure calls, make it impossible to determine that the interations of the loop nest are independent. However, if it is known that the loop iterations are independent, then much faster code can be generated for the loop on a variety of hardware architectures, including long vectors (Cray, NEC), short vectors (IBM PowerPC or Intel/AMD based systems), or multi-threading (SPARC and others). The CONCURRENT construct provides a standard way of specifying that the iterations of the loop nest may the executed in any order or in parallel. It would provide a much cleaner and portable alternative to the current practice of preceding DO loops with multiple directives, one for each vendor. Estimated Impact: Changes to the standard document would be fairly localized, though precisely stating what is "obvious" may be non-trivial. Implementation in compilers would be simple, as many compilers already support the feature through directives. At a minimum, a compiler could convert the construct to a set of DO loops, with possibly an IF test, and execute the interations in order. Detailed Specification: The syntax for CONCURRENT follows the FORALL syntax: [:] CONCURRENT ... END CONCURRENT [] Example: ! This example is equivalent to specifying that the array section ! indx(1:n) does not contain any repeated values. concurrent (i=1:n) a(indx(i)) = a(indx(i)) + 1 end concurrent A rule is needed to handle scalar temporaries that used for convenience in otherwise parallel loops: Scalar variables that appear in a definition context within a CONCURRENT construct have independent values for each iteration and become undefined on when execution of the construct completes. We may want to spell out that (even though it is pretty obvious) some execution control constructs are not allowed: Branching out of a CONCURRENT construct is not allowed. History: