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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The host-fallback explicitly sets the number of teams to the lower_bound,
if available, and otherwise to 1 - which is fine.

Regarding changing the default from 0 to the actually used number,
the problem is on the device side it is only known at runtime
→ issue with OMP_DISPLAY_ENV.
BTW, the "[host] OMP_NUM_TEAMS = '0'" should be "[all] OMP_NUM_TEAMS = '0'
for the default.

For the device side, I think we need (untested):

--- a/libgomp/config/gcn/target.c
+++ b/libgomp/config/gcn/target.c
@@ -51 +51,3 @@ GOMP_teams4 (unsigned int num_teams_lower, unsigned int -   
num_teams_upper = num_workgroups;
+    num_teams_upper = ((GOMP_ADDITIONAL_ICVS.nteams > 0
+                       && num_workgroups > GOMP_ADDITIONAL_ICVS.nteams)
+                      ? GOMP_ADDITIONAL_ICVS.nteams : num_workgroups);
diff --git a/libgomp/config/nvptx/target.c b/libgomp/config/nvptx/target.c
index f102d7d02d9..125d92a2ea9 100644
--- a/libgomp/config/nvptx/target.c
+++ b/libgomp/config/nvptx/target.c
@@ -58 +58,3 @@ GOMP_teams4 (unsigned int num_teams_lower, unsigned int 
-    num_teams_upper = num_blocks;
+    num_teams_upper = ((GOMP_ADDITIONAL_ICVS.nteams > 0
+                       && num_blocks > GOMP_ADDITIONAL_ICVS.nteams)
+                      ? GOMP_ADDITIONAL_ICVS.nteams : num_blocks);

Reply via email to