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 via email to