Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / runtime / test / api / omp_pause_resource.c
blobe4aaa51861b8e2912214a79c974273fafc3d0707
1 // RUN: %libomp-compile-and-run
3 // Linking fails for icc 18/19
4 // UNSUPPORTED: icc-18, icc-19
6 #include <stdio.h>
7 #include "omp_testsuite.h"
9 int test_omp_pause_resource() {
10 int fails, nthreads, my_dev;
12 fails = 0;
13 nthreads = 0;
14 my_dev = omp_get_initial_device();
16 #pragma omp parallel
17 #pragma omp single
18 nthreads = omp_get_num_threads();
20 if (omp_pause_resource(omp_pause_soft, my_dev))
21 fails++;
23 #pragma omp parallel shared(nthreads)
24 #pragma omp single
25 nthreads = omp_get_num_threads();
27 if (nthreads == 0)
28 fails++;
29 if (omp_pause_resource(omp_pause_hard, my_dev))
30 fails++;
31 nthreads = 0;
33 #pragma omp parallel shared(nthreads)
34 #pragma omp single
35 nthreads = omp_get_num_threads();
37 if (nthreads == 0)
38 fails++;
39 if (omp_pause_resource_all(omp_pause_soft))
40 fails++;
41 nthreads = 0;
43 #pragma omp parallel shared(nthreads)
44 #pragma omp single
45 nthreads = omp_get_num_threads();
47 if (nthreads == 0)
48 fails++;
49 return fails == 0;
52 int main() {
53 int i;
54 int num_failed = 0;
56 for (i = 0; i < REPETITIONS; i++) {
57 if (!test_omp_pause_resource()) {
58 num_failed++;
61 return num_failed;