J3/05-237 Date: 25-July-2005 To: J3 From: Bill Long Subject: Edits for DO CONCURRENT construct References: Feature j3-046, 05-133r2 -------------------------------------------------------------- Following are the edits to implement the j3-046 feature, the DO CONCURRENT construct. Note: < and > are used to delimit italic font. << and >> are used to delimit bold font. All page and line numbers refer to j3/04-007. EDITS ..................................................................... In the Introduction section (page xiii), the list of new Fortran 2008 features should include The DO CONCURRENT construct which allows loop iterations to be executed in any order or concurrently. ..................................................................... In section 1.6 Compatibility, there are no changes needed. ..................................................................... 164:3. In the second sentence of the first paragraph in 8.1.6, DO construct, replace "The EXIT and CYCLE statements" with: The EXIT, except in a DO CONCURRENT construct, and the CYCLE statements ..................................................................... 164:6. In the second sentence of the second paragraph in 8.1.6, DO construct, replace "In either case," with: Except in the case of a DO CONCURRENT construct, ..................................................................... 165:15+. Add an new line to R830, in 8.1.6.1.1, Form of the block DO construct: or [,] CONCURRENT ..................................................................... 165:15++. Following the line added in the edit for 165:15+ above, add the following paragraph: A <> construct is a DO construct with a of [,] CONCURRENT . ..................................................................... 167:7+. Before the last sentence of 8.1.6.4.1, Loop initiation, add a new paragraph: For a DO CONCURRENT construct the values of the index variables for the iterations of the construct are determined by the rules for the index variables of the FORALL construct (7.4.4.2.1 and 7.4.4.2.2). The number of distinct index value combinations in the active combination of values is the iteration count for the construct. ..................................................................... 167:10. In the first sencence of 8.1.6.4.2, The execution cycle, replace "The <> of a DO construct consists of" with: The <> of a DO construct that is not a DO CONCURRENT construct consists of ..................................................................... 167:23+. At the end of 8.1.6.4.2, The execution cycle, add a new paragraph: The <> of a DO CONCURRENT construct consists of the following steps: (1) The iteration count is tested. If it is zero the loop terminates, and the DO CONCURRENT construct becomes inactive. (2) If the iteration count is non-zero, the range of the loop is executed once for each active combination of values. The order in which the iterations are performed is indeterminant. ..................................................................... 167:25. In the first sentence of 8.1.6.4.3, CYCLE statement, replace "Step (2) in the above execution cycle may be curtailed" with: Execution of the range of the loop may be curtailed ..................................................................... 167:33. At the beginning of the first sentence of the second to last paragraph of subsection 8.1.6.4.3, replace "Execution of a CYCLE statement causes" with: Execution of a CYCLE statement in a DO construct that is not a DO CONCURRENT construct causes ..................................................................... 167:34. After the first sentence if the second to last paragraph of subsection 8.1.6.4.3, add a new sentence: Execution of a CYCLE statement in a DO CONCURRENT construct completes the execution of that iteration of the loop. ..................................................................... 168:7+ Add two new constraints to subsection 8.1.6.4.4, Loop termination: C829a (R844) An shall not appear with a specified for a DO CONCURRENT construct. C829b (R844) An shall not appear within the loop range of a DO CONCURRENT construct without a if the innermost DO construct is the DO CONCURRENT construct, or with a specified for any construct that contains the DO CONCURRENT construct. ..................................................................... 168:11. At the beginning of the sentence before the list of items in subsection 8.1.6.4.4, replace "The loop terminates" with: For a DO construct that is not a DO CONCURRENT construct, the loop terminates ..................................................................... 168:23+. After the last paragraph of subsection 8.1.6.4.4, add a new paragraph: For a DO CONCURRENT construct, the loop terminates, and the DO construct becomes inactive when all of the iterations have completed execution. ..................................................................... 168:24-. Add a new subsection and two Notes between 8.1.6.4.4 and 8.1.6.5: 8.1.6.4a Restrictions on DO CONCURRENT constructs Restrictions on the statements in the loop range of a DO CONCURRENT construct allow the iterations of the loop to be executed in any order, or conurrently. A statement in the loop range of a DO CONCURRENT construct shall not cause a branch out of the loop range. A variable that is referenced in an iteration of a the loop range of a DO CONCURRENT construct shall either be previously defined during that iteration, or shall not be defined during any other iteration. A variable that is defined by more that one iteration becomes undefined when the DO CONCURRENT construct terminates. A pointer that is referenced in an interation of a DO CONCURRENT construct either shall be previously pointer associated during that iteration, or shall not become pointer associated in the loop range. A pointer that is pointer associated in more than one iteration has a processor dependent association status when the DO CONCURRENT construct terminates. An allocatable object that is allocated in more than one iteration of a DO CONCURRENT construct shall be subsequently deallocated during the same iteration in which it was allocated. An object that is allocated or deallocated in only one iteration of a DO CONCURRENT construct shall not be deallocated, allocated, referenced, or defined in a different iteration. An input/output statement in a DO CONCURRENT construct shall not write data to a file record or position in one iteration and read from the same record or position in a different iteration. Procedures referenced in the loop range of a DO CONCURRENT construct shall be PURE. If the IEEE_EXCEPTIONS intrinsic module is accessible, calls to the IEEE_GET_FLAG, IEEE_SET_HALTING_MODE, and IEEE_GET_HALTING_MODE subroutines shall not appear in the loop range. Note 8.15a The restrictions on referencing variables defined in an iteration of a DO CONCURRENT construct apply to any procedure invoked by the loop. [end Note] Note 8.15b The restrictions on the statements in the loop range of a DO CONCURRENT construct are designed to ensure there are no data dependencies between iterations of the loop. This permits code optimizations that might otherwise be difficult or impossible because they would depend on characteristics of the program not visible to the compiler. [end Note] ..................................................................... 169:1-- After Note 8.18, add a new Note: Note 8.18a The following example represents a common case in which the user knows that the elements of the array IND form a permutation of the integers 1..N. The DO CONCURRENT construct will allow the compiler to generate vector gather/scatter code, loop unrolling, or parallel threaded code for this loop, significantly improving performance. INTEGER :: A(N),IND(N) DO CONCURRENT (I=1:N) A(IND(I)) = A(IND(I)) + 1 END DO ..................................................................... 287:7+. In the third line of Note 12.44, replace "FORALL where" with FORALL , or a DO CONCURRENT construct, where ..................................................................... 287:7+. In the last sentence of Note 12.44, replace "referenced in FORALL statements and constructs and within" with: referenced in FORALL statements and constructs, DO CONCURRENT constructs, and within ..................................................................... 409:15-410:4. In section 16.3, Statement and construct entities, replace "FORALL construct" with "FORALL or DO CONCURRENT construct" in the following eight locations: 409:15 409:24 409:28 409:42 409:43 410:1 410:2 410:4 ..................................................................... 409:26. In the third line of the third paragraph of section 16.3, replace "FORALL" with "FORALL statement or FORALL or DO CONCURRENT construct". .....................................................................