LLVM OpenMP 20.0.0git
ompt-signal.h
Go to the documentation of this file.
1/*
2 * ompt-signal.h -- Header providing low-level synchronization for tests
3 */
4
5//===----------------------------------------------------------------------===//
6//
7// The LLVM Compiler Infrastructure
8//
9// This file is a copy from runtime/test/ompt/
10//
11//===----------------------------------------------------------------------===//
12
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
20
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
24
25#define OMPT_SIGNAL(s) ompt_signal(&s)
26// inline
27void ompt_signal(int *s) {
28#pragma omp atomic
29 (*s)++;
30}
31
32#define OMPT_WAIT(s, v) ompt_wait(&s, v)
33// wait for s >= v
34// inline
35void 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);
42}
void const char const char int ITT_FORMAT __itt_group_sync s
#define delay(t)
Definition: ompt-signal.h:6
void ompt_signal(int *s)
Definition: ompt-signal.h:14
void ompt_wait(int *s, int v)
Definition: ompt-signal.h:23