J3/05-237r1 Date: 08 August 2005 To: J3 From: Bill Long Subject: Edits for DO CONCURRENT construct References: Feature j3-046, 05-133r2, 05-237 -------------------------------------------------------------- Following are the edits to implement the j3-046 feature, the DO CONCURRENT construct. The detailed specifications for this feature are in 05-133r2. 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 Performance enhancements: 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 statement, except in a DO CONCURRENT construct, and the CYCLE statement ..................................................................... 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:8+. After the second paragraph of 8.1.6, add the following paragraph: A <> construct is a DO construct with a of [,] WHILE (). A <> construct is a DO construct with a of [,] CONCURRENT . ..................................................................... 165:15+. Add an new line to R830, in 8.1.6.1.1, Form of the block DO construct: or [,] CONCURRENT ..................................................................... 167:4-5. In the third sentence of the paragraph following Note 8.15, replace "If is [,] WHILE ()" with: For a DO WHILE construct ..................................................................... 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:13. In the third sentence of item (1) in 8.1.6.4.2, replace "If is [,] WHILE ()" with: For a DO WHILE construct ..................................................................... 167:23+. At the end of 8.1.6.4.2, The execution cycle, add a new paragraph: The of a DO CONCURRENT construct is executed for all of the active combinations of the values. Each execution of the is an iteration. The executions may occur in any order, or concurrently. ..................................................................... 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:29+. After constraint C828 in 8.1.6.4.3, add a new constraint: C828a (R843) The shall not appear within the of a DO CONCURRENT construct if it belongs to a construct that contains the DO CONCURRENT construct. ..................................................................... 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 that belongs to 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 that belongs to a DO CONCURRENT construct completes the iteration of that construct in which the CYCLE statement is executed. ..................................................................... 168:7+ Add a new constraint to subsection 8.1.6.4.4, Loop termination: C829a (R844) An shall not belong to a DO CONCURRENT construct, nor shall it appear within the of a DO CONCURRENT construct if it belongs to a construct that contains that 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 of a DO CONCURRENT construct allow the iterations of the loop to be executed in any order, or concurrently. A statement in the shall not cause a branch out of the construct. A variable that is referenced in an iteration shall either be previously defined during that iteration, or shall not be defined during any other iteration of the current execution of the construct. A variable that is defined by more that one iteration of the current execution of the construct becomes undefined when the current execution of the construct terminates. A pointer that is referenced in an iteration either shall be previously pointer associated during that iteration, or shall not become pointer associated during any iteration. A pointer that is pointer associated in more than one iteration has a processor dependent association status when the construct terminates. An allocatable object that is allocated in more than one iteration shall be subsequently deallocated during the same iteration in which it was allocated. An object that is allocated or deallocated in only one iteration shall not be deallocated, allocated, referenced, or defined in a different iteration. An input/output statement 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 of the same execution of the construct. Procedures referenced in the 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 . 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". ..................................................................... 423:18. In item (15) of section 16.5.6, replace "FORALL construct" with "FORALL or DO CONCURRENT construct". ..................................................................... 423:18+. After item (15) of section 16.5.6, add the following item: When a DO CONCURRENT construct terminates, a variable that is defined by more than one iteration of the construct becomes undefined.