On 11.11.21 19:01, Jakub Jelinek wrote: > On Thu, Nov 11, 2021 at 06:11:23PM +0100, Tobias Burnus wrote: >> --- a/gcc/fortran/parse.c >> +++ b/gcc/fortran/parse.c >> ... >> + matchs ("end distribute parallel do simd", gfc_match_omp_end_nowait, >> ... >> + matcho ("end distribute parallel do", gfc_match_omp_end_nowait, > I think the above two changes are incorrect. > At least looking at 5.1 which is clearer than 5.2, 5.1 [221:17-23] says > for C/C++ that while nowait is allowed on worksharing-loop, it is not > allowed on combined parallel worksharing-loop, and Fortran has that > restriction through the syntax (no [nowait] on !$omp end parallel do). I did look at 5.2 and did miss it – but now after searching more careful: In 5.2 it is hidden in "17.3 Combined and Composite Directive Names" [342:14-16] "If directive-name-A is parallel then directive-name-B may be loop, sections, workshare, masked, for, do or the directive name of a combined or composite construct for which directive-name-A is masked, for or do." and "17.4 Combined Construct Semantics" [343:14-16] "If directive-name-A is parallel, the nowait and in_reduction clauses must not be specified." And for completeness, "nowait" (Sect. 15.6) is permitted for "Directives: dispatch, do, for, interop, scope, sections, single, target, target enter data, target exit data, target update, taskwait, workshare" * * * With the attached patch, the following combined/composite directives accept 'nowait' at 'end': "end critical" "end do simd" "end do" "end scope" "end sections" "end single" "end target parallel" (newly permits nowait) "end target simd" (newly permits nowait) "end target teams distribute simd" (newly permits nowait) "end target teams distribute" (newly permits nowait) "end target teams loop" (newly permits nowait) "end target teams" (newly permits nowait) "end target" "end workshare" and the following don't "end atomic" "end distribute parallel do simd" "end distribute parallel do" "end distribute simd" "end distribute" "end loop" (was completely missing before) "end simd" "end masked taskloop simd" "end masked taskloop" "end masked" "end master taskloop simd" "end master taskloop" "end master" "end ordered" "end parallel do simd" "end parallel do" "end parallel loop" (was completely missing before) "end parallel masked taskloop simd" "end parallel masked taskloop" "end parallel masked" "end parallel master taskloop simd" "end parallel master taskloop" "end parallel master" "end parallel sections" "end parallel workshare" "end parallel" "end target data" "end target parallel do simd" "end target parallel do" "end target parallel loop" (was completely missing before) "end target teams distribute parallel do simd" "end target teams distribute parallel do" "end taskgroup" "end taskloop simd" "end taskloop" "end task" "end teams distribute parallel do simd" "end teams distribute parallel do" "end teams distribute simd" "end teams distribute" "end teams loop" "end teams" * * * [target parallel do simd:] > The above seems like a bug in 5.1 standard, haven't checked 5.2. > !$omp end target parallel do simd nowait > should be IMO valid, but [241:16] mistakenly doesn't list it. It is the same – A="target" → B="simd/parallel/teams" and there B can be also the A in a combined/composite construct, such that A=parallel (see first quote above). >> + matcho ("end target parallel do", gfc_match_omp_end_nowait, >> + matcho ("end target parallel loop", gfc_match_omp_end_nowait, >> + matcho ("end target parallel", gfc_match_omp_end_nowait, > Similarly. While the first two are still invalid, in the latter parallel does not appear as "A" and is thus valid in 5.2 in my reading. >> - matchs ("end target simd", gfc_match_omp_eos_error, ST_OMP_END_TARGET_SIMD); >> + matchs ("end target simd", gfc_match_omp_end_nowait, ST_OMP_END_TARGET_SIMD); > Similarly. Likewise now valid in my reading. Revised version attached – it does follow 5.2 by permitting all 'target' combined/composite constructions which does not contain 'parallel' as "A". — I hope I got it now right (following OMP 5.2). Tobias PS: I note that c-c++-common/gomp/clauses-1.c has the following. I think it follows into the category could be valid (and attached to 'target') but OMP 5.1 and OMP 5.2 do not permit it. [I have no checked other variations, I just saw them fail in the Fortranized version and looked at the original.] * #pragma omp target parallel for ... nowait (twice) * #pragma omp target parallel for simd ... nowait * #pragma omp target teams distribute parallel for ... nowait * #pragma omp target teams distribute parallel for simd .. nowait * #pragma omp target parallel loop ... nowait (twice) * #pragma omp target parallel for ... nowait (twice) * #pragma omp target parallel for simd ... nowait ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955