]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Pass loop parameters to static worksharing dispatch builtins for OMPT
authorPaul-Antoine Arras <parras@baylibre.com>
Wed, 15 Jul 2026 18:41:45 +0000 (20:41 +0200)
committerPaul-Antoine Arras <parras@baylibre.com>
Thu, 16 Jul 2026 17:19:14 +0000 (19:19 +0200)
The GOMP_*_static_worksharing_dispatch builtins took no arguments and the
OMPT dispatch callback was missing information about the loop. Pass the loop's
iteration count, start, step, chunk size, and the thread's starting
iteration instead.

gcc/ChangeLog:

* builtin-types.def (BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG): New.
* omp-builtins.def (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_DISPATCH): Use
BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG.
(BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_DISPATCH): Likewise.
* omp-expand.cc (expand_omp_for_static_nochunk): Pass niter, start,
incr, chunk size, and istart to the dispatch call.
(expand_omp_for_static_chunk): Likewise.

gcc/fortran/ChangeLog:

* types.def (BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG): New.

libgomp/ChangeLog:

* config/gcn/teams.c (GOMP_distribute_static_worksharing_dispatch): Add
niter, start, incr, chunk_size, and istart parameters (unused).
* config/nvptx/teams.c (GOMP_distribute_static_worksharing_dispatch):
Likewise.
* libgomp_g.h (GOMP_loop_static_worksharing_dispatch): Update prototype.
(GOMP_distribute_static_worksharing_dispatch): Likewise.
* loop.c (GOMP_loop_static_worksharing_dispatch): Add niter, start,
incr, chunk_size, and istart parameters (unused).
* teams.c (GOMP_distribute_static_worksharing_dispatch): Likewise.
* testsuite/libgomp.c-c++-common/for-static-3.c: Update scan pattern
to match new arguments.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/for-static-3.c: Update scan pattern to match new
arguments.

gcc/builtin-types.def
gcc/fortran/types.def
gcc/omp-builtins.def
gcc/omp-expand.cc
gcc/testsuite/c-c++-common/gomp/for-static-3.c
libgomp/config/gcn/teams.c
libgomp/config/nvptx/teams.c
libgomp/libgomp_g.h
libgomp/loop.c
libgomp/teams.c
libgomp/testsuite/libgomp.c-c++-common/for-static-3.c

index d11e6e736a2b7776f2d7f0e9c9387ecafbe15a9a..4725668643d731d499f0d54605d5b0bbcde571c4 100644 (file)
@@ -945,6 +945,8 @@ DEF_FUNCTION_TYPE_5 (BT_FN_BOOL_UINT_LONGPTR_LONG_LONGPTR_LONGPTR,
 DEF_FUNCTION_TYPE_5 (BT_FN_BOOL_UINT_ULLPTR_ULL_ULLPTR_ULLPTR,
                     BT_BOOL, BT_UINT, BT_PTR_ULONGLONG, BT_ULONGLONG,
                     BT_PTR_ULONGLONG, BT_PTR_ULONGLONG)
+DEF_FUNCTION_TYPE_5 (BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG,
+                    BT_VOID, BT_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG)
 
 DEF_FUNCTION_TYPE_6 (BT_FN_INT_STRING_SIZE_INT_SIZE_CONST_STRING_VALIST_ARG,
                     BT_INT, BT_STRING, BT_SIZE, BT_INT, BT_SIZE,
index b694e6893600cfbfb9d597f4bb86fa0007e2b047..30c1050d87d47aae15a3ee46b3365c614e675383 100644 (file)
@@ -198,6 +198,8 @@ DEF_FUNCTION_TYPE_5 (BT_FN_BOOL_UINT_LONGPTR_LONG_LONGPTR_LONGPTR,
 DEF_FUNCTION_TYPE_5 (BT_FN_BOOL_UINT_ULLPTR_ULL_ULLPTR_ULLPTR,
                     BT_BOOL, BT_UINT, BT_PTR_ULONGLONG, BT_ULONGLONG,
                     BT_PTR_ULONGLONG, BT_PTR_ULONGLONG)
+DEF_FUNCTION_TYPE_5 (BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG,
+                    BT_VOID, BT_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG)
 
 DEF_FUNCTION_TYPE_6 (BT_FN_BOOL_LONG_LONG_LONG_LONG_LONGPTR_LONGPTR,
                      BT_BOOL, BT_LONG, BT_LONG, BT_LONG, BT_LONG,
index 3b0d5572043a70ac8e90de5edae2d14d73383b0d..121bdcb61a3396bdf02571171afaed3ae9ce7070 100644 (file)
@@ -523,7 +523,8 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_END,
                  "GOMP_loop_static_worksharing_end", BT_FN_VOID,
                  ATTR_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_DISPATCH,
-                 "GOMP_loop_static_worksharing_dispatch", BT_FN_VOID,
+                 "GOMP_loop_static_worksharing_dispatch",
+                 BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG,
                  ATTR_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING,
                  "GOMP_distribute_static_worksharing",
@@ -537,5 +538,6 @@ DEF_GOMP_BUILTIN (BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_END,
                  "GOMP_distribute_static_worksharing_end", BT_FN_VOID,
                  ATTR_NOTHROW_LEAF_LIST)
 DEF_GOMP_BUILTIN (BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_DISPATCH,
-                 "GOMP_distribute_static_worksharing_dispatch", BT_FN_VOID,
+                 "GOMP_distribute_static_worksharing_dispatch",
+                 BT_FN_VOID_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG,
                  ATTR_NOTHROW_LEAF_LIST)
index ca4d5d0db9e5a6653ba00f0761ff489c9a0cfa20..cf992eab835fac1935201fece32795e1718ac94c 100644 (file)
@@ -5602,8 +5602,15 @@ expand_omp_for_static_nochunk (struct omp_region *region,
        default:
          gcc_unreachable ();
        }
-      gcall *g = gimple_build_call (decl, 0);
-      gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+      tree n_ull = fold_convert (long_long_unsigned_type_node, n);
+      tree n1_ull = fold_convert (long_long_unsigned_type_node, n1);
+      tree step_ull = fold_convert (long_long_unsigned_type_node, step);
+      tree chunk_size_ull = build_int_cst (long_long_unsigned_type_node, 0);
+      tree v_ull = fold_convert (long_long_unsigned_type_node, fd->loop.v);
+      tree call = build_call_expr (decl, 5, n_ull, n1_ull, step_ull,
+                                  chunk_size_ull, v_ull);
+      force_gimple_operand_gsi (&gsi, call, true, NULL_TREE, true,
+                               GSI_SAME_STMT);
     }
 
   gsi = gsi_last_nondebug_bb (exit_bb);
@@ -6441,8 +6448,16 @@ expand_omp_for_static_chunk (struct omp_region *region,
        default:
          gcc_unreachable ();
        }
-      gcall *g = gimple_build_call (decl, 0);
-      gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+      tree n_ull = fold_convert (long_long_unsigned_type_node, n);
+      tree n1_ull = fold_convert (long_long_unsigned_type_node, n1);
+      tree step_ull = fold_convert (long_long_unsigned_type_node, step);
+      tree chunk_size_ull
+       = fold_convert (long_long_unsigned_type_node, chunk_size);
+      tree v_ull = fold_convert (long_long_unsigned_type_node, fd->loop.v);
+      tree call = build_call_expr (decl, 5, n_ull, n1_ull, step_ull,
+                                  chunk_size_ull, v_ull);
+      force_gimple_operand_gsi (&gsi, call, true, NULL_TREE, true,
+                               GSI_SAME_STMT);
     }
 
   /* Connect the new blocks.  */
index 8e45223c3538f54e8997ff866f58394ba42e98d6..950edab0779c7fbe288133cf14d54087380144c6 100644 (file)
@@ -8,11 +8,13 @@
 
 /* { 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_dispatch \\(\[^,\]+, \[^,\]+, \[^,\]+, 0, \[^)\]+\\)" 1 "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_loop_static_worksharing_dispatch \\(\[^,\]+, \[^,\]+, \[^,\]+, 4, \[^)\]+\\)" 1 "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_dispatch \\(\[^,\]+, \[^,\]+, \[^,\]+, 0, \[^)\]+\\)" 1 "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_distribute_static_worksharing_dispatch \\(\[^,\]+, \[^,\]+, \[^,\]+, 4, \[^)\]+\\)" 1 "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" } } */
index 4354131f9b768037a25f335db969ff899eed399f..7000e99fb32bb792f738428ae7785fefb33946cf 100644 (file)
@@ -64,10 +64,19 @@ GOMP_distribute_static_worksharing_start (unsigned long long niter
   return nteams + tid * 1I;
 }
 
-/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed.  */
+/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. NITER is the total
+   number of iterations. START is the starting iteration index. INCR is the
+   increment of the loop (or step). CHUNK_SIZE is the specific chunk size
+   requested in the schedule clause, or 0 if not specified. ISTART is the
+   iteration index of the logical chunk start.  */
 
 void
-GOMP_distribute_static_worksharing_dispatch (void)
+GOMP_distribute_static_worksharing_dispatch (
+  unsigned long long niter __attribute__ ((unused)),
+  unsigned long long start __attribute__ ((unused)),
+  unsigned long long incr __attribute__ ((unused)),
+  unsigned long long chunk_size __attribute__ ((unused)),
+  unsigned long long istart __attribute__ ((unused)))
 {}
 
 /* Stub for OMPT callback enabled by -fopenmp-ompt.  */
index e04f8bbbdb1458e8b35a40977be49d2440c826d6..7793a745bb1166e7a128e67378af30982bfc6620 100644 (file)
@@ -65,10 +65,19 @@ GOMP_distribute_static_worksharing_start (unsigned long long niter
   return nteams + tid * 1I;
 }
 
-/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed.  */
+/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. NITER is the total
+   number of iterations. START is the starting iteration index. INCR is the
+   increment of the loop (or step). CHUNK_SIZE is the specific chunk size
+   requested in the schedule clause, or 0 if not specified. ISTART is the
+   iteration index of the logical chunk start.  */
 
 void
-GOMP_distribute_static_worksharing_dispatch (void)
+GOMP_distribute_static_worksharing_dispatch (
+  unsigned long long niter __attribute__ ((unused)),
+  unsigned long long start __attribute__ ((unused)),
+  unsigned long long incr __attribute__ ((unused)),
+  unsigned long long chunk_size __attribute__ ((unused)),
+  unsigned long long istart __attribute__ ((unused)))
 {}
 
 /* Stub for OMPT callback enabled by -fopenmp-ompt.  */
index 27d0db8c93bbf821a1e8fe11217252eb2b28fb4f..1ea8123056e2d03fe2e78f822825346c642ae01a 100644 (file)
@@ -146,7 +146,11 @@ extern bool GOMP_loop_end_cancel (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_dispatch (unsigned long long,
+                                                  unsigned long long,
+                                                  unsigned long long,
+                                                  unsigned long long,
+                                                  unsigned long long);
 extern void GOMP_loop_static_worksharing_end (void);
 
 /* loop_ull.c */
@@ -388,7 +392,11 @@ extern void GOMP_teams_reg (void (*) (void *), void *, unsigned, unsigned,
                            unsigned);
 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_dispatch (unsigned long long,
+                                                        unsigned long long,
+                                                        unsigned long long,
+                                                        unsigned long long,
+                                                        unsigned long long);
 extern void GOMP_distribute_static_worksharing_end (void);
 
 /* allocator.c */
index f4d962667741edc00bd34dfa94988e921b35550b..01ba0a3c900376e886fa6806a2f0de246e6efe60 100644 (file)
@@ -1213,10 +1213,19 @@ GOMP_loop_static_worksharing_start (unsigned long long niter
   return nthreads + tid * 1I;
 }
 
-/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed.  */
+/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. NITER is the total
+   number of iterations. START is the starting iteration index. INCR is the
+   increment of the loop (or step). CHUNK_SIZE is the specific chunk size
+   requested in the schedule clause, or 0 if not specified. ISTART is the
+   iteration index of the logical chunk start.  */
 
 void
-GOMP_loop_static_worksharing_dispatch (void)
+GOMP_loop_static_worksharing_dispatch (
+  unsigned long long niter __attribute__ ((unused)),
+  unsigned long long start __attribute__ ((unused)),
+  unsigned long long incr __attribute__ ((unused)),
+  unsigned long long chunk_size __attribute__ ((unused)),
+  unsigned long long istart __attribute__ ((unused)))
 {}
 
 /* Stub for OMPT callback enabled by -fopenmp-ompt.  */
index 71c40ef5b466af6e2121292e8786d941146ca24f..e95f52056c7a415fd53f7329621ded9684578a7f 100644 (file)
@@ -84,10 +84,19 @@ GOMP_distribute_static_worksharing_start (unsigned long long
   return nteams + tid * 1I;
 }
 
-/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed.  */
+/* Stub for OMPT callback enabled by -fopenmp-ompt-detailed. NITER is the total
+   number of iterations. START is the starting iteration index. INCR is the
+   increment of the loop (or step). CHUNK_SIZE is the specific chunk size
+   requested in the schedule clause, or 0 if not specified. ISTART is the
+   iteration index of the logical chunk start.  */
 
 void
-GOMP_distribute_static_worksharing_dispatch (void)
+GOMP_distribute_static_worksharing_dispatch (
+  unsigned long long niter __attribute__ ((unused)),
+  unsigned long long start __attribute__ ((unused)),
+  unsigned long long incr __attribute__ ((unused)),
+  unsigned long long chunk_size __attribute__ ((unused)),
+  unsigned long long istart __attribute__ ((unused)))
 {}
 
 /* Stub for OMPT callback enabled by -fopenmp-ompt.  */
index d783b2c7c6b7f9602c774d63810422915e768c45..77954743843e86168972f7f59b1c48870c18a07f 100644 (file)
@@ -7,5 +7,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_dispatch \\(\[^,\]+, \[^,\]+, \[^,\]+, 0, \[^)\]+\\)" 1 "optimized" } } */
+/* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_dispatch \\(\[^,\]+, \[^,\]+, \[^,\]+, 4, \[^)\]+\\)" 1 "optimized" } } */
 /* { dg-final { scan-offload-tree-dump-times "GOMP_distribute_static_worksharing_end \\(\\)" 2 "optimized" } } */