LLVM OpenMP 20.0.0git
issue-87307.c
Go to the documentation of this file.
1// RUN: %libomp-compile-and-run
2#include <stdio.h>
3#include <stdlib.h>
4#include <omp.h>
5
6int a;
7
8void inc_a() {
9#pragma omp task
10 {
11#pragma omp atomic
12 a++;
13 }
14}
15
16int main() {
17 int n;
18 int nth_outer;
21
22 for (n = 0; n < 200; ++n) {
23 a = 0;
24#pragma omp parallel num_threads(8)
25 {
26 if (omp_get_thread_num() == 0)
27 nth_outer = omp_get_num_threads();
28#pragma omp parallel num_threads(2)
29 {
30 int i;
31#pragma omp master
32 for (i = 0; i < 50; ++i)
33 inc_a();
34 }
35 }
36 if (a != nth_outer * 50) {
37 fprintf(stderr, "error: a (%d) != %d\n", a, nth_outer * 50);
38 return EXIT_FAILURE;
39 }
40 }
41
42 return EXIT_SUCCESS;
43}
void inc_a()
Definition: issue-87307.c:8
int a
Definition: issue-87307.c:6
int main()
Definition: issue-87307.c:16
#define i
Definition: kmp_stub.cpp:87
#define omp_set_max_active_levels
Definition: kmp_stub.cpp:29
#define omp_set_dynamic
Definition: kmp_stub.cpp:35
int omp_get_num_threads()