]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Pass iteration count to static worksharing builtins for OMPT
authorPaul-Antoine Arras <parras@baylibre.com>
Wed, 1 Jul 2026 16:51:07 +0000 (18:51 +0200)
committerThomas Schwinge <tschwinge@baylibre.com>
Thu, 9 Jul 2026 22:06:31 +0000 (00:06 +0200)
Add parameter to GOMP_{loop,distribute}_static_worksharing{,_start} carrying the
total number of loop iterations. niter is unused for now, pending OMPT
implementation.

The call in omp-expand.cc is moved after the iteration count computation
so that the iteration count is available to pass as the argument.

gcc/ChangeLog:

* builtin-types.def (BT_FN_COMPLEX_INT): Remove.
(BT_FN_COMPLEX_INT_ULONGLONG): New.
* omp-builtins.def (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING): Use
BT_FN_COMPLEX_INT_ULONGLONG.
(BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START): Likewise.
(BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING): Likewise.
(BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START): Likewise.
* omp-expand.cc (expand_omp_for_static_nochunk): Move worksharing
builtin call after iteration count computation; pass n as niter.
(expand_omp_for_static_chunk): Likewise.

gcc/fortran/ChangeLog:

* types.def (BT_FN_COMPLEX_INT): Remove.
(BT_FN_COMPLEX_INT_ULONGLONG): New.

libgomp/ChangeLog:

* config/gcn/teams.c (GOMP_distribute_static_worksharing): Add
long niter parameter (unused).
(GOMP_distribute_static_worksharing_start): Likewise.
* config/nvptx/teams.c (GOMP_distribute_static_worksharing):
Likewise.
(GOMP_distribute_static_worksharing_start): Likewise.
* libgomp.texi: Update function signatures; fix real/imaginary
description; document niter parameter.
* libgomp_g.h (GOMP_loop_static_worksharing): Update prototype.
(GOMP_distribute_static_worksharing): Likewise.
* loop.c (GOMP_loop_static_worksharing): Add long niter parameter
(unused).
(GOMP_loop_static_worksharing_start): Likewise.
* teams.c (GOMP_distribute_static_worksharing): Likewise.
(GOMP_distribute_static_worksharing_start): Likewise.
* testsuite/libgomp.c-c++-common/for-static-1.c: Update scan
pattern to match niter argument.
* testsuite/libgomp.c-c++-common/for-static-2.c: Likewise.
* testsuite/libgomp.c-c++-common/for-static-3.c: Likewise.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/for-static-1.c: Update scan pattern to match
niter argument.
* c-c++-common/gomp/for-static-2.c: Likewise.
* c-c++-common/gomp/for-static-3.c: Likewise.

Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
16 files changed:
gcc/builtin-types.def
gcc/fortran/types.def
gcc/omp-builtins.def
gcc/omp-expand.cc
gcc/testsuite/c-c++-common/gomp/for-static-1.c
gcc/testsuite/c-c++-common/gomp/for-static-2.c
gcc/testsuite/c-c++-common/gomp/for-static-3.c
libgomp/config/gcn/teams.c
libgomp/config/nvptx/teams.c
libgomp/libgomp.texi
libgomp/libgomp_g.h
libgomp/loop.c
libgomp/teams.c
libgomp/testsuite/libgomp.c-c++-common/for-static-1.c
libgomp/testsuite/libgomp.c-c++-common/for-static-2.c
libgomp/testsuite/libgomp.c-c++-common/for-static-3.c

index 55ed6f0cae10a1ecc3dbba581c622b1404701221..d11e6e736a2b7776f2d7f0e9c9387ecafbe15a9a 100644 (file)
@@ -236,7 +236,6 @@ DEF_FUNCTION_TYPE_0 (BT_FN_CONST_STRING, BT_CONST_STRING)
 DEF_FUNCTION_TYPE_0 (BT_FN_PID, BT_PID)
 DEF_FUNCTION_TYPE_0 (BT_FN_INT, BT_INT)
 DEF_FUNCTION_TYPE_0 (BT_FN_UINT, BT_UINT)
-DEF_FUNCTION_TYPE_0 (BT_FN_COMPLEX_INT, BT_COMPLEX_INT)
 DEF_FUNCTION_TYPE_0 (BT_FN_ULONG, BT_ULONG)
 DEF_FUNCTION_TYPE_0 (BT_FN_ULONGLONG, BT_ULONGLONG)
 DEF_FUNCTION_TYPE_0 (BT_FN_FLOAT, BT_FLOAT)
@@ -429,6 +428,7 @@ DEF_FUNCTION_TYPE_1 (BT_FN_UINT16_UINT32, BT_UINT16, BT_UINT32)
 DEF_FUNCTION_TYPE_1 (BT_FN_UINT32_UINT16, BT_UINT32, BT_UINT16)
 DEF_FUNCTION_TYPE_1 (BT_FN_INT_FENV_T_PTR, BT_INT, BT_FENV_T_PTR)
 DEF_FUNCTION_TYPE_1 (BT_FN_INT_CONST_FENV_T_PTR, BT_INT, BT_CONST_FENV_T_PTR)
+DEF_FUNCTION_TYPE_1 (BT_FN_COMPLEX_INT_ULONGLONG, BT_COMPLEX_INT, BT_ULONGLONG)
 
 DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR, BT_FN_VOID_PTR)
 
index 6f98e3e48ffaad78d82b56d4071fb7ccbba13179..b694e6893600cfbfb9d597f4bb86fa0007e2b047 100644 (file)
@@ -77,7 +77,6 @@ DEF_POINTER_TYPE (BT_PTR_PTR, BT_PTR)
 DEF_FUNCTION_TYPE_0 (BT_FN_BOOL, BT_BOOL)
 DEF_FUNCTION_TYPE_0 (BT_FN_PTR, BT_PTR)
 DEF_FUNCTION_TYPE_0 (BT_FN_INT, BT_INT)
-DEF_FUNCTION_TYPE_0 (BT_FN_COMPLEX_INT, BT_COMPLEX_INT)
 DEF_FUNCTION_TYPE_0 (BT_FN_UINT, BT_UINT)
 DEF_FUNCTION_TYPE_0 (BT_FN_VOID, BT_VOID)
 DEF_FUNCTION_TYPE_0 (BT_FN_ULONGLONG, BT_ULONGLONG)
@@ -91,6 +90,7 @@ DEF_FUNCTION_TYPE_1 (BT_FN_PTR_PTR, BT_PTR, BT_PTR)
 DEF_FUNCTION_TYPE_1 (BT_FN_VOID_INT, BT_VOID, BT_INT)
 DEF_FUNCTION_TYPE_1 (BT_FN_VOID_BOOL, BT_VOID, BT_BOOL)
 DEF_FUNCTION_TYPE_1 (BT_FN_BOOL_INT, BT_BOOL, BT_INT)
+DEF_FUNCTION_TYPE_1 (BT_FN_COMPLEX_INT_ULONGLONG, BT_COMPLEX_INT, BT_ULONGLONG)
 
 DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR, BT_FN_VOID_PTR)
 
index 465aeebefdb74aa5e3ef7a0ce1bd59caddf34b19..3b0d5572043a70ac8e90de5edae2d14d73383b0d 100644 (file)
@@ -510,11 +510,14 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_HAS_MASKED_THREAD_NUM,
                  ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_MASKED_END, "GOMP_masked_end", BT_FN_VOID,
                  ATTR_NOTHROW_LEAF_LIST)
+/* TODO review these function attributes once OMPT implementation done  */
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING,
-                 "GOMP_loop_static_worksharing", BT_FN_COMPLEX_INT,
+                 "GOMP_loop_static_worksharing",
+                 BT_FN_COMPLEX_INT_ULONGLONG,
                  ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START,
-                 "GOMP_loop_static_worksharing_start", BT_FN_COMPLEX_INT,
+                 "GOMP_loop_static_worksharing_start",
+                 BT_FN_COMPLEX_INT_ULONGLONG,
                  ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_END,
                  "GOMP_loop_static_worksharing_end", BT_FN_VOID,
@@ -523,10 +526,12 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_DISPATCH,
                  "GOMP_loop_static_worksharing_dispatch", BT_FN_VOID,
                  ATTR_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING,
-                 "GOMP_distribute_static_worksharing", BT_FN_COMPLEX_INT,
+                 "GOMP_distribute_static_worksharing",
+                 BT_FN_COMPLEX_INT_ULONGLONG,
                  ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START,
-                 "GOMP_distribute_static_worksharing_start", BT_FN_COMPLEX_INT,
+                 "GOMP_distribute_static_worksharing_start",
+                 BT_FN_COMPLEX_INT_ULONGLONG,
                  ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_END,
                  "GOMP_distribute_static_worksharing_end", BT_FN_VOID,
index ad380b27d06270d5649086fcea5b5138553ee791..388f84eddff0447633df8f4307e92e3804657b18 100644 (file)
@@ -5190,42 +5190,6 @@ expand_omp_for_static_nochunk (struct omp_region *region,
          release_ssa_name (gimple_assign_lhs (g));
        }
     }
-  /* Fetch the thread/team id and the number of threads/teams in a single
-     call to GOMP_loop_static_worksharing or GOMP_distribute_static_worksharing.
-     The helper returns both values packed into one complex int, with
-     the id as the imaginary part and the count as the real part.  Returning
-     (rather than writing through pointers) keeps both values as plain SSA
-     names, which lets later passes - notably IPA-CP propagating constants
-     into the outlined kernel - reason about them.  */
-  tree decl;
-  switch (gimple_omp_for_kind (fd->for_stmt))
-    {
-    case GF_OMP_FOR_KIND_FOR:
-      decl = builtin_decl_explicit (
-       flag_openmp_ompt ? BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START
-                        : BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING);
-      break;
-    case GF_OMP_FOR_KIND_DISTRIBUTE:
-      decl = builtin_decl_explicit (
-       flag_openmp_ompt ? BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START
-                        : BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING);
-      break;
-    default:
-      gcc_unreachable ();
-    }
-  {
-    tree packed = build_call_expr (decl, 0);
-    packed = force_gimple_operand_gsi (&gsi, packed, true, NULL_TREE,
-                                      true, GSI_SAME_STMT);
-    threadid = fold_build1 (IMAGPART_EXPR, integer_type_node, packed);
-    threadid = fold_convert (itype, threadid);
-    threadid = force_gimple_operand_gsi (&gsi, threadid, true, NULL_TREE,
-                                        true, GSI_SAME_STMT);
-    nthreads = fold_build1 (REALPART_EXPR, integer_type_node, packed);
-    nthreads = fold_convert (itype, nthreads);
-    nthreads = force_gimple_operand_gsi (&gsi, nthreads, true, NULL_TREE,
-                                        true, GSI_SAME_STMT);
-  }
 
   n1 = fd->loop.n1;
   n2 = fd->loop.n2;
@@ -5261,6 +5225,45 @@ expand_omp_for_static_nochunk (struct omp_region *region,
   t = fold_convert (itype, t);
   n = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true, GSI_SAME_STMT);
 
+  {
+    /* Fetch the thread/team id and the number of threads/teams in a single
+       call to GOMP_loop_static_worksharing or
+       GOMP_distribute_static_worksharing. The helper returns both values packed
+       into one complex int, with the id as the imaginary part and the count as
+       the real part.  Returning (rather than writing through pointers) keeps
+       both values as plain SSA names, which lets later passes - notably IPA-CP
+       propagating constants into the outlined kernel - reason about them.
+       Also pass the total number of iterations for OMPT.  */
+    tree decl;
+    switch (gimple_omp_for_kind (fd->for_stmt))
+      {
+      case GF_OMP_FOR_KIND_FOR:
+       decl = builtin_decl_explicit (
+         flag_openmp_ompt ? BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START
+                          : BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING);
+       break;
+      case GF_OMP_FOR_KIND_DISTRIBUTE:
+       decl = builtin_decl_explicit (
+         flag_openmp_ompt ? BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START
+                          : BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING);
+       break;
+      default:
+       gcc_unreachable ();
+      }
+    tree n_ull = fold_convert (long_long_unsigned_type_node, n);
+    tree packed = build_call_expr (decl, 1, n_ull);
+    packed = force_gimple_operand_gsi (&gsi, packed, true, NULL_TREE,
+                                      true, GSI_SAME_STMT);
+    threadid = fold_build1 (IMAGPART_EXPR, integer_type_node, packed);
+    threadid = fold_convert (itype, threadid);
+    threadid = force_gimple_operand_gsi (&gsi, threadid, true, NULL_TREE,
+                                        true, GSI_SAME_STMT);
+    nthreads = fold_build1 (REALPART_EXPR, integer_type_node, packed);
+    nthreads = fold_convert (itype, nthreads);
+    nthreads = force_gimple_operand_gsi (&gsi, nthreads, true, NULL_TREE,
+                                        true, GSI_SAME_STMT);
+  }
+
   q = create_tmp_reg (itype, "q");
   t = fold_build2 (TRUNC_DIV_EXPR, itype, n, nthreads);
   t = force_gimple_operand_gsi (&gsi, t, false, NULL_TREE, true, GSI_SAME_STMT);
@@ -6008,42 +6011,6 @@ expand_omp_for_static_chunk (struct omp_region *region,
          release_ssa_name (gimple_assign_lhs (g));
        }
     }
-  /* Fetch the thread/team id and the number of threads/teams in a single
-     call to GOMP_loop_static_worksharing or GOMP_distribute_static_worksharing.
-     The helper returns both values packed into one complex int, with
-     the id as the imaginary part and the count as the real part.  Returning
-     (rather than writing through pointers) keeps both values as plain SSA
-     names, which lets later passes - notably IPA-CP propagating constants
-     into the outlined kernel - reason about them.  */
-  tree decl;
-  switch (gimple_omp_for_kind (fd->for_stmt))
-    {
-    case GF_OMP_FOR_KIND_FOR:
-      decl = builtin_decl_explicit (
-       flag_openmp_ompt ? BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START
-                        : BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING);
-      break;
-    case GF_OMP_FOR_KIND_DISTRIBUTE:
-      decl = builtin_decl_explicit (
-       flag_openmp_ompt ? BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START
-                        : BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING);
-      break;
-    default:
-      gcc_unreachable ();
-    }
-  {
-    tree packed = build_call_expr (decl, 0);
-    packed = force_gimple_operand_gsi (&gsi, packed, true, NULL_TREE,
-                                      true, GSI_SAME_STMT);
-    threadid = fold_build1 (IMAGPART_EXPR, integer_type_node, packed);
-    threadid = fold_convert (itype, threadid);
-    threadid = force_gimple_operand_gsi (&gsi, threadid, true, NULL_TREE,
-                                        true, GSI_SAME_STMT);
-    nthreads = fold_build1 (REALPART_EXPR, integer_type_node, packed);
-    nthreads = fold_convert (itype, nthreads);
-    nthreads = force_gimple_operand_gsi (&gsi, nthreads, true, NULL_TREE,
-                                        true, GSI_SAME_STMT);
-  }
 
   n1 = fd->loop.n1;
   n2 = fd->loop.n2;
@@ -6086,6 +6053,45 @@ expand_omp_for_static_chunk (struct omp_region *region,
   n = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
                                true, GSI_SAME_STMT);
 
+  {
+    /* Fetch the thread/team id and the number of threads/teams in a single
+       call to GOMP_loop_static_worksharing or
+       GOMP_distribute_static_worksharing. The helper returns both values packed
+       into one complex int, with the id as the imaginary part and the count as
+       the real part.  Returning (rather than writing through pointers) keeps
+       both values as plain SSA names, which lets later passes - notably IPA-CP
+       propagating constants into the outlined kernel - reason about them.
+       Also pass the total number of iterations for OMPT.  */
+    tree decl;
+    switch (gimple_omp_for_kind (fd->for_stmt))
+      {
+      case GF_OMP_FOR_KIND_FOR:
+       decl = builtin_decl_explicit (
+         flag_openmp_ompt ? BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START
+                          : BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING);
+       break;
+      case GF_OMP_FOR_KIND_DISTRIBUTE:
+       decl = builtin_decl_explicit (
+         flag_openmp_ompt ? BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START
+                          : BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING);
+       break;
+      default:
+       gcc_unreachable ();
+      }
+    tree n_ull = fold_convert (long_long_unsigned_type_node, n);
+    tree packed = build_call_expr (decl, 1, n_ull);
+    packed = force_gimple_operand_gsi (&gsi, packed, true, NULL_TREE, true,
+                                      GSI_SAME_STMT);
+    threadid = fold_build1 (IMAGPART_EXPR, integer_type_node, packed);
+    threadid = fold_convert (itype, threadid);
+    threadid = force_gimple_operand_gsi (&gsi, threadid, true, NULL_TREE, true,
+                                        GSI_SAME_STMT);
+    nthreads = fold_build1 (REALPART_EXPR, integer_type_node, packed);
+    nthreads = fold_convert (itype, nthreads);
+    nthreads = force_gimple_operand_gsi (&gsi, nthreads, true, NULL_TREE, true,
+                                        GSI_SAME_STMT);
+  }
+
   trip_var = create_tmp_reg (itype, ".trip");
   if (gimple_in_ssa_p (cfun))
     {
index 50d4e176f3d8ce8021df1c1eb82fc7048b77c832..09e533c931dd787ebc5d619db51a9d897b4ba9a1 100644 (file)
@@ -9,8 +9,11 @@
 
 #include "for-static.h"
 
-/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing \\(" 2 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing \\(" 2 "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing \\(\[^\\)\]" 2 "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "GOMP_loop_static_worksharing_start" "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "GOMP_loop_static_worksharing_dispatch" "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "GOMP_loop_static_worksharing_end" "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing \\(\[^\\)\]" 2 "ompexp" } } */
 /* { dg-final { scan-tree-dump-not "omp_get_num_threads" "ompexp" } } */
 /* { dg-final { scan-tree-dump-not "omp_get_thread_num" "ompexp" } } */
 /* { dg-final { scan-tree-dump-not "omp_get_num_teams" "ompexp" } } */
index c3d25b97bed7946cea9167d859a0409106bc6b08..d99f59d7471e789dedd9f230b4f2bc42f4425a2c 100644 (file)
@@ -5,11 +5,15 @@
 
 #include "for-static.h"
 
-/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_start \\(" 2 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_end \\(" 2 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_start \\(" 2 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_end \\(" 2 "ompexp" } } */
 /* { dg-final { scan-tree-dump-not "GOMP_loop_static_worksharing \\(" "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_start \\(\[^\\)\]" 2 "ompexp" } } */
 /* { dg-final { scan-tree-dump-not "GOMP_loop_static_worksharing_dispatch" "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_end \\(\\)" 2 "ompexp" } } */
 /* { dg-final { scan-tree-dump-not "GOMP_distribute_static_worksharing \\(" "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_start \\(\[^\\)\]" 2 "ompexp" } } */
 /* { dg-final { scan-tree-dump-not "GOMP_distribute_static_worksharing_dispatch" "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_end \\(\\)" 2 "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "omp_get_num_threads" "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "omp_get_thread_num" "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "omp_get_num_teams" "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "omp_get_team_num" "ompexp" } } */
index 6fd1da6c4075bea9f9591d3c2176a0a637f041f7..8e45223c3538f54e8997ff866f58394ba42e98d6 100644 (file)
@@ -6,9 +6,15 @@
 
 #include "for-static.h"
 
-/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_start \\(" 2 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_dispatch \\(" 2 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_end \\(" 2 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_start \\(" 2 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_dispatch \\(" 2 "ompexp" } } */
-/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_end \\(" 2 "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "GOMP_loop_static_worksharing \\(" "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_start \\(\[^\\)\]" 2 "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_dispatch \\(\\)" 2 "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_end \\(\\)" 2 "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "GOMP_distribute_static_worksharing \\(" "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_start \\(\[^\\)\]" 2 "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_dispatch \\(\\)" 2 "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_end \\(\\)" 2 "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "omp_get_num_threads" "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "omp_get_thread_num" "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "omp_get_num_teams" "ompexp" } } */
+/* { dg-final { scan-tree-dump-not "omp_get_team_num" "ompexp" } } */
index 99f807ac87661e1ab21ad7d075817f178aa4d0cb..4354131f9b768037a25f335db969ff899eed399f 100644 (file)
@@ -39,10 +39,12 @@ GOMP_teams_reg (void (*fn) (void *), void *data, unsigned int num_teams,
 }
 
 /* For a distribute construct with static schedule, return the team ID and
-   number of teams packed into a single complexvalue.  */
+   number of teams packed into a single complex value. NITER is the total
+   number of iterations.  */
 
 _Complex int
-GOMP_distribute_static_worksharing (void)
+GOMP_distribute_static_worksharing (unsigned long long niter
+                                   __attribute__ ((unused)))
 {
   int __lds *gomp_team_num = (int __lds *) GOMP_TEAM_NUM;
   unsigned tid = *gomp_team_num;
@@ -53,7 +55,8 @@ GOMP_distribute_static_worksharing (void)
 /* OMPT variant enabled by -fopenmp-ompt.  */
 
 _Complex int
-GOMP_distribute_static_worksharing_start (void)
+GOMP_distribute_static_worksharing_start (unsigned long long niter
+                                         __attribute__ ((unused)))
 {
   int __lds *gomp_team_num = (int __lds *) GOMP_TEAM_NUM;
   unsigned tid = *gomp_team_num;
index 3e6ea2872766312a272babe3335edf3f11c9d637..e04f8bbbdb1458e8b35a40977be49d2440c826d6 100644 (file)
@@ -42,10 +42,12 @@ GOMP_teams_reg (void (*fn) (void *), void *data, unsigned int num_teams,
 }
 
 /* For a distribute construct with static schedule, return the team ID and
-   number of teams packed into a single complexvalue.  */
+   number of teams packed into a single complex value. NITER is the total
+   number of iterations.  */
 
 _Complex int
-GOMP_distribute_static_worksharing (void)
+GOMP_distribute_static_worksharing (unsigned long long niter
+                                   __attribute__ ((unused)))
 {
   unsigned tid = __gomp_team_num;
   unsigned nteams = gomp_num_teams_var + 1;
@@ -55,7 +57,8 @@ GOMP_distribute_static_worksharing (void)
 /* OMPT variant enabled by -fopenmp-ompt.  */
 
 _Complex int
-GOMP_distribute_static_worksharing_start (void)
+GOMP_distribute_static_worksharing_start (unsigned long long niter
+                                         __attribute__ ((unused)))
 {
   unsigned tid = __gomp_team_num;
   unsigned nteams = gomp_num_teams_var + 1;
index 83b90e6dc53a85ed4e3751c62481d40d913621d4..5d29da0984d965cc7c7de9b265573b26a075c365 100644 (file)
@@ -8318,17 +8318,18 @@ but since its supposed to remain unchanged, we can also not if we like.
 For @code{schedule(static)} without @code{ordered}, the compiler uses:
 
 @smallexample
-  _Complex int GOMP_loop_static_worksharing (void)
+  _Complex int GOMP_loop_static_worksharing (unsigned long long)
 @end smallexample
 
-which returns the thread id in the real part and the thread count in the imaginary
-part as a single value, avoiding separate @code{omp_get_thread_num} /
+which returns the thread id in the imaginary part and the thread count in the
+real part as a single value, avoiding separate @code{omp_get_thread_num} /
 @code{omp_get_num_threads} calls that OMPT cannot distinguish from user queries.
+For OMPT, the total number of loop iterations is passed as argument.
 
 Similarly, for @code{distribute} constructs:
 
 @smallexample
-  _Complex int GOMP_distribute_static_worksharing (void)
+  _Complex int GOMP_distribute_static_worksharing (unsigned long long)
 @end smallexample
 
 returns the team id and team count.
index 4a3565684cc955febfbbc76b0ffc10ef567bf283..27d0db8c93bbf821a1e8fe11217252eb2b28fb4f 100644 (file)
@@ -144,8 +144,8 @@ extern void GOMP_loop_end (void);
 extern void GOMP_loop_end_nowait (void);
 extern bool GOMP_loop_end_cancel (void);
 
-extern __complex__ int GOMP_loop_static_worksharing (void);
-extern __complex__ int GOMP_loop_static_worksharing_start (void);
+extern _Complex int GOMP_loop_static_worksharing (unsigned long long);
+extern _Complex int GOMP_loop_static_worksharing_start (unsigned long long);
 extern void GOMP_loop_static_worksharing_dispatch (void);
 extern void GOMP_loop_static_worksharing_end (void);
 
@@ -386,8 +386,8 @@ extern void *GOMP_target_map_indirect_ptr (void *);
 
 extern void GOMP_teams_reg (void (*) (void *), void *, unsigned, unsigned,
                            unsigned);
-extern __complex__ int GOMP_distribute_static_worksharing (void);
-extern __complex__ int GOMP_distribute_static_worksharing_start (void);
+extern _Complex int GOMP_distribute_static_worksharing (unsigned long long);
+extern _Complex int GOMP_distribute_static_worksharing_start (unsigned long long);
 extern void GOMP_distribute_static_worksharing_dispatch (void);
 extern void GOMP_distribute_static_worksharing_end (void);
 
index f286ce6b6db58f76ec3af2f94ddfe303caa11334..f4d962667741edc00bd34dfa94988e921b35550b 100644 (file)
@@ -1188,10 +1188,12 @@ GOMP_loop_ordered_guided_next (long *istart, long *iend)
 #endif
 
 /* For a worksharing-loop construct with static schedule, return the thread ID
-   and number of threads packed into a single complex value.  */
+   and number of threads packed into a single complex value. NITER is the total
+   number of iterations.  */
 
 _Complex int
-GOMP_loop_static_worksharing (void)
+GOMP_loop_static_worksharing (unsigned long long niter
+                             __attribute__ ((unused)))
 {
   struct gomp_team *team = gomp_thread ()->ts.team;
   unsigned tid = gomp_thread ()->ts.team_id;
@@ -1202,7 +1204,8 @@ GOMP_loop_static_worksharing (void)
 /* OMPT variant enabled by -fopenmp-ompt.  */
 
 _Complex int
-GOMP_loop_static_worksharing_start (void)
+GOMP_loop_static_worksharing_start (unsigned long long niter
+                                   __attribute__ ((unused)))
 {
   struct gomp_team *team = gomp_thread ()->ts.team;
   unsigned tid = gomp_thread ()->ts.team_id;
index f501123d6479d5eb99b935706d76dd1c58fa4de0..71c40ef5b466af6e2121292e8786d941146ca24f 100644 (file)
@@ -59,10 +59,12 @@ GOMP_teams_reg (void (*fn) (void *), void *data, unsigned int num_teams,
 }
 
 /* For a distribute construct with static schedule, return the team ID and
-   number of teams packed into a single complex value.  */
+   number of teams packed into a single complex value. NITER is the total
+   number of iterations.  */
 
 _Complex int
-GOMP_distribute_static_worksharing (void)
+GOMP_distribute_static_worksharing (unsigned long long
+                                   niter __attribute__ ((unused)))
 {
   struct gomp_thread *thr = gomp_thread ();
   unsigned tid = thr->team_num;
@@ -73,7 +75,8 @@ GOMP_distribute_static_worksharing (void)
 /* OMPT variant enabled by -fopenmp-ompt.  */
 
 _Complex int
-GOMP_distribute_static_worksharing_start (void)
+GOMP_distribute_static_worksharing_start (unsigned long long
+                                         niter __attribute__ ((unused)))
 {
   struct gomp_thread *thr = gomp_thread ();
   unsigned tid = thr->team_num;
index b304c8c10ecc3ea3960e7b57c9ca921ccb5fdf6e..2eb63e3d1ad95f6d644788abf4af36055b948879 100644 (file)
@@ -8,6 +8,6 @@
 
 #include "for-static.h"
 
-/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing \\(" 2 "optimized" } } */
+/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing \\(\[^\\)\]" 2 "optimized" } } */
 /* { dg-final { scan-offload-tree-dump-not "omp_get_num_teams" "optimized" } } */
 /* { dg-final { scan-offload-tree-dump-not "omp_get_team_num" "optimized" } } */
index 83e577a3298052d4798a78f801828fde1286d368..ff756a38489b25b0333457eea01c8c9464f269c6 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "for-static.h"
 
-/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_start \\(" 2 "optimized" } } */
-/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_end \\(" 2 "optimized" } } */
+/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_start \\(\[^\\)\]" 2 "optimized" } } */
+/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_end \\(\\)" 2 "optimized" } } */
 /* { dg-final { scan-offload-tree-dump-not "GOMP_distribute_static_worksharing \\(" "optimized" } } */
 /* { dg-final { scan-offload-tree-dump-not "GOMP_distribute_static_worksharing_dispatch" "optimized" } } */
index e7b904eedc3a3622557fd7402ede49e0ce0bf3be..d783b2c7c6b7f9602c774d63810422915e768c45 100644 (file)
@@ -6,6 +6,6 @@
 
 #include "for-static.h"
 
-/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_start \\(" 2 "optimized" } } */
-/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_dispatch \\(" 2 "optimized" } } */
-/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_end \\(" 2 "optimized" } } */
+/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_start \\(\[^\\)\]" 2 "optimized" } } */
+/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_dispatch \\(\\)" 2 "optimized" } } */
+/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_end \\(\\)" 2 "optimized" } } */