1// RUN: %libomp-compile-and-run
2
3// Linking fails for icc 18/19
4// UNSUPPORTED: icc-18, icc-19
5
6#include <stdio.h>
7#include "omp_testsuite.h"
8
9int test_omp_pause_resource() {
10 int fails, nthreads, my_dev;
11
12 fails = 0;
13 nthreads = 0;
14 my_dev = omp_get_initial_device();
15
16#pragma omp parallel
17#pragma omp single
18 nthreads = omp_get_num_threads();
19
20 if (omp_pause_resource(omp_pause_soft, my_dev))
21 fails++;
22
23#pragma omp parallel shared(nthreads)
24#pragma omp single
25 nthreads = omp_get_num_threads();
26
27 if (nthreads == 0)
28 fails++;
29 if (omp_pause_resource(omp_pause_hard, my_dev))
30 fails++;
31 nthreads = 0;
32
33#pragma omp parallel shared(nthreads)
34#pragma omp single
35 nthreads = omp_get_num_threads();
36
37 if (nthreads == 0)
38 fails++;
39 if (omp_pause_resource_all(omp_pause_soft))
40 fails++;
41 nthreads = 0;
42
43#pragma omp parallel shared(nthreads)
44#pragma omp single
45 nthreads = omp_get_num_threads();
46
47 if (nthreads == 0)
48 fails++;
49 return fails == 0;
50}
51
52int main() {
53 int i;
54 int num_failed = 0;
55
56 for (i = 0; i < REPETITIONS; i++) {
57 if (!test_omp_pause_resource()) {
58 num_failed++;
59 }
60 }
61 return num_failed;
62}
63

source code of openmp/runtime/test/api/omp_pause_resource.c