Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / tools / archer / tests / ompt / ompt-signal.h
blob6b605e3a4654d64f70254e0ca9e241a0ee7d2f82
1 /*
2 * ompt-signal.h -- Header providing low-level synchronization for tests
3 */
5 //===----------------------------------------------------------------------===//
6 //
7 // The LLVM Compiler Infrastructure
8 //
9 // This file is a copy from runtime/test/ompt/
11 //===----------------------------------------------------------------------===//
13 #if defined(WIN32) || defined(_WIN32)
14 #include <windows.h>
15 #define delay() Sleep(1);
16 #else
17 #include <unistd.h>
18 #define delay(t) usleep(t);
19 #endif
21 // These functions are used to provide a signal-wait mechanism to enforce
22 // expected scheduling for the test cases.
23 // Conditional variable (s) needs to be shared! Initialize to 0
25 #define OMPT_SIGNAL(s) ompt_signal(&s)
26 // inline
27 void ompt_signal(int *s) {
28 #pragma omp atomic
29 (*s)++;
32 #define OMPT_WAIT(s, v) ompt_wait(&s, v)
33 // wait for s >= v
34 // inline
35 void ompt_wait(int *s, int v) {
36 int wait = 0;
37 do {
38 delay(10);
39 #pragma omp atomic read
40 wait = (*s);
41 } while (wait < v);