[Openmp-commits] [PATCH] D95820: [OpenMP] Add bounds to num_teams clause (OpenMP 5.1)

Andrey Churbanov via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Feb 4 06:07:13 PST 2021


AndreyChurbanov added inline comments.


================
Comment at: openmp/runtime/src/kmp_runtime.cpp:7537
+      num_teams = __kmp_teams_max_nth;
+    }
+  } else if (num_teams_lb == num_teams_ub) { // required exact number of teams
----------------
jdoerfert wrote:
> Nawrin wrote:
> > jdoerfert wrote:
> > > IIRC, this is not correct anymore in 5.1. We cannot cap the number of teams. We need to implement a loop if the number of physical teams is smaller than the number requested teams to basically emulate as many as have been requested.
> > According to the spec, when num_teams clause is not present, the number of teams created should be implementation defined, but it will be greater or equal to 1.
> > 
> > 5.1 spec - "If the num_teams clause is not specified and the value of the nteams-var ICV is greater than zero, the number of teams created is less or equal to the value of the nteams-var ICV. Otherwise, the number of teams created is implementation defined, but it will be greater than or equal to 1."
> I'm not arguing against that. What I'm trying to say is that we cannot cap the number of teams. So we cannot do `nteams = min(nteams, __kmp_teams_max_nth)`.
> 
> OpenMP 5.1 says, you get a number between the lower and upper bound. So if the lower bound is not smaller or equal than `__kmp_teams_max_nth`, we cannot cap at `__kmp_teams_max_nth`. This is explicitly different from num_threads on a parallel. For example, to implement N teams with a single thread, e.g., if `__kmp_teams_max_nth` was `1`, you would do something like this:
> ```
> for (unsigned team_no = 0; team_no < num_teams_requested; ++team_no) {
>   set_team_no_for_thread(team_no);
>   execute_team_body();
> }
> ```
> 
> I'm not arguing against that. What I'm trying to say is that we cannot cap the number of teams. So we cannot do `nteams = min(nteams, __kmp_teams_max_nth)`.
Why?  Once the specification allows to choose any number of teams, why would we complicate things without the need?

> OpenMP 5.1 says, you get a number between the lower and upper bound. So if the lower bound is not smaller or equal than `__kmp_teams_max_nth`, we cannot cap at `__kmp_teams_max_nth`.
Right. But this is not the case in this code branch.  Here we have neither lower nor upper bound.

We don't cap the number of teams when we have lower and/or upper bound.  But again, it is not the case here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95820/new/

https://reviews.llvm.org/D95820



More information about the Openmp-commits mailing list