Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / bench_ten_mutexes.cpp
blobe7fa05ea82039c55b5b58d2b54171662f38c490c
1 // RUN: %clangxx_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s
4 // bench.h needs pthread barriers which are not available on OS X
5 // UNSUPPORTED: darwin
7 #include "bench.h"
9 const int kMutex = 10;
10 pthread_mutex_t mtx[kMutex];
12 void thread(int tid) {
13 for (int i = 0; i < bench_niter; i++) {
14 int idx = (i % kMutex);
15 if (tid == 0)
16 idx = kMutex - idx - 1;
17 pthread_mutex_lock(&mtx[idx]);
18 pthread_mutex_unlock(&mtx[idx]);
22 void bench() {
23 for (int i = 0; i < kMutex; i++)
24 pthread_mutex_init(&mtx[i], 0);
25 start_thread_group(2, thread);
28 // CHECK: DONE