public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/101602] New: local and local_init are not supported in DO CONCURRENT
@ 2021-07-23 15:01 jeff.science at gmail dot com
  2021-11-06 19:53 ` [Bug fortran/101602] [F2018] " anlauf at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jeff.science at gmail dot com @ 2021-07-23 15:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101602

            Bug ID: 101602
           Summary: local and local_init are not supported in DO
                    CONCURRENT
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jeff.science at gmail dot com
  Target Milestone: ---

Fortran 2018 (https://j3-fortran.org/doc/year/18/18-007r1.pdf) has three
locality specifiers: shared, local and local_init.

GCC Fortran does not support any of these.  This breaks user experience for
Fortran programmers using DO CONCURRENT code that works with other compilers.

OpenMP supports equivalent locality specifiers already so the internal
capability for this surely exists in GCC.

      program bug
        implicit none
        integer :: i, j, k
        integer, dimension(100) :: x
        j = 20
        k = 30
        x = 7
        do concurrent (i=1:10) shared(x)
           k = k + x(i)
           j = k 
        end do
        do concurrent (i=1:10) local(j)
           k = k + x(i)
           j = k 
        end do
        do concurrent (i=1:10) local_init(k)
           k = k + x(i)
           j = k 
        end do
        print*,k
      end program bug


% gfortran-11 bug.F
bug.F:8:31:

    8 |         do concurrent (i=1:10) shared(x)
      |                               1
Error: Syntax error in DO statement at (1)
bug.F:11:11:

   11 |         end do
      |           1
Error: Expecting END PROGRAM statement at (1)
bug.F:12:31:

   12 |         do concurrent (i=1:10) local(j)
      |                               1
Error: Syntax error in DO statement at (1)
bug.F:15:11:

   15 |         end do
      |           1
Error: Expecting END PROGRAM statement at (1)
bug.F:16:31:

   16 |         do concurrent (i=1:10) local_init(k)
      |                               1
Error: Syntax error in DO statement at (1)
bug.F:19:11:

   19 |         end do
      |           1
Error: Expecting END PROGRAM statement at (1)

% gfortran-11 --version
GNU Fortran (Homebrew GCC 11.1.0_1) 11.1.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/101602] [F2018] local and local_init are not supported in DO CONCURRENT
  2021-07-23 15:01 [Bug fortran/101602] New: local and local_init are not supported in DO CONCURRENT jeff.science at gmail dot com
@ 2021-11-06 19:53 ` anlauf at gcc dot gnu.org
  2023-08-14 20:12 ` marshall.ward at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-11-06 19:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101602

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-11-06
                 CC|                            |anlauf at gcc dot gnu.org
            Summary|local and local_init are    |[F2018] local and
                   |not supported in DO         |local_init are not
                   |CONCURRENT                  |supported in DO CONCURRENT
           Keywords|                            |rejects-valid
           Priority|P3                          |P4
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.

See also F2018:R1130.

Note that Intel warns that locality information is ignored unless OpenMP or
other form of parallelization is active.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/101602] [F2018] local and local_init are not supported in DO CONCURRENT
  2021-07-23 15:01 [Bug fortran/101602] New: local and local_init are not supported in DO CONCURRENT jeff.science at gmail dot com
  2021-11-06 19:53 ` [Bug fortran/101602] [F2018] " anlauf at gcc dot gnu.org
@ 2023-08-14 20:12 ` marshall.ward at gmail dot com
  2023-08-15  5:06 ` michael at dontknow dot de
  2023-08-16 15:37 ` marshall.ward at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: marshall.ward at gmail dot com @ 2023-08-14 20:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101602

Marshall Ward <marshall.ward at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marshall.ward at gmail dot com

--- Comment #2 from Marshall Ward <marshall.ward at gmail dot com> ---
I've tested this in 13.0.0 and it appears that `local`, `local_init`, `shared`
are still not supported in `do concurrent` and produce syntax errors.

Has there been any activity on this issue recently?  If not, could anyone
comment on the proposal by Jeff Hammond about utilizing the analogous OpenMP
constructs?  Would this be a feasible option?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/101602] [F2018] local and local_init are not supported in DO CONCURRENT
  2021-07-23 15:01 [Bug fortran/101602] New: local and local_init are not supported in DO CONCURRENT jeff.science at gmail dot com
  2021-11-06 19:53 ` [Bug fortran/101602] [F2018] " anlauf at gcc dot gnu.org
  2023-08-14 20:12 ` marshall.ward at gmail dot com
@ 2023-08-15  5:06 ` michael at dontknow dot de
  2023-08-16 15:37 ` marshall.ward at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: michael at dontknow dot de @ 2023-08-15  5:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101602

--- Comment #3 from Michael Klemm <michael at dontknow dot de> ---
The locality specifiers cannot directly map to the OpenMP data-sharing clauses.
 While SHARED and LOCAL can be mapped, LOCAL_INIT cannot.  The latter needs to
initialize the variable anew for each iteration of the DO CONCURRENT loop,
while FIRSTPRIVATE will initialize the variable only once per thread that
executes chunks of said loop.  So, the code transformation for that case will
have to be more involved.

There has been discussions in the OpenMP language committee if a LINEAR(x:0)
clause can substitute LOCAL_INIT(x).  That might be one solution to reduce the
implementation burden and map everything to OpenMP constructs.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/101602] [F2018] local and local_init are not supported in DO CONCURRENT
  2021-07-23 15:01 [Bug fortran/101602] New: local and local_init are not supported in DO CONCURRENT jeff.science at gmail dot com
                   ` (2 preceding siblings ...)
  2023-08-15  5:06 ` michael at dontknow dot de
@ 2023-08-16 15:37 ` marshall.ward at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: marshall.ward at gmail dot com @ 2023-08-16 15:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101602

--- Comment #4 from Marshall Ward <marshall.ward at gmail dot com> ---
Thank you Michael, that is very informative, particularly with respect to
LOCAL_INIT vs FIRSTPRIVATE.  If we could just get support for LOCAL, then we
may be to start using do-concurrent in our production codes.  Perhaps there is
a possibility of only adding support for LOCAL and SHARED, and raising an error
if LOCAL_INIT appears?

I have no experience with the GCC source, but I can see where this should
appear in the parser:

diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index ba23bcd9692..439839295a1 100644
--- a/gcc/fortran/match.cc
+++ b/gcc/fortran/match.cc
@@ -2642,36 +2642,38 @@ gfc_match_do (void)
   if (gfc_match (" concurrent") == MATCH_YES)
     {
       gfc_forall_iterator *head;
       gfc_expr *mask;

       if (!gfc_notify_std (GFC_STD_F2008, "DO CONCURRENT construct at %C"))
        return MATCH_ERROR;


       mask = NULL;
       head = NULL;
       m = match_forall_header (&head, &mask);

       if (m == MATCH_NO)
        return m;
       if (m == MATCH_ERROR)
        goto concurr_cleanup;

+      /* TODO: Parse local, local_init, shared */
+
       if (gfc_match_eos () != MATCH_YES)
        goto concurr_cleanup;

       if (label != NULL
           && !gfc_reference_st_label (label, ST_LABEL_DO_TARGET))
        goto concurr_cleanup;

       new_st.label1 = label;
       new_st.op = EXEC_DO_CONCURRENT;
       new_st.expr1 = mask;
       new_st.ext.forall_iterator = head;

       return MATCH_YES;

 concurr_cleanup:
       gfc_syntax_error (ST_DO);
       gfc_free_expr (mask);
       gfc_free_forall_iterator (head);

I'm a little lost on how to associate these blocks with OpenMP constructs,
however.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-16 15:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 15:01 [Bug fortran/101602] New: local and local_init are not supported in DO CONCURRENT jeff.science at gmail dot com
2021-11-06 19:53 ` [Bug fortran/101602] [F2018] " anlauf at gcc dot gnu.org
2023-08-14 20:12 ` marshall.ward at gmail dot com
2023-08-15  5:06 ` michael at dontknow dot de
2023-08-16 15:37 ` marshall.ward at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).