public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/96459] New: OpenMP host teams reductions ignored
@ 2020-08-04 14:47 jakub at gcc dot gnu.org
  2020-08-04 14:49 ` [Bug middle-end/96459] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-04 14:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96459
           Summary: OpenMP host teams reductions ignored
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

#include <stdlib.h>

int
main ()
{
  int niters = 0, i, j, k;
  #pragma omp teams reduction(+:niters)
  {
    #pragma omp distribute collapse(3)
    for (i = 0; i < 3; i++)
      for (j = 0; j < 8; j += 2)
        for (k = 0; k < 25; k += 3)
          niters++;
  }
  if (niters != 96)
    abort ();
  return 0;
}

is miscompiled, nothing performs the reduction on niters.

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

* [Bug middle-end/96459] OpenMP host teams reductions ignored
  2020-08-04 14:47 [Bug middle-end/96459] New: OpenMP host teams reductions ignored jakub at gcc dot gnu.org
@ 2020-08-04 14:49 ` jakub at gcc dot gnu.org
  2020-08-04 14:57 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-04 14:49 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
           Keywords|                            |openmp, wrong-code
   Last reconfirmed|                            |2020-08-04
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Wrong code since GCC 9 when host teams support has been introduced.

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

* [Bug middle-end/96459] OpenMP host teams reductions ignored
  2020-08-04 14:47 [Bug middle-end/96459] New: OpenMP host teams reductions ignored jakub at gcc dot gnu.org
  2020-08-04 14:49 ` [Bug middle-end/96459] " jakub at gcc dot gnu.org
@ 2020-08-04 14:57 ` jakub at gcc dot gnu.org
  2020-08-04 14:59 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-04 14:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 48994
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48994&action=edit
gcc11-pr96459.patch

Untested fix.

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

* [Bug middle-end/96459] OpenMP host teams reductions ignored
  2020-08-04 14:47 [Bug middle-end/96459] New: OpenMP host teams reductions ignored jakub at gcc dot gnu.org
  2020-08-04 14:49 ` [Bug middle-end/96459] " jakub at gcc dot gnu.org
  2020-08-04 14:57 ` jakub at gcc dot gnu.org
@ 2020-08-04 14:59 ` jakub at gcc dot gnu.org
  2020-08-05  8:44 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-04 14:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #0)
>   if (niters != 96)
    if (niters != 108)
Can't count, sorry.

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

* [Bug middle-end/96459] OpenMP host teams reductions ignored
  2020-08-04 14:47 [Bug middle-end/96459] New: OpenMP host teams reductions ignored jakub at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-08-04 14:59 ` jakub at gcc dot gnu.org
@ 2020-08-05  8:44 ` cvs-commit at gcc dot gnu.org
  2020-08-25 17:44 ` cvs-commit at gcc dot gnu.org
  2020-09-16 19:22 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-05  8:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:916c7a201a9a1dc94f2c056a773826a26d1daca9

commit r11-2571-g916c7a201a9a1dc94f2c056a773826a26d1daca9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Aug 5 10:40:10 2020 +0200

    openmp: Handle reduction clauses on host teams construct [PR96459]

    As the new testcase shows, we weren't actually performing reductions on
    host teams construct.  And fixing that revealed a flaw in the for-14.c
testcase.
    The problem is that the tests perform also initialization and checking
around the
    calls to the functions with the OpenMP constructs.  In that testcase, all
the
    tests have been spawned from a teams construct but only the tested loops
were
    distribute, which means the initialization and checking has been performed
    redundantly and racily in each team.  Fixed by performing the
initialization
    and checking outside of host teams and only do the calls to functions with
    the tested constructs inside of host teams.

    2020-08-05  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/96459
            * omp-low.c (lower_omp_taskreg): Call lower_reduction_clauses even
in
            for host teams.

            * testsuite/libgomp.c/teams-3.c: New test.
            * testsuite/libgomp.c-c++-common/for-2.h (OMPTEAMS): Define to
nothing
            if not defined yet.
            (N(test)): Use it before all N(f*) calls.
            * testsuite/libgomp.c-c++-common/for-14.c (DO_PRAGMA, OMPTEAMS):
Define.
            (main): Don't call all test_* functions from within
            #pragma omp teams reduction(|:err), call them directly.

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

* [Bug middle-end/96459] OpenMP host teams reductions ignored
  2020-08-04 14:47 [Bug middle-end/96459] New: OpenMP host teams reductions ignored jakub at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-08-05  8:44 ` cvs-commit at gcc dot gnu.org
@ 2020-08-25 17:44 ` cvs-commit at gcc dot gnu.org
  2020-09-16 19:22 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-25 17:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:fa6563471f5c9f96d2e446b15eb7aa770b4b4f17

commit r10-8662-gfa6563471f5c9f96d2e446b15eb7aa770b4b4f17
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Aug 5 10:40:10 2020 +0200

    openmp: Handle reduction clauses on host teams construct [PR96459]

    As the new testcase shows, we weren't actually performing reductions on
    host teams construct.  And fixing that revealed a flaw in the for-14.c
testcase.
    The problem is that the tests perform also initialization and checking
around the
    calls to the functions with the OpenMP constructs.  In that testcase, all
the
    tests have been spawned from a teams construct but only the tested loops
were
    distribute, which means the initialization and checking has been performed
    redundantly and racily in each team.  Fixed by performing the
initialization
    and checking outside of host teams and only do the calls to functions with
    the tested constructs inside of host teams.

    2020-08-05  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/96459
            * omp-low.c (lower_omp_taskreg): Call lower_reduction_clauses even
in
            for host teams.

            * testsuite/libgomp.c/teams-3.c: New test.
            * testsuite/libgomp.c-c++-common/for-2.h (OMPTEAMS): Define to
nothing
            if not defined yet.
            (N(test)): Use it before all N(f*) calls.
            * testsuite/libgomp.c-c++-common/for-14.c (DO_PRAGMA, OMPTEAMS):
Define.
            (main): Don't call all test_* functions from within
            #pragma omp teams reduction(|:err), call them directly.

    (cherry picked from commit 916c7a201a9a1dc94f2c056a773826a26d1daca9)

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

* [Bug middle-end/96459] OpenMP host teams reductions ignored
  2020-08-04 14:47 [Bug middle-end/96459] New: OpenMP host teams reductions ignored jakub at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-08-25 17:44 ` cvs-commit at gcc dot gnu.org
@ 2020-09-16 19:22 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-16 19:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:464ed899038051f80af1df7197e561f327502107

commit r9-8906-g464ed899038051f80af1df7197e561f327502107
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Aug 5 10:40:10 2020 +0200

    openmp: Handle reduction clauses on host teams construct [PR96459]

    As the new testcase shows, we weren't actually performing reductions on
    host teams construct.  And fixing that revealed a flaw in the for-14.c
testcase.
    The problem is that the tests perform also initialization and checking
around the
    calls to the functions with the OpenMP constructs.  In that testcase, all
the
    tests have been spawned from a teams construct but only the tested loops
were
    distribute, which means the initialization and checking has been performed
    redundantly and racily in each team.  Fixed by performing the
initialization
    and checking outside of host teams and only do the calls to functions with
    the tested constructs inside of host teams.

    2020-08-05  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/96459
            * omp-low.c (lower_omp_taskreg): Call lower_reduction_clauses even
in
            for host teams.

            * testsuite/libgomp.c/teams-3.c: New test.
            * testsuite/libgomp.c-c++-common/for-2.h (OMPTEAMS): Define to
nothing
            if not defined yet.
            (N(test)): Use it before all N(f*) calls.
            * testsuite/libgomp.c-c++-common/for-14.c (DO_PRAGMA, OMPTEAMS):
Define.
            (main): Don't call all test_* functions from within
            #pragma omp teams reduction(|:err), call them directly.

    (cherry picked from commit 916c7a201a9a1dc94f2c056a773826a26d1daca9)

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

end of thread, other threads:[~2020-09-16 19:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 14:47 [Bug middle-end/96459] New: OpenMP host teams reductions ignored jakub at gcc dot gnu.org
2020-08-04 14:49 ` [Bug middle-end/96459] " jakub at gcc dot gnu.org
2020-08-04 14:57 ` jakub at gcc dot gnu.org
2020-08-04 14:59 ` jakub at gcc dot gnu.org
2020-08-05  8:44 ` cvs-commit at gcc dot gnu.org
2020-08-25 17:44 ` cvs-commit at gcc dot gnu.org
2020-09-16 19:22 ` cvs-commit at gcc dot gnu.org

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).