[Openmp-commits] [openmp] 578b2a3 - [OpenMP] Add LIT test on task depend clause
Animesh Kumar via Openmp-commits
openmp-commits at lists.llvm.org
Fri Apr 28 03:30:05 PDT 2023
Author: Animesh Kumar
Date: 2023-04-28T15:53:41+05:30
New Revision: 578b2a36b6756f91e3e22d967f98efb5ff090d25
URL: https://github.com/llvm/llvm-project/commit/578b2a36b6756f91e3e22d967f98efb5ff090d25
DIFF: https://github.com/llvm/llvm-project/commit/578b2a36b6756f91e3e22d967f98efb5ff090d25.diff
LOG: [OpenMP] Add LIT test on task depend clause
The working of depend clause with iterator modifier
can be correctly tested by means of execution tests
and not at the LLVM IR level. These tests
are imported/inspired from the SOLLVE tests.
SOLLVE repo: https://github.com/SOLLVE/sollve_vv
Differential Revision: https://reviews.llvm.org/D146706
Added:
openmp/runtime/test/tasking/omp_task_depend_iterator.cpp
Modified:
Removed:
################################################################################
diff --git a/openmp/runtime/test/tasking/omp_task_depend_iterator.cpp b/openmp/runtime/test/tasking/omp_task_depend_iterator.cpp
new file mode 100644
index 0000000000000..27eee0a45fc30
--- /dev/null
+++ b/openmp/runtime/test/tasking/omp_task_depend_iterator.cpp
@@ -0,0 +1,86 @@
+// RUN: %libomp-cxx-compile-and-run
+
+/*
+
+This test is imported from SOLLVE: 5.0/task/test_task_depend_iterator.cpp
+SOLLVE page: https://github.com/SOLLVE/sollve_vv
+
+OpenMP API Version 5.0 Nov 2020
+
+This test is for the iterator modifier when used with the task depend
+clause. This modifier should create an iterator that expands to multiple values
+inside the clause they appear. In this particular test case the iterator expands into
+several values creating several dependencies at the same time.
+
+*/
+
+#include <omp.h>
+#include <algorithm>
+#include <cstdlib>
+#include <iostream>
+#include <thread>
+#include <vector>
+#include "omp_testsuite.h"
+
+#define N 1024
+#define FROM 64
+#define LENGTH 128
+
+int test_omp_task_depend_iterator() {
+ int ptr[] = {0, 4, 5, 6, 7, 8, 9, 10, 11};
+ int cols[] = {1, 2, 3, 4, 5, 5, 6, 6, 7, 7, 8};
+ std::vector<int> threadOrder;
+ bool threadOrderError = false;
+#pragma omp parallel num_threads(8)
+ {
+#pragma omp single
+ {
+ for (int i = 0; i < 8; ++i) {
+ int pos = ptr[i], size = ptr[i + 1] - ptr[i];
+#pragma omp task depend(iterator(it = 0 : size), in : ptr[cols[pos + it]]) depend(out : ptr[i])
+ {
+#pragma omp critical
+ {
+ threadOrder.push_back(i);
+ } // end critical section
+ } // end task depend
+ }
+ } // end single
+ } // end parallel
+
+ // store the indices of the execution order of generated tasks in idx[]
+ std::vector<int>::iterator idx[8];
+ for (int i = 0; i < 8; ++i)
+ idx[i] = std::find (threadOrder.begin(), threadOrder.end(), i);
+
+ // verify that dependencies are met in the order
+ if (idx[0] != threadOrder.begin())
+ threadOrderError |= true;
+ if (idx[1] > idx[5] || idx[2] > idx[5])
+ threadOrderError |= true;
+ if (idx[3] > idx[6] || idx[4] > idx[6])
+ threadOrderError |= true;
+ if (idx[5] > idx[7] || idx[6] > idx[7])
+ threadOrderError |= true;
+
+ std::sort(threadOrder.begin(), threadOrder.end());
+ for(int i = 0; i < 8; ++i)
+ threadOrderError = (threadOrder[i] != i) || threadOrderError;
+
+ // FALSE If dependencies between tasks were not enforced in the correct order.
+ return !threadOrderError;
+}
+
+
+
+int main() {
+ int i;
+ int num_failed=0;
+
+ for(i = 0; i < REPETITIONS; i++) {
+ if(!test_omp_task_depend_iterator()) {
+ num_failed++;
+ }
+ }
+ return num_failed;
+}
More information about the Openmp-commits
mailing list