[clang] [llvm] [openmp] [OpenMP][offload] Fix dynamic schedule tracking (PR #97065)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 08:01:57 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 0f61ba679fa1942397c8d2661f3339c305cc101b 49e25086ca66074df97bd0f717783695eccf4bda --extensions 'h,c,cpp' -- offload/test/offloading/dynamic-schedule.cpp offload/test/offloading/schedule.c clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/CodeGen/CGOpenMPRuntime.h clang/lib/CodeGen/CGStmtOpenMP.cpp clang/test/OpenMP/distribute_parallel_for_codegen.cpp clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp clang/test/OpenMP/nvptx_SPMD_codegen.cpp clang/test/OpenMP/ordered_codegen.cpp clang/test/OpenMP/parallel_for_codegen.cpp clang/test/OpenMP/target_parallel_for_codegen.cpp clang/test/OpenMP/target_parallel_for_simd_codegen.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp clang/test/OpenMP/teams_distribute_parallel_for_schedule_codegen.cpp clang/test/OpenMP/teams_distribute_parallel_for_simd_schedule_codegen.cpp llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp offload/DeviceRTL/include/Interface.h offload/DeviceRTL/src/Kernel.cpp offload/DeviceRTL/src/Workshare.cpp openmp/runtime/src/kmp.h openmp/runtime/src/kmp_dispatch.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/offload/test/offloading/schedule.c b/offload/test/offloading/schedule.c
index ef7749f5a8..680dc3fc75 100644
--- a/offload/test/offloading/schedule.c
+++ b/offload/test/offloading/schedule.c
@@ -1,4 +1,5 @@
-// RUN: %libomptarget-compile-generic && %libomptarget-run-generic 2>&1 | %fcheck-generic
+// RUN: %libomptarget-compile-generic && %libomptarget-run-generic 2>&1 |
+// %fcheck-generic
 
 // UNSUPPORTED: aarch64-unknown-linux-gnu
 // UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
@@ -9,27 +10,26 @@
 
 // REQUIRES: amdgcn-amd-amdhsa
 
+#include <omp.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <omp.h>
 
 int ordered_example(int lb, int ub, int stride, int nteams) {
   int i;
-  int size = (ub-lb)/ stride;
-  double *output = (double*)malloc(size * sizeof(double));
+  int size = (ub - lb) / stride;
+  double *output = (double *)malloc(size * sizeof(double));
 
-#pragma omp target teams map(from: output [0:size]) num_teams(nteams) thread_limit(128)
+#pragma omp target teams map(from : output[0 : size]) num_teams(nteams)        \
+    thread_limit(128)
 #pragma omp parallel for ordered schedule(dynamic)
-  for (i=lb; i<ub; i+=stride) {
-    #pragma omp ordered
-    {
-      output[(i-lb)/stride] = omp_get_wtime();
-    }
+  for (i = lb; i < ub; i += stride) {
+#pragma omp ordered
+    { output[(i - lb) / stride] = omp_get_wtime(); }
   }
 
   // verification
   for (int j = 0; j < size; j++) {
-    for (int jj = j+1; jj < size; jj++) {
+    for (int jj = j + 1; jj < size; jj++) {
       if (output[j] > output[jj]) {
         printf("Fail to schedule in order.\n");
         free(output);
@@ -50,7 +50,8 @@ int NO_order_example(int lb, int ub, int stride, int nteams) {
   int size = (ub - lb) / stride;
   double *output = (double *)malloc(size * sizeof(double));
 
-#pragma omp target teams map(from: output [0:size]) num_teams(nteams) thread_limit(128)
+#pragma omp target teams map(from : output[0 : size]) num_teams(nteams)        \
+    thread_limit(128)
 #pragma omp parallel for
   for (i = lb; i < ub; i += stride) {
     output[(i - lb) / stride] = omp_get_wtime();
@@ -74,11 +75,9 @@ int NO_order_example(int lb, int ub, int stride, int nteams) {
   return 0;
 }
 
-int main()
-{
+int main() {
   // CHECK: test no order OK
   NO_order_example(0, 10, 1, 8);
   // CHECK: test ordered OK
   return ordered_example(0, 10, 1, 8);
 }
-

``````````

</details>


https://github.com/llvm/llvm-project/pull/97065


More information about the llvm-commits mailing list