1 // RUN: %libomp-cxx-compile-and-run
8 // The number of times to run each test
11 // Every thread creates a single "increment" task
13 for (int i
= 0; i
< 100; ++i
)
16 int tid
= omp_get_thread_num();
20 // Testing single level of parallelism with increment tasks
21 void test_base(int nthreads
) {
24 printf(" test_base(%d)\n", nthreads
);
26 #pragma omp parallel num_threads(nthreads)
30 // Testing nested parallel with increment tasks
31 // first = nthreads of outer parallel
32 // second = nthreads of nested parallel
33 void test_nest(int first
, int second
) {
36 printf(" test_nest(%d, %d)\n", first
, second
);
38 #pragma omp parallel num_threads(first)
40 for (int i
= 0; i
< 100; ++i
)
43 int tid
= omp_get_thread_num();
49 template <typename
... Args
>
50 void run_ntimes(int n
, void (*func
)(Args
...), Args
... args
) {
51 for (int i
= 0; i
< n
; ++i
) {
57 omp_set_max_active_levels(5);
59 for (int i
= 0; i
< 100; ++i
) {
60 run_ntimes(NTIMES
, test_nest
, 4, 3);
61 run_ntimes(NTIMES
, test_nest
, 2, 1);