Hi!

This adds (C/C++ only) testsuite coverage for these new OpenMP 5.1 APIs.

Regtested on x86_64-linux and i686-linux, committed to trunk.

2021-10-12  Jakub Jelinek  <ja...@redhat.com>

        * testsuite/libgomp.c-c++-common/icv-3.c: New test.
        * testsuite/libgomp.c-c++-common/icv-4.c: New test.

--- libgomp/testsuite/libgomp.c-c++-common/icv-3.c.jj   2021-10-11 
17:16:35.455296745 +0200
+++ libgomp/testsuite/libgomp.c-c++-common/icv-3.c      2021-10-11 
17:19:14.358023413 +0200
@@ -0,0 +1,54 @@
+#include <omp.h>
+#include <stdlib.h>
+
+int
+main ()
+{
+  if (getenv ("OMP_NUM_TEAMS") == NULL
+      && omp_get_max_teams () != 0)
+    abort ();
+  omp_set_num_teams (7);
+  if (omp_get_max_teams () != 7)
+    abort ();
+  if (getenv ("OMP_TEAMS_THREAD_LIMIT") == NULL
+      && omp_get_teams_thread_limit () != 0)
+    abort ();
+  omp_set_teams_thread_limit (15);
+  if (omp_get_teams_thread_limit () != 15)
+    abort ();
+  #pragma omp teams
+  {
+    if (omp_get_max_teams () != 7
+       || omp_get_teams_thread_limit () != 15
+       || omp_get_num_teams () < 1
+       || omp_get_num_teams () > 7
+       || omp_get_team_num () < 0
+       || omp_get_team_num () >= omp_get_num_teams ()
+       || omp_get_thread_limit () < 1
+       || omp_get_thread_limit () > 15)
+      abort ();
+  }
+  #pragma omp teams num_teams(5) thread_limit (13)
+  {
+    if (omp_get_max_teams () != 7
+       || omp_get_teams_thread_limit () != 15
+       || omp_get_num_teams () != 5
+       || omp_get_team_num () < 0
+       || omp_get_team_num () >= omp_get_num_teams ()
+       || omp_get_thread_limit () < 1
+       || omp_get_thread_limit () > 13)
+      abort ();
+  }
+  #pragma omp teams num_teams(8) thread_limit (16)
+  {
+    if (omp_get_max_teams () != 7
+       || omp_get_teams_thread_limit () != 15
+       || omp_get_num_teams () != 8
+       || omp_get_team_num () < 0
+       || omp_get_team_num () >= omp_get_num_teams ()
+       || omp_get_thread_limit () < 1
+       || omp_get_thread_limit () > 16)
+      abort ();
+  }
+  return 0;
+}
--- libgomp/testsuite/libgomp.c-c++-common/icv-4.c.jj   2021-10-11 
17:17:22.963617081 +0200
+++ libgomp/testsuite/libgomp.c-c++-common/icv-4.c      2021-10-11 
17:22:35.797141533 +0200
@@ -0,0 +1,40 @@
+/* { dg-set-target-env-var OMP_NUM_TEAMS "6" } */
+/* { dg-set-target-env-var OMP_TEAMS_THREAD_LIMIT "12" } */
+
+#include <omp.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main ()
+{
+  if (getenv ("OMP_NUM_TEAMS") != NULL
+      && strcmp (getenv ("OMP_NUM_TEAMS"), "6") == 0)
+    {
+      if (omp_get_max_teams () != 6)
+       abort ();
+    }
+  else
+    omp_set_num_teams (6);
+  if (getenv ("OMP_TEAMS_THREAD_LIMIT") == NULL
+      && strcmp (getenv ("OMP_TEAMS_THREAD_LIMIT"), "12") == 0)
+    {
+      if (omp_get_teams_thread_limit () != 12)
+       abort ();
+    }
+  else
+    omp_set_teams_thread_limit (12);
+  #pragma omp teams
+  {
+    if (omp_get_max_teams () != 6
+       || omp_get_teams_thread_limit () != 12
+       || omp_get_num_teams () < 1
+       || omp_get_num_teams () > 6
+       || omp_get_team_num () < 0
+       || omp_get_team_num () >= omp_get_num_teams ()
+       || omp_get_thread_limit () < 1
+       || omp_get_thread_limit () > 12)
+      abort ();
+  }
+  return 0;
+}

        Jakub

Reply via email to