summaryrefslogtreecommitdiffstats
path: root/openmp/tools/archer/tests/races
diff options
context:
space:
mode:
Diffstat (limited to 'openmp/tools/archer/tests/races')
-rw-r--r--openmp/tools/archer/tests/races/critical-unrelated.c42
-rw-r--r--openmp/tools/archer/tests/races/lock-nested-unrelated.c48
-rw-r--r--openmp/tools/archer/tests/races/lock-unrelated.c48
-rw-r--r--openmp/tools/archer/tests/races/parallel-simple.c37
-rw-r--r--openmp/tools/archer/tests/races/task-dependency.c61
-rw-r--r--openmp/tools/archer/tests/races/task-taskgroup-unrelated.c61
-rw-r--r--openmp/tools/archer/tests/races/task-taskwait-nested.c59
-rw-r--r--openmp/tools/archer/tests/races/task-two.c45
8 files changed, 401 insertions, 0 deletions
diff --git a/openmp/tools/archer/tests/races/critical-unrelated.c b/openmp/tools/archer/tests/races/critical-unrelated.c
new file mode 100644
index 00000000000..d94acf5f386
--- /dev/null
+++ b/openmp/tools/archer/tests/races/critical-unrelated.c
@@ -0,0 +1,42 @@
+/*
+ * critical-unrelated.c -- Archer testcase
+ */
+
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+//
+// See tools/archer/LICENSE.txt for details.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+
+// RUN: %libarcher-compile-and-run-race | FileCheck %s
+#include <omp.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ int var = 0;
+
+#pragma omp parallel num_threads(2) shared(var)
+ {
+#pragma omp critical
+ {
+ // Dummy region.
+ }
+
+ var++;
+ }
+
+ fprintf(stderr, "DONE\n");
+}
+
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK-NEXT: {{(Write|Read)}} of size 4
+// CHECK-NEXT: #0 {{.*}}critical-unrelated.c:29
+// CHECK: Previous write of size 4
+// CHECK-NEXT: #0 {{.*}}critical-unrelated.c:29
+// CHECK: DONE
+// CHECK: ThreadSanitizer: reported 1 warnings
+
diff --git a/openmp/tools/archer/tests/races/lock-nested-unrelated.c b/openmp/tools/archer/tests/races/lock-nested-unrelated.c
new file mode 100644
index 00000000000..67d12310f11
--- /dev/null
+++ b/openmp/tools/archer/tests/races/lock-nested-unrelated.c
@@ -0,0 +1,48 @@
+/*
+ * lock-nested-unrelated.c -- Archer testcase
+ */
+
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+//
+// See tools/archer/LICENSE.txt for details.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+
+// RUN: %libarcher-compile-and-run-race | FileCheck %s
+#include <omp.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ int var = 0;
+
+ omp_nest_lock_t lock;
+ omp_init_nest_lock(&lock);
+
+#pragma omp parallel num_threads(2) shared(var)
+ {
+ omp_set_nest_lock(&lock);
+ omp_set_nest_lock(&lock);
+ // Dummy locking.
+ omp_unset_nest_lock(&lock);
+ omp_unset_nest_lock(&lock);
+
+ var++;
+ }
+
+ omp_destroy_nest_lock(&lock);
+
+ fprintf(stderr, "DONE\n");
+}
+
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK-NEXT: {{(Write|Read)}} of size 4
+// CHECK-NEXT: #0 {{.*}}lock-nested-unrelated.c:33
+// CHECK: Previous write of size 4
+// CHECK-NEXT: #0 {{.*}}lock-nested-unrelated.c:33
+// CHECK: DONE
+// CHECK: ThreadSanitizer: reported 1 warnings
+
diff --git a/openmp/tools/archer/tests/races/lock-unrelated.c b/openmp/tools/archer/tests/races/lock-unrelated.c
new file mode 100644
index 00000000000..ec7c96db0dd
--- /dev/null
+++ b/openmp/tools/archer/tests/races/lock-unrelated.c
@@ -0,0 +1,48 @@
+/*
+ * lock-unrelated.c -- Archer testcase
+ */
+
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+//
+// See tools/archer/LICENSE.txt for details.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+
+// RUN: %libarcher-compile-and-run-race | FileCheck %s
+#include <omp.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ int var = 0;
+
+ omp_lock_t lock;
+ omp_init_lock(&lock);
+
+#pragma omp parallel num_threads(2) shared(var)
+ {
+ omp_set_lock(&lock);
+ // Dummy locking.
+ omp_unset_lock(&lock);
+
+ var++;
+ }
+
+ omp_destroy_lock(&lock);
+
+ int error = (var != 2);
+ fprintf(stderr, "DONE\n");
+ return error;
+}
+
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK-NEXT: {{(Write|Read)}} of size 4
+// CHECK-NEXT: #0 {{.*}}lock-unrelated.c:31
+// CHECK: Previous write of size 4
+// CHECK-NEXT: #0 {{.*}}lock-unrelated.c:31
+// CHECK: DONE
+// CHECK: ThreadSanitizer: reported 1 warnings
+
diff --git a/openmp/tools/archer/tests/races/parallel-simple.c b/openmp/tools/archer/tests/races/parallel-simple.c
new file mode 100644
index 00000000000..94be4daa56f
--- /dev/null
+++ b/openmp/tools/archer/tests/races/parallel-simple.c
@@ -0,0 +1,37 @@
+/*
+ * parallel-simple.c -- Archer testcase
+ */
+
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+//
+// See tools/archer/LICENSE.txt for details.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+
+// RUN: %libarcher-compile-and-run-race | FileCheck %s
+#include <omp.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ int var = 0;
+
+#pragma omp parallel num_threads(2) shared(var)
+ { var++; }
+
+ int error = (var != 2);
+ fprintf(stderr, "DONE\n");
+ return error;
+}
+
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK-NEXT: {{(Write|Read)}} of size 4
+// CHECK-NEXT: #0 {{.*}}parallel-simple.c:23
+// CHECK: Previous write of size 4
+// CHECK-NEXT: #0 {{.*}}parallel-simple.c:23
+// CHECK: DONE
+// CHECK: ThreadSanitizer: reported 1 warnings
+
diff --git a/openmp/tools/archer/tests/races/task-dependency.c b/openmp/tools/archer/tests/races/task-dependency.c
new file mode 100644
index 00000000000..012c0d7bae9
--- /dev/null
+++ b/openmp/tools/archer/tests/races/task-dependency.c
@@ -0,0 +1,61 @@
+/*
+ * task-deoendency.c -- Archer testcase
+ */
+
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+//
+// See tools/archer/LICENSE.txt for details.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+
+// RUN: %libarcher-compile-and-run-race | FileCheck %s
+#include <omp.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "ompt/ompt-signal.h"
+
+int main(int argc, char *argv[]) {
+ int var = 0, a = 0;
+
+#pragma omp parallel num_threads(2) shared(var, a)
+#pragma omp master
+ {
+#pragma omp task shared(var, a) depend(out : var)
+ {
+ OMPT_SIGNAL(a);
+ var++;
+ }
+
+#pragma omp task shared(a) depend(in : var)
+ {
+ OMPT_SIGNAL(a);
+ OMPT_WAIT(a, 3);
+ }
+
+#pragma omp task shared(var) // depend(in: var) is missing here!
+ {
+ var++;
+ OMPT_SIGNAL(a);
+ }
+
+ // Give other thread time to steal the task.
+ OMPT_WAIT(a, 2);
+ }
+
+ int error = (var != 2);
+ fprintf(stderr, "DONE\n");
+ return error;
+}
+
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK-NEXT: {{(Write|Read)}} of size 4
+// CHECK-NEXT: #0 {{.*}}task-dependency.c:41
+// CHECK: Previous write of size 4
+// CHECK-NEXT: #0 {{.*}}task-dependency.c:30
+// CHECK: DONE
+// CHECK: ThreadSanitizer: reported 1 warnings
+
diff --git a/openmp/tools/archer/tests/races/task-taskgroup-unrelated.c b/openmp/tools/archer/tests/races/task-taskgroup-unrelated.c
new file mode 100644
index 00000000000..f2ea78200fb
--- /dev/null
+++ b/openmp/tools/archer/tests/races/task-taskgroup-unrelated.c
@@ -0,0 +1,61 @@
+/*
+ * task-taskgroup-unrelated.c -- Archer testcase
+ */
+
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+//
+// See tools/archer/LICENSE.txt for details.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// RUN: %libarcher-compile-and-run-race | FileCheck %s
+#include <omp.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "ompt/ompt-signal.h"
+
+int main(int argc, char *argv[]) {
+ int var = 0, a = 0;
+
+#pragma omp parallel num_threads(2) shared(var, a)
+#pragma omp master
+ {
+#pragma omp task shared(var, a)
+ {
+ var++;
+ OMPT_SIGNAL(a);
+ // Give master thread time to execute the task in the taskgroup.
+ OMPT_WAIT(a, 2);
+ }
+
+#pragma omp taskgroup
+ {
+#pragma omp task if (0)
+ {
+ // Dummy task.
+ }
+
+ // Give other threads time to steal the tasks.
+ OMPT_WAIT(a, 1);
+ OMPT_SIGNAL(a);
+ }
+
+ var++;
+ }
+
+ int error = (var != 2);
+ fprintf(stderr, "DONE\n");
+ return error;
+}
+
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK-NEXT: {{(Write|Read)}} of size 4
+// CHECK-NEXT: #0 {{.*}}task-taskgroup-unrelated.c:46
+// CHECK: Previous write of size 4
+// CHECK-NEXT: #0 {{.*}}task-taskgroup-unrelated.c:28
+// CHECK: DONE
+// CHECK: ThreadSanitizer: reported 1 warnings
+
diff --git a/openmp/tools/archer/tests/races/task-taskwait-nested.c b/openmp/tools/archer/tests/races/task-taskwait-nested.c
new file mode 100644
index 00000000000..90322d52ea3
--- /dev/null
+++ b/openmp/tools/archer/tests/races/task-taskwait-nested.c
@@ -0,0 +1,59 @@
+/*
+ * task-taskwait-nested.c -- Archer testcase
+ */
+
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+//
+// See tools/archer/LICENSE.txt for details.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+
+// RUN: %libarcher-compile-and-run-race | FileCheck %s
+#include <omp.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "ompt/ompt-signal.h"
+
+int main(int argc, char *argv[]) {
+ int var = 0, a = 0;
+
+#pragma omp parallel num_threads(2) shared(var, a)
+#pragma omp master
+ {
+#pragma omp task shared(var, a)
+ {
+#pragma omp task shared(var, a)
+ {
+ // wait for master to pass the taskwait
+ OMPT_SIGNAL(a);
+ OMPT_WAIT(a, 2);
+ var++;
+ }
+ }
+
+ // Give other thread time to steal the task and execute its child.
+ OMPT_WAIT(a, 1);
+
+// Only directly generated children are guaranteed to be executed.
+#pragma omp taskwait
+ OMPT_SIGNAL(a);
+ var++;
+ }
+
+ int error = (var != 2);
+ fprintf(stderr, "DONE\n");
+ return error;
+}
+
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK-NEXT: {{(Write|Read)}} of size 4
+// CHECK-NEXT: #0 {{.*}}task-taskwait-nested.c:34
+// CHECK: Previous write of size 4
+// CHECK-NEXT: #0 {{.*}}task-taskwait-nested.c:44
+// CHECK: DONE
+// CHECK: ThreadSanitizer: reported 1 warnings
+
diff --git a/openmp/tools/archer/tests/races/task-two.c b/openmp/tools/archer/tests/races/task-two.c
new file mode 100644
index 00000000000..7445961e27d
--- /dev/null
+++ b/openmp/tools/archer/tests/races/task-two.c
@@ -0,0 +1,45 @@
+/*
+ * task-two.c -- Archer testcase
+ */
+
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+//
+// See tools/archer/LICENSE.txt for details.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+
+// RUN: %libarcher-compile-and-run-race | FileCheck %s
+#include <omp.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#define NUM_THREADS 2
+
+int main(int argc, char *argv[]) {
+ int var = 0;
+ int i;
+
+#pragma omp parallel for num_threads(NUM_THREADS) shared(var) schedule(static, \
+ 1)
+ for (i = 0; i < NUM_THREADS; i++) {
+#pragma omp task shared(var) if (0) // the task is inlined an executed locally
+ { var++; }
+ }
+
+ int error = (var != 2);
+ fprintf(stderr, "DONE\n");
+ return error;
+}
+
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK-NEXT: {{(Write|Read)}} of size 4
+// CHECK-NEXT: #0 {{.*}}task-two.c:30
+// CHECK: Previous write of size 4
+// CHECK-NEXT: #0 {{.*}}task-two.c:30
+// CHECK: DONE
+// CHECK: ThreadSanitizer: reported 1 warnings
+
OpenPOWER on IntegriCloud