public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/102972] New: [OpenMP] Strictly-nested diagnostic missing
@ 2021-10-27 20:32 burnus at gcc dot gnu.org
  2021-10-28 11:48 ` [Bug middle-end/102972] " burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-10-27 20:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102972
           Summary: [OpenMP] Strictly-nested diagnostic missing
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: openmp
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

Came up at https://github.com/SOLLVE/sollve_vv/issues/409

"17.1 Nesting of Regions" has the following (mirrored in the restriction
section for the teams construct):

"• distribute regions, including any distribute regions arising from composite
constructs,
parallel regions, including any parallel regions arising from combined
constructs, loop
regions, omp_get_num_teams() regions, and omp_get_team_num() regions are the
only OpenMP regions that may be strictly nested inside the teams region."

And it seems as if this is violated for the following:

#include <omp.h>

void foo(int *a, int N) {
  int is_initial = 0;
  #pragma omp target
    #pragma omp teams
    {
      is_initial = omp_is_initial_device();

      #pragma omp distribute parallel for
        for (int i = 0; i < N; i++) {
           a[i] = i;
        }
    }
}

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

* [Bug middle-end/102972] [OpenMP] Strictly-nested diagnostic missing
  2021-10-27 20:32 [Bug middle-end/102972] New: [OpenMP] Strictly-nested diagnostic missing burnus at gcc dot gnu.org
@ 2021-10-28 11:48 ` burnus at gcc dot gnu.org
  2021-10-30 21:46 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-10-28 11:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Created attachment 51688
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51688&action=edit
Draft patch

Patch works – but causes quite some fails in testsuites (at least in
https://github.com/clang-ykt/omptests).

Thus, I wonder whether it is (a) correct and, even if so, (b) it should be just
a warning? Or a downgradable error? I don't care about testsuites, but I fear
that it might also affect real-world code.

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

* [Bug middle-end/102972] [OpenMP] Strictly-nested diagnostic missing
  2021-10-27 20:32 [Bug middle-end/102972] New: [OpenMP] Strictly-nested diagnostic missing burnus at gcc dot gnu.org
  2021-10-28 11:48 ` [Bug middle-end/102972] " burnus at gcc dot gnu.org
@ 2021-10-30 21:46 ` cvs-commit at gcc dot gnu.org
  2022-10-20  8:46 ` burnus at gcc dot gnu.org
  2022-10-20  8:56 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-30 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:

https://gcc.gnu.org/g:948d461954f2642ca187f86c19d297ba7a86320f

commit r12-4809-g948d461954f2642ca187f86c19d297ba7a86320f
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Sat Oct 30 23:45:32 2021 +0200

    OpenMP: Add strictly nested API call check [PR102972]

    The teams construct only permits omp_get_num_teams and omp_get_team_num
    as API call in strictly nested regions - check for it.

    Additionally, for Fortran, using DECL_NAME does not show the mangled
    name, hence, DECL_ASSEMBLER_NAME had to be used to.

    Finally, 'target device(ancestor:1)' wrongly rejected non-API calls
    as well.

            PR middle-end/102972
    gcc/ChangeLog:

            * omp-low.c (omp_runtime_api_call): Use DECL_ASSEMBLER_NAME to get
            internal Fortran name; new permit_num_teams arg to permit
            omp_get_num_teams and omp_get_team_num.
            (scan_omp_1_stmt): Update call to it, add missing call for
            reverse offload, and check for strictly nested API calls in teams.

    gcc/testsuite/ChangeLog:

            * c-c++-common/gomp/target-device-ancestor-3.c: Add non-API
            routine test.
            * gfortran.dg/gomp/order-6.f90: Add missing bind(C).
            * c-c++-common/gomp/teams-3.c: New test.
            * gfortran.dg/gomp/teams-3.f90: New test.
            * gfortran.dg/gomp/teams-4.f90: New test.

    libgomp/ChangeLog:
            * testsuite/libgomp.c-c++-common/icv-3.c: Nest API calls inside
            parallel construct.
            * testsuite/libgomp.c-c++-common/icv-4.c: Likewise.
            * testsuite/libgomp.c/target-3.c: Likewise.
            * testsuite/libgomp.c/target-5.c: Likewise.
            * testsuite/libgomp.c/target-6.c: Likewise.
            * testsuite/libgomp.c/target-teams-1.c: Likewise.
            * testsuite/libgomp.c/teams-1.c: Likewise.
            * testsuite/libgomp.c/thread-limit-2.c: Likewise.
            * testsuite/libgomp.c/thread-limit-3.c: Likewise.
            * testsuite/libgomp.c/thread-limit-4.c: Likewise.
            * testsuite/libgomp.c/thread-limit-5.c: Likewise.
            * testsuite/libgomp.fortran/icv-3.f90: Likewise.
            * testsuite/libgomp.fortran/icv-4.f90: Likewise.
            * testsuite/libgomp.fortran/teams1.f90: Likewise.

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

* [Bug middle-end/102972] [OpenMP] Strictly-nested diagnostic missing
  2021-10-27 20:32 [Bug middle-end/102972] New: [OpenMP] Strictly-nested diagnostic missing burnus at gcc dot gnu.org
  2021-10-28 11:48 ` [Bug middle-end/102972] " burnus at gcc dot gnu.org
  2021-10-30 21:46 ` cvs-commit at gcc dot gnu.org
@ 2022-10-20  8:46 ` burnus at gcc dot gnu.org
  2022-10-20  8:56 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-10-20  8:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Besides the restriction on 'teams', there is also:

"Restrictions to the distribute construct are as follows:
...
• The region that corresponds to the distribute construct must be strictly
nested inside a teams region."

Example: a non-enclosed 'distribute':
https://github.com/SOLLVE/sollve_vv/blob/6e8dca8bcab429eb91924e349639b1f7de68ce95/tests/5.0/declare_variant/test_declare_variant.F90#L43-L52

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

* [Bug middle-end/102972] [OpenMP] Strictly-nested diagnostic missing
  2021-10-27 20:32 [Bug middle-end/102972] New: [OpenMP] Strictly-nested diagnostic missing burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-10-20  8:46 ` burnus at gcc dot gnu.org
@ 2022-10-20  8:56 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-10-20  8:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
strictly nested region in teams region doesn't preclude orphaned constructs, it
just means at runtime one can't call it when not inside of teams (host or
target)  or when nested inside of another OpenMP construct nside of teams.

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

end of thread, other threads:[~2022-10-20  8:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 20:32 [Bug middle-end/102972] New: [OpenMP] Strictly-nested diagnostic missing burnus at gcc dot gnu.org
2021-10-28 11:48 ` [Bug middle-end/102972] " burnus at gcc dot gnu.org
2021-10-30 21:46 ` cvs-commit at gcc dot gnu.org
2022-10-20  8:46 ` burnus at gcc dot gnu.org
2022-10-20  8:56 ` jakub 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).