Home | History | Annotate | Download | only in tsan
      1 // RUN: %clangxx_tsan %s -o %t
      2 // RUN: %run %t 2>&1 | FileCheck %s
      3 
      4 // bench.h needs pthread barriers which are not available on OS X
      5 // UNSUPPORTED: darwin
      6 
      7 #include "bench.h"
      8 
      9 int *x;
     10 const int kStride = 32;
     11 
     12 void thread(int tid) {
     13   __atomic_load_n(&x[tid * kStride], __ATOMIC_ACQUIRE);
     14   for (int i = 0; i < bench_niter; i++)
     15     __atomic_store_n(&x[tid * kStride], 0, __ATOMIC_RELEASE);
     16 }
     17 
     18 void bench() {
     19   x = (int*)malloc(bench_nthread * kStride * sizeof(x[0]));
     20   for (int i = 0; i < bench_nthread; i++)
     21     __atomic_store_n(&x[i * kStride], 0, __ATOMIC_RELEASE);
     22   start_thread_group(bench_nthread, thread);
     23 }
     24 
     25 // CHECK: DONE
     26 
     27