LLVM OpenMP 20.0.0git
issue-94260-1.cpp
Go to the documentation of this file.
1// RUN: %libomp-cxx-compile-and-run
2
3#include <assert.h>
4#include <stdio.h>
5#include <stdlib.h>
6#include <omp.h>
7
8// The number of times to run each test
9#define NTIMES 2
10
11// Every thread creates a single "increment" task
12void test_tasks() {
13 for (int i = 0; i < 100; ++i)
14#pragma omp task
15 {
16 int tid = omp_get_thread_num();
17 }
18}
19
20// Testing single level of parallelism with increment tasks
21void test_base(int nthreads) {
22#ifdef VERBOSE
23#pragma omp master
24 printf(" test_base(%d)\n", nthreads);
25#endif
26#pragma omp parallel num_threads(nthreads)
27 { test_tasks(); }
28}
29
30// Testing nested parallel with increment tasks
31// first = nthreads of outer parallel
32// second = nthreads of nested parallel
33void test_nest(int first, int second) {
34#ifdef VERBOSE
35#pragma omp master
36 printf(" test_nest(%d, %d)\n", first, second);
37#endif
38#pragma omp parallel num_threads(first)
39 {
40 for (int i = 0; i < 100; ++i)
41#pragma omp task
42 {
43 int tid = omp_get_thread_num();
44 }
45 test_base(second);
46 }
47}
48
49template <typename... Args>
50void run_ntimes(int n, void (*func)(Args...), Args... args) {
51 for (int i = 0; i < n; ++i) {
52 func(args...);
53 }
54}
55
56int main() {
58
59 for (int i = 0; i < 100; ++i) {
62 }
63
64 printf("PASS\n");
65 return EXIT_SUCCESS;
66}
void run_ntimes(int n, void(*func)(Args...), Args... args)
#define NTIMES
void test_base(int nthreads)
int main()
void test_nest(int first, int second)
void test_tasks()
#define args
#define i
Definition: kmp_stub.cpp:87
#define omp_set_max_active_levels
Definition: kmp_stub.cpp:29
void func(int *num_exec)