summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/test/tasking
diff options
context:
space:
mode:
authorAndrey Churbanov <Andrey.Churbanov@intel.com>2019-07-02 15:10:20 +0000
committerAndrey Churbanov <Andrey.Churbanov@intel.com>2019-07-02 15:10:20 +0000
commita23806e67a2d65196aacc6fd7243d228b4852c81 (patch)
tree6b4940a7748c61f13cd3fbfd1eb55e0e52a4e8c3 /openmp/runtime/test/tasking
parent50be3481d4c77d596ce65cc3155cb45400cbc65b (diff)
downloadbcm5719-llvm-a23806e67a2d65196aacc6fd7243d228b4852c81.tar.gz
bcm5719-llvm-a23806e67a2d65196aacc6fd7243d228b4852c81.zip
Create a runtime option to disable task throttling.
Patch by viroulep (Philippe Virouleau) Differential Revision: https://reviews.llvm.org/D63196 llvm-svn: 364934
Diffstat (limited to 'openmp/runtime/test/tasking')
-rw-r--r--openmp/runtime/test/tasking/omp_fill_taskqueue.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/openmp/runtime/test/tasking/omp_fill_taskqueue.c b/openmp/runtime/test/tasking/omp_fill_taskqueue.c
new file mode 100644
index 00000000000..e95f97a4480
--- /dev/null
+++ b/openmp/runtime/test/tasking/omp_fill_taskqueue.c
@@ -0,0 +1,60 @@
+// RUN: %libomp-compile && env KMP_ENABLE_TASK_THROTTLING=0 %libomp-run
+// RUN: %libomp-compile && env KMP_ENABLE_TASK_THROTTLING=1 %libomp-run
+
+#include<omp.h>
+#include<stdlib.h>
+#include<string.h>
+
+/**
+ * Test the task throttling behavior of the runtime.
+ * Unless OMP_NUM_THREADS is 1, the master thread pushes tasks to its own tasks
+ * queue until either of the following happens:
+ * - the task queue is full, and it starts serializing tasks
+ * - all tasks have been pushed, and it can begin execution
+ * The idea is to create a huge number of tasks which execution are blocked
+ * until the master thread comes to execute tasks (they need to be blocking,
+ * otherwise the second thread will start emptying the queue).
+ * At this point we can check the number of enqueued tasks: iff all tasks have
+ * been enqueued, then there was no task throttling.
+ * Otherwise there has been some sort of task throttling.
+ * If what we detect doesn't match the value of the environment variable, the
+ * test is failed.
+ */
+
+
+#define NUM_TASKS 2000
+
+
+int main()
+{
+ int i;
+ int block = 1;
+ int tid;
+ int throttling = strcmp(getenv("KMP_ENABLE_TASK_THROTTLING"), "1") == 0;
+ int enqueued = 0;
+ int failed = -1;
+
+ #pragma omp parallel num_threads(2)
+ #pragma omp master
+ {
+ for (i = 0; i < NUM_TASKS; i++) {
+ enqueued++;
+ #pragma omp task
+ {
+ tid = omp_get_thread_num();
+ if (tid == 0) {
+ // As soon as the master thread starts executing task we should unlock
+ // all tasks, and detect the test failure if it has not been done yet.
+ if (failed < 0)
+ failed = throttling ? enqueued == NUM_TASKS : enqueued < NUM_TASKS;
+ block = 0;
+ }
+ while (block)
+ ;
+ }
+ }
+ block = 0;
+ }
+
+ return failed;
+}
OpenPOWER on IntegriCloud