From 4f5dc501183cca28b2951f3a126427b369abb9e6 Mon Sep 17 00:00:00 2001 From: Shintaro Iwasaki Date: Sat, 2 May 2020 01:01:15 -0500 Subject: [PATCH] [BOLT] test: add a new test to check tied/untied tasks This bug was reported in https://github.com/pmodels/bolt/issues/51, which has been already fixed. This test checks if this bug has been really fixed. Acknowledgment: the original code of this test has been created by Joseph Schuchart (schuchart@hlrs.de). Thank you. --- runtime/test/bolt/misc_bugs/untied_tasks.c | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 runtime/test/bolt/misc_bugs/untied_tasks.c diff --git a/runtime/test/bolt/misc_bugs/untied_tasks.c b/runtime/test/bolt/misc_bugs/untied_tasks.c new file mode 100644 index 000000000..88e8edeba --- /dev/null +++ b/runtime/test/bolt/misc_bugs/untied_tasks.c @@ -0,0 +1,61 @@ +// RUN: %libomp-compile-and-run +// REQUIRES: abt +#include "omp_testsuite.h" + +int test_omp_untied_tasks() +{ + // https://github.com/pmodels/bolt/issues/49 + int val = 0; + #pragma omp parallel + #pragma omp master + { + #pragma omp task untied + { val = 1; } + } + return val; +} + +int test_omp_tied_tasks() +{ + int val = 0; + #pragma omp parallel + #pragma omp master + { + #pragma omp task + { val = 1; } + } + return val; +} + +int test_omp_tied_and_untied_tasks() +{ + int val1 = 0; + int val2 = 0; + #pragma omp parallel + #pragma omp master + { + #pragma omp task + { val1 = 1; } + #pragma omp task untied + { val2 = 1; } + } + return val1 == 1 && val2 == 1; +} + +int main() +{ + int i; + int num_failed = 0; + for (i = 0; i < REPETITIONS; i++) { + if (!test_omp_untied_tasks()) { + num_failed++; + } + if (!test_omp_tied_tasks()) { + num_failed++; + } + if (!test_omp_tied_and_untied_tasks()) { + num_failed++; + } + } + return num_failed; +}