brintos

brintos / llvm-project-archived public Read only

0
0
Text · 642 B · f3eaa55 Raw
31 lines · c
1#if defined(WIN32) || defined(_WIN32)2#include <windows.h>3#define delay() Sleep(1);4#else5#include <unistd.h>6#define delay(t) usleep(t);7#endif8 9// These functions are used to provide a signal-wait mechanism to enforce10// expected scheduling for the test cases. Conditional variable (s) needs to be11// shared! Initialize to 012 13#define OMPT_SIGNAL(s) ompt_signal(&s)14// inline15void ompt_signal(int *s) {16#pragma omp atomic17  (*s)++;18}19 20#define OMPT_WAIT(s, v) ompt_wait(&s, v)21// wait for s >= v22// inline23void ompt_wait(int *s, int v) {24  int wait = 0;25  do {26    delay(10);27#pragma omp atomic read28    wait = (*s);29  } while (wait < v);30}31