[Openmp-commits] [openmp] Draft: Update OpenMP runtime to adopt taskgraph clause from 6.0 Specs (PR #130751)

via Openmp-commits openmp-commits at lists.llvm.org
Tue Mar 11 03:59:10 PDT 2025


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 5048a0858beb15bdd203dee89dd4df9b2a72ba5f 15e587e41a7c648491b6a7810e50f06cf4d3fb29 --extensions cpp,h -- openmp/runtime/src/kmp.h openmp/runtime/src/kmp_global.cpp openmp/runtime/src/kmp_tasking.cpp openmp/runtime/test/tasking/omp_record_replay.cpp openmp/runtime/test/tasking/omp_record_replay_deps.cpp openmp/runtime/test/tasking/omp_record_replay_multiTDGs.cpp openmp/runtime/test/tasking/omp_record_replay_print_dot.cpp openmp/runtime/test/tasking/omp_record_replay_taskloop.cpp
``````````

</details>

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

``````````diff
diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index 77b519764c..4f1a91dfd8 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -2647,12 +2647,11 @@ typedef struct kmp_tdg_info {
   kmp_int32 rec_num_taskred;
 } kmp_tdg_info_t;
 
-
 extern int __kmp_tdg_dot;
 extern kmp_int32 __kmp_max_tdgs;
 extern kmp_tdg_info_t **__kmp_global_tdgs;
 extern kmp_int32 __kmp_curr_tdg_idx;
-extern kmp_tdg_info_t* __kmp_curr_tdg;
+extern kmp_tdg_info_t *__kmp_curr_tdg;
 extern kmp_int32 __kmp_successors_size;
 extern std::atomic<kmp_int32> __kmp_tdg_task_id;
 extern kmp_int32 __kmp_num_tdg;
diff --git a/openmp/runtime/src/kmp_global.cpp b/openmp/runtime/src/kmp_global.cpp
index 0bf5c034ad..501e478370 100644
--- a/openmp/runtime/src/kmp_global.cpp
+++ b/openmp/runtime/src/kmp_global.cpp
@@ -556,8 +556,7 @@ kmp_int32 __kmp_max_tdgs = 100;
 kmp_tdg_info_t **__kmp_global_tdgs = NULL;
 kmp_int32 __kmp_curr_tdg_idx =
     0; // Id of the current TDG being recorded or executed
-kmp_tdg_info_t* __kmp_curr_tdg =
-    NULL; // Current TDG being recorded or executed
+kmp_tdg_info_t *__kmp_curr_tdg = NULL; // Current TDG being recorded or executed
 kmp_int32 __kmp_num_tdg = 0;
 kmp_int32 __kmp_successors_size = 10; // Initial succesor size list for
                                       // recording
diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp
index e1f5c299c0..cc2fadedfb 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -2580,11 +2580,9 @@ void *__kmpc_task_reduction_init(int gtid, int num, void *data) {
   kmp_tdg_info_t *tdg = __kmp_curr_tdg;
   if (tdg && __kmp_tdg_is_recording(tdg->tdg_status)) {
     /* kmp_tdg_info_t *this_tdg = __kmp_global_tdgs[__kmp_curr_tdg_idx]; */
-    tdg->rec_taskred_data =
-        __kmp_allocate(sizeof(kmp_task_red_input_t) * num);
+    tdg->rec_taskred_data = __kmp_allocate(sizeof(kmp_task_red_input_t) * num);
     tdg->rec_num_taskred = num;
-    KMP_MEMCPY(tdg->rec_taskred_data, data,
-               sizeof(kmp_task_red_input_t) * num);
+    KMP_MEMCPY(tdg->rec_taskred_data, data, sizeof(kmp_task_red_input_t) * num);
   }
 #endif
   return __kmp_task_reduction_init(gtid, num, (kmp_task_red_input_t *)data);
@@ -2607,11 +2605,9 @@ void *__kmpc_taskred_init(int gtid, int num, void *data) {
   kmp_tdg_info_t *tdg = __kmp_curr_tdg;
   if (tdg && __kmp_tdg_is_recording(tdg->tdg_status)) {
     /* kmp_tdg_info_t *this_tdg = __kmp_global_tdgs[__kmp_curr_tdg_idx]; */
-    tdg->rec_taskred_data =
-        __kmp_allocate(sizeof(kmp_task_red_input_t) * num);
+    tdg->rec_taskred_data = __kmp_allocate(sizeof(kmp_task_red_input_t) * num);
     tdg->rec_num_taskred = num;
-    KMP_MEMCPY(tdg->rec_taskred_data, data,
-               sizeof(kmp_task_red_input_t) * num);
+    KMP_MEMCPY(tdg->rec_taskred_data, data, sizeof(kmp_task_red_input_t) * num);
   }
 #endif
   return __kmp_task_reduction_init(gtid, num, (kmp_taskred_input_t *)data);
@@ -5469,9 +5465,9 @@ static kmp_tdg_info_t *__kmp_find_tdg(kmp_int32 tdg_id) {
         sizeof(kmp_tdg_info_t *) * __kmp_max_tdgs);
 
   for (i = 0; i < __kmp_max_tdgs; i++) {
-    if (__kmp_global_tdgs[i] &&
-        __kmp_global_tdgs[i]->tdg_id == tdg_id) {
-      if (__kmp_global_tdgs[i]->tdg_status != KMP_TDG_NONE) { //XXX: Do I really need this?
+    if (__kmp_global_tdgs[i] && __kmp_global_tdgs[i]->tdg_id == tdg_id) {
+      if (__kmp_global_tdgs[i]->tdg_status !=
+          KMP_TDG_NONE) { // XXX: Do I really need this?
         res = __kmp_global_tdgs[i];
       }
       // XXX: Probably cleanup if statue == KMP_TDG_NONE
@@ -5498,7 +5494,7 @@ static kmp_tdg_info_t *__kmp_alloc_tdg(kmp_int32 tdg_id) {
   for (i = 0; i < __kmp_max_tdgs; i++) {
     if (!__kmp_global_tdgs[i]) {
       kmp_tdg_info_t *tdg =
-        (kmp_tdg_info_t *)__kmp_allocate(sizeof(kmp_tdg_info_t));
+          (kmp_tdg_info_t *)__kmp_allocate(sizeof(kmp_tdg_info_t));
       __kmp_global_tdgs[i] = tdg;
       __kmp_curr_tdg = tdg;
       __kmp_curr_tdg_idx = i;
@@ -5528,8 +5524,7 @@ static bool __kmp_free_tdg(kmp_int32 tdg_id) {
     return false;
 
   for (i = 0; i < __kmp_max_tdgs; i++) {
-    if (__kmp_global_tdgs[i] &&
-        __kmp_global_tdgs[i]->tdg_id == tdg_id) {
+    if (__kmp_global_tdgs[i] && __kmp_global_tdgs[i]->tdg_id == tdg_id) {
       tdg = __kmp_global_tdgs[i];
       for (kmp_int i = 0; i < tdg->map_size; i++) {
         __kmp_free(tdg->record_map[i].successors);
@@ -5691,14 +5686,13 @@ kmp_int32 __kmpc_start_record_task(ident_t *loc_ref, kmp_int32 gtid,
   kmp_taskgraph_flags_t *flags = (kmp_taskgraph_flags_t *)&input_flags;
   KA_TRACE(10,
            ("__kmpc_start_record_task(enter): T#%d loc=%p flags=%d tdg_id=%d\n "
-            "reset=%d\n", gtid, loc_ref, input_flags, tdg_id, reset));
+            "reset=%d\n",
+            gtid, loc_ref, input_flags, tdg_id, reset));
 
   if (__kmp_max_tdgs == 0) {
-    KA_TRACE(
-        10,
-        ("__kmpc_start_record_task(abandon): T#%d loc=%p flags=%d "
-         "tdg_id = %d reset = %d, __kmp_max_tdgs = 0\n",
-         gtid, loc_ref, input_flags, tdg_id, reset));
+    KA_TRACE(10, ("__kmpc_start_record_task(abandon): T#%d loc=%p flags=%d "
+                  "tdg_id = %d reset = %d, __kmp_max_tdgs = 0\n",
+                  gtid, loc_ref, input_flags, tdg_id, reset));
     return 1;
   }
 
diff --git a/openmp/runtime/test/tasking/omp_record_replay.cpp b/openmp/runtime/test/tasking/omp_record_replay.cpp
index 7779d27ca1..dc753d8733 100644
--- a/openmp/runtime/test/tasking/omp_record_replay.cpp
+++ b/openmp/runtime/test/tasking/omp_record_replay.cpp
@@ -30,7 +30,8 @@ int main() {
   #pragma omp single
   for (int iter = 0; iter < NT; ++iter) {
     int gtid = __kmpc_global_thread_num(nullptr);
-    int res =  __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */ 0, /* tdg_id */0, /* reset */ false);
+    int res = __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */ 0,
+                                       /* tdg_id */ 0, /* reset */ false);
     if (res) {
       num_tasks++;
       #pragma omp task 
diff --git a/openmp/runtime/test/tasking/omp_record_replay_deps.cpp b/openmp/runtime/test/tasking/omp_record_replay_deps.cpp
index 05318e4e2c..524f9b633f 100644
--- a/openmp/runtime/test/tasking/omp_record_replay_deps.cpp
+++ b/openmp/runtime/test/tasking/omp_record_replay_deps.cpp
@@ -44,7 +44,8 @@ int main() {
   #pragma omp single
   for (int iter = 0; iter < NT; ++iter) {
     int gtid = __kmpc_global_thread_num(nullptr);
-    int res =  __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */0, /* tdg_id */0, /* reset */ false);
+    int res = __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */ 0,
+                                       /* tdg_id */ 0, /* reset */ false);
     if (res) {
       #pragma omp task depend(out:y)
       add();
diff --git a/openmp/runtime/test/tasking/omp_record_replay_multiTDGs.cpp b/openmp/runtime/test/tasking/omp_record_replay_multiTDGs.cpp
index 8edfa4e7ad..fc8763ce65 100644
--- a/openmp/runtime/test/tasking/omp_record_replay_multiTDGs.cpp
+++ b/openmp/runtime/test/tasking/omp_record_replay_multiTDGs.cpp
@@ -43,7 +43,8 @@ int main() {
   #pragma omp single
   for (int iter = 0; iter < NT; ++iter) {
     int gtid = __kmpc_global_thread_num(nullptr);
-    int res =  __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */0, /* tdg_id */0, /* reset */ false);
+    int res = __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */ 0,
+                                       /* tdg_id */ 0, /* reset */ false);
     if (res) {
       num_tasks++;
       #pragma omp task depend(out:y)
@@ -54,7 +55,8 @@ int main() {
       mult();
     }
     __kmpc_end_record_task(nullptr, gtid, /* kmp_tdg_flags */0, /* tdg_id */0);
-    res =  __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */0, /* tdg_id */1, /* reset */ false);
+    res = __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */ 0,
+                                   /* tdg_id */ 1, /* reset */ false);
     if (res) {
       num_tasks++;
       #pragma omp task depend(out:y)
diff --git a/openmp/runtime/test/tasking/omp_record_replay_print_dot.cpp b/openmp/runtime/test/tasking/omp_record_replay_print_dot.cpp
index b32c42b659..1dc31574a2 100644
--- a/openmp/runtime/test/tasking/omp_record_replay_print_dot.cpp
+++ b/openmp/runtime/test/tasking/omp_record_replay_print_dot.cpp
@@ -48,7 +48,8 @@ int main() {
   #pragma omp single
   {
     int gtid = __kmpc_global_thread_num(nullptr);
-    int res = __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */0, /* tdg_id */0, /* reset */ false);
+    int res = __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */ 0,
+                                       /* tdg_id */ 0, /* reset */ false);
     if (res) {
       #pragma omp task depend(out : x)
       func(&num_exec);
diff --git a/openmp/runtime/test/tasking/omp_record_replay_taskloop.cpp b/openmp/runtime/test/tasking/omp_record_replay_taskloop.cpp
index 2d50a9d41a..5f61becd21 100644
--- a/openmp/runtime/test/tasking/omp_record_replay_taskloop.cpp
+++ b/openmp/runtime/test/tasking/omp_record_replay_taskloop.cpp
@@ -31,7 +31,8 @@ int main() {
   #pragma omp single
   for (int iter = 0; iter < NT; ++iter) {
     int gtid = __kmpc_global_thread_num(nullptr);
-    int res =  __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */0, /* tdg_id */0, /* reset */ false);
+    int res = __kmpc_start_record_task(nullptr, gtid, /* kmp_tdg_flags */ 0,
+                                       /* tdg_id */ 0, /* reset */ false);
     if (res) {
       num_tasks++;
       #pragma omp taskloop reduction(+:sum) num_tasks(4096)

``````````

</details>


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


More information about the Openmp-commits mailing list