public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgomp/109875] New: [OpenMP] nteams-var / OMP_NUM_TEAMS → ICV not passed to the device / default value
Date: Tue, 16 May 2023 17:39:28 +0000	[thread overview]
Message-ID: <bug-109875-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 109875
           Summary: [OpenMP] nteams-var / OMP_NUM_TEAMS → ICV not passed
                    to the device / default value
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: openmp
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

Related: https://github.com/SOLLVE/sollve_vv/pull/728 and
OpenMP Spec Issue 3619.

The following is with host fallback - and I might miss something because of
this.

However, I get only a single team with the following code;
even though max_num_teams == 3.

Replacing the set_num_teams by
  OMP_NUM_TEAMS=7 OMP_NUM_TEAMS_DEV=8
will yield the expected 7 for max_teams.

But it will still execute with a single team. — Using num_teams(3) as clause
will have an effect, however.

TODO:

* Check whether TEAMS = 1 makes sense for host fallback
  and what the result is with actual offloading.

EXPECTED:

* The value of the ICV is honored on the device side

* Possibly, the initial value should be not 0 but a different value,
  but that depends on the OpenMP Spec Issue 3619.

  NOTE: While the init value is now changed, as omp_get_max_teams()
  is confusingly written, just changing the default is undetectable
  inside the program as only omp_get_max_teams() or display-env can be
  used to determine the value - and the values returned by the latter
  is not really available for consumption inside of the program.

* On the host side, the default seems to be 3, given that there is:
    libgomp/teams.c:    num_teams = gomp_nteams_var ? gomp_nteams_var : 3;


It seems as if get_gomp_offload_icvs sets the ICV for the device but it does
not seem to get actually get used. – At least not for host fallback.


#include <omp.h>
int main ()
{
  int num_teams;
#if 1 // set to 0 to test the environment variables
  omp_set_num_teams(2);
  #pragma omp target
  omp_set_num_teams(3);
#endif

  __builtin_printf("max_teams: %d\n", omp_get_max_teams());
  #pragma omp target teams map(tofrom: num_teams) //num_teams(4)
        {
                if (omp_get_team_num() == 0) {
                        num_teams = omp_get_num_teams();
                }
        }               
  __builtin_printf("num_teams: %d\n", num_teams);
  return 0;
}

             reply	other threads:[~2023-05-16 17:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16 17:39 burnus at gcc dot gnu.org [this message]
2023-05-17  9:47 ` [Bug libgomp/109875] " burnus at gcc dot gnu.org
2023-05-17 10:11 ` burnus at gcc dot gnu.org
2023-05-21 18:44 ` cvs-commit at gcc dot gnu.org
2023-05-21 18:56 ` burnus at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109875-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).