diff compiler-rt/test/tsan/bench_single_writer.cpp @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler-rt/test/tsan/bench_single_writer.cpp	Thu Feb 13 15:10:13 2020 +0900
@@ -0,0 +1,26 @@
+// RUN: %clangxx_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+// bench.h needs pthread barriers which are not available on OS X
+// UNSUPPORTED: darwin
+
+#include "bench.h"
+
+int x;
+
+void thread(int tid) {
+  if (tid == 0) {
+    for (int i = 0; i < bench_niter; i++)
+      __atomic_store_n(&x, 0, __ATOMIC_RELEASE);
+  } else {
+    for (int i = 0; i < bench_niter; i++)
+      __atomic_load_n(&x, __ATOMIC_ACQUIRE);
+  }
+}
+
+void bench() {
+  start_thread_group(bench_nthread, thread);
+}
+
+// CHECK: DONE
+