[Openmp-commits] [PATCH] D80577: [OpenMP] Fixed taskloop recursive splitting so that taskloop tasks have same parent tasks.
Andrey Churbanov via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Mon Jun 1 08:01:10 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e111c5df8ef: [openmp] Fixed taskloop recursive splitting so that taskloop tasks have sameā¦ (authored by AndreyChurbanov).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80577/new/
https://reviews.llvm.org/D80577
Files:
openmp/runtime/src/kmp_tasking.cpp
openmp/runtime/test/tasking/omp_taskloop_taskwait.c
Index: openmp/runtime/test/tasking/omp_taskloop_taskwait.c
===================================================================
--- /dev/null
+++ openmp/runtime/test/tasking/omp_taskloop_taskwait.c
@@ -0,0 +1,30 @@
+// RUN: %libomp-compile-and-run
+#include <stdio.h>
+#include <omp.h>
+int main()
+{
+ enum {ITERS = 500};
+ enum {SIZE = 5};
+ int err = 0;
+ #pragma omp parallel num_threads(2) reduction(+:err)
+ {
+ int r = 0;
+ int i;
+ #pragma omp taskloop grainsize(SIZE) shared(r) nogroup
+ for(i=0; i<ITERS; i++) {
+ #pragma omp atomic
+ ++r;
+ }
+ #pragma omp taskwait
+ printf("%d\n", r);
+ if (r != ITERS)
+ err++;
+ } // end of parallel
+ if (err != 0) {
+ printf("failed, err = %d\n", err);
+ return 1;
+ } else {
+ printf("passed\n");
+ return 0;
+ }
+}
Index: openmp/runtime/src/kmp_tasking.cpp
===================================================================
--- openmp/runtime/src/kmp_tasking.cpp
+++ openmp/runtime/src/kmp_tasking.cpp
@@ -3898,14 +3898,13 @@
kmp_task_t *__kmp_task_dup_alloc(kmp_info_t *thread, kmp_task_t *task_src) {
kmp_task_t *task;
kmp_taskdata_t *taskdata;
- kmp_taskdata_t *taskdata_src;
- kmp_taskdata_t *parent_task = thread->th.th_current_task;
+ kmp_taskdata_t *taskdata_src = KMP_TASK_TO_TASKDATA(task_src);
+ kmp_taskdata_t *parent_task = taskdata_src->td_parent; // same parent task
size_t shareds_offset;
size_t task_size;
KA_TRACE(10, ("__kmp_task_dup_alloc(enter): Th %p, source task %p\n", thread,
task_src));
- taskdata_src = KMP_TASK_TO_TASKDATA(task_src);
KMP_DEBUG_ASSERT(taskdata_src->td_flags.proxy ==
TASK_FULL); // it should not be proxy task
KMP_DEBUG_ASSERT(taskdata_src->td_flags.tasktype == TASK_EXPLICIT);
@@ -4280,7 +4279,6 @@
void *codeptr_ra,
#endif
void *task_dup) {
-#if KMP_DEBUG
kmp_taskdata_t *taskdata = KMP_TASK_TO_TASKDATA(task);
KMP_DEBUG_ASSERT(task != NULL);
KMP_DEBUG_ASSERT(num_tasks > num_t_min);
@@ -4288,7 +4286,6 @@
" %lld, extras %lld, i=%lld,%lld(%d), dup %p\n",
gtid, taskdata, num_tasks, grainsize, extras, *lb, *ub, st,
task_dup));
-#endif
p_task_dup_t ptask_dup = (p_task_dup_t)task_dup;
kmp_uint64 lower = *lb;
kmp_info_t *thread = __kmp_threads[gtid];
@@ -4332,9 +4329,14 @@
*ub = ub0; // adjust upper bound for the 1st half
// create auxiliary task for 2nd half of the loop
+ // make sure new task has same parent task as the pattern task
+ kmp_taskdata_t *current_task = thread->th.th_current_task;
+ thread->th.th_current_task = taskdata->td_parent;
kmp_task_t *new_task =
__kmpc_omp_task_alloc(loc, gtid, 1, 3 * sizeof(void *),
sizeof(__taskloop_params_t), &__kmp_taskloop_task);
+ // restore current task
+ thread->th.th_current_task = current_task;
__taskloop_params_t *p = (__taskloop_params_t *)new_task->shareds;
p->task = next_task;
p->lb = (kmp_uint64 *)((char *)next_task + lower_offset);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80577.267622.patch
Type: text/x-patch
Size: 3109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200601/1cda9b9a/attachment-0001.bin>
More information about the Openmp-commits
mailing list