[HLSL] Implement RWBuffer::operator[] via __builtin_hlsl_resource_getpointer (#117017)
[llvm-project.git] / openmp / runtime / test / flush / omp_flush.c
blob95a406d3eadcb59d1c3bd2fb0009ff401302aa84
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include "omp_testsuite.h"
4 #include "omp_my_sleep.h"
6 int test_omp_flush()
8 int result1;
9 int result2;
10 int dummy;
12 result1 = 0;
13 result2 = 0;
15 #pragma omp parallel
17 int rank;
18 rank = omp_get_thread_num ();
19 #pragma omp barrier
20 if (rank == 1) {
21 result2 = 3;
22 #pragma omp flush (result2)
23 dummy = result2;
25 if (rank == 0) {
26 my_sleep(SLEEPTIME);
27 #pragma omp flush (result2)
28 result1 = result2;
30 } /* end of parallel */
31 return ((result1 == result2) && (result2 == dummy) && (result2 == 3));
34 int main()
36 int i;
37 int num_failed=0;
39 // the test requires more than 1 thread to pass
40 omp_set_dynamic(0); // disable dynamic adjustment of threads
41 if (omp_get_max_threads() == 1)
42 omp_set_num_threads(2); // set 2 threads if no HW resources available
44 for (i = 0; i < REPETITIONS; i++) {
45 if(!test_omp_flush()) {
46 num_failed++;
49 return num_failed;