Bug 87725 - OpenMP 4.5 clause schedule(simd,monotonic:static) not understood
Summary: OpenMP 4.5 clause schedule(simd,monotonic:static) not understood
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: 7.5
Assignee: Jakub Jelinek
URL:
Keywords: openmp
Depends on:
Blocks:
 
Reported: 2018-10-24 09:50 UTC by Anton Shterenlikht
Modified: 2019-08-30 13:42 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-10-24 00:00:00


Attachments
gcc9-pr87725.patch (1.85 KB, patch)
2018-10-24 18:08 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Shterenlikht 2018-10-24 09:50:11 UTC
OpenMP 4.5 specifications say that
schedule clause can have 2 modifiers,
specifically this should be valid:

!$omp do schedule(simd,monotonic:static)

But gfortran9 rejects this with:

21 | !$omp do schedule(simd,monotonic:static, n/nthr )
   |      1
Error: Unclassifiable OpenMP directive at (1)

Intel Fortran 18 does accept the above
construct with 2 schedule modifiers.

Using only a single modifier is accepted by gfortran9, i.e:

!$omp do schedule( simd:static )
!$omp do schedule( monotonic:static )

are both fine.

I guess this just hasn't been implemented yet?

A complete program:
use, intrinsic :: iso_fortran_env
use :: omp_lib
implicit none
integer :: i, val, tid, nthr, sum, part, n
  write (*,*) "OMP version:", openmp_version
    n = 2**30
  sum = 0
!$omp parallel default( none )   &
!$omp private( tid, i, part, nthr ) &
!$omp shared( sum, n )
      part = 0
      nthr = omp_get_num_threads()
       tid = omp_get_thread_num()
  write (*,*) tid, nthr
! !$omp do schedule(simd,monotonic:static, n/nthr )
!$omp do schedule(simd:static, n/nthr )
! !$omp do schedule(monotonic:static, n/nthr )
 do i=1,n
        part = part + 1
 end do
!$omp end do nowait
         !$omp atomic
               sum = sum + part
         !$omp end atomic
!$omp end parallel
write (*,*) sum, ( sum .eq. n )
end
Comment 1 Jakub Jelinek 2018-10-24 18:08:11 UTC
Created attachment 44893 [details]
gcc9-pr87725.patch

Well, OpenMP 4.5 Fortran support is unfinished, this is just one of the things.
Though, the reason here was just a thinko (nmodifiers == 0 test when nmodifiers == 1 should have been used, because unlike C/C++ FEs it has been bumped already at that point if there was any), the rest of the patch is just better diagnostics and accepting even the bogus cases that I'll make sure to make invalid in OpenMP 5.1.
Comment 2 Jakub Jelinek 2018-10-25 07:57:27 UTC
Author: jakub
Date: Thu Oct 25 07:56:55 2018
New Revision: 265479

URL: https://gcc.gnu.org/viewcvs?rev=265479&root=gcc&view=rev
Log:
	PR fortran/87725
	* openmp.c (gfc_match_omp_clauses): Parse simd, monotonic and
	nonmonotonic modifiers regardless of if they have been parsed
	already or if the opposite one has.  Fix up check whether
	comma after modifier should be parsed.
	(resolve_omp_clauses): Diagnose schedule modifier restrictions.

	* c-c++-common/gomp/schedule-modifiers-1.c (bar): Separate modifier
	from kind with a colon rather than comma.
	* gfortran.dg/gomp/schedule-modifiers-1.f90: New test.
	* gfortran.dg/gomp/schedule-modifiers-2.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/gomp/schedule-modifiers-1.f90
    trunk/gcc/testsuite/gfortran.dg/gomp/schedule-modifiers-2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/openmp.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/c-c++-common/gomp/schedule-modifiers-1.c
Comment 3 Jakub Jelinek 2018-11-05 14:10:48 UTC
Author: jakub
Date: Mon Nov  5 14:10:16 2018
New Revision: 265805

URL: https://gcc.gnu.org/viewcvs?rev=265805&root=gcc&view=rev
Log:
	Backported from mainline
	2018-10-25  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/87725
	* openmp.c (gfc_match_omp_clauses): Parse simd, monotonic and
	nonmonotonic modifiers regardless of if they have been parsed
	already or if the opposite one has.  Fix up check whether
	comma after modifier should be parsed.
	(resolve_omp_clauses): Diagnose schedule modifier restrictions.

	* c-c++-common/gomp/schedule-modifiers-1.c (bar): Separate modifier
	from kind with a colon rather than comma.
	* gfortran.dg/gomp/schedule-modifiers-1.f90: New test.
	* gfortran.dg/gomp/schedule-modifiers-2.f90: New test.

Added:
    branches/gcc-8-branch/gcc/testsuite/gfortran.dg/gomp/schedule-modifiers-1.f90
    branches/gcc-8-branch/gcc/testsuite/gfortran.dg/gomp/schedule-modifiers-2.f90
Modified:
    branches/gcc-8-branch/gcc/fortran/ChangeLog
    branches/gcc-8-branch/gcc/fortran/openmp.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
    branches/gcc-8-branch/gcc/testsuite/c-c++-common/gomp/schedule-modifiers-1.c
Comment 4 Martin Liška 2018-11-20 08:55:16 UTC
Jakub: Can the bug be marked as resolved?
Comment 5 Jakub Jelinek 2018-11-20 08:59:19 UTC
No, it hasn't been backported to 7.x yet.
Comment 6 Jakub Jelinek 2019-08-30 11:09:54 UTC
Author: jakub
Date: Fri Aug 30 11:09:22 2019
New Revision: 275067

URL: https://gcc.gnu.org/viewcvs?rev=275067&root=gcc&view=rev
Log:
	Backported from mainline
	2018-10-25  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/87725
	* openmp.c (gfc_match_omp_clauses): Parse simd, monotonic and
	nonmonotonic modifiers regardless of if they have been parsed
	already or if the opposite one has.  Fix up check whether
	comma after modifier should be parsed.
	(resolve_omp_clauses): Diagnose schedule modifier restrictions.

	* c-c++-common/gomp/schedule-modifiers-1.c (bar): Separate modifier
	from kind with a colon rather than comma.
	* gfortran.dg/gomp/schedule-modifiers-1.f90: New test.
	* gfortran.dg/gomp/schedule-modifiers-2.f90: New test.

Added:
    branches/gcc-7-branch/gcc/testsuite/gfortran.dg/gomp/schedule-modifiers-1.f90
    branches/gcc-7-branch/gcc/testsuite/gfortran.dg/gomp/schedule-modifiers-2.f90
Modified:
    branches/gcc-7-branch/gcc/fortran/ChangeLog
    branches/gcc-7-branch/gcc/fortran/openmp.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
    branches/gcc-7-branch/gcc/testsuite/c-c++-common/gomp/schedule-modifiers-1.c
Comment 7 Jakub Jelinek 2019-08-30 13:42:35 UTC
Fixed.