LLVM OpenMP
20.0.0git
runtime
test
tasking
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
6
int
a
;
7
8
void
inc_a
() {
9
#pragma omp task
10
{
11
#pragma omp atomic
12
a
++;
13
}
14
}
15
16
int
main
() {
17
int
n;
18
int
nth_outer;
19
omp_set_max_active_levels
(2);
20
omp_set_dynamic
(0);
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
}
inc_a
void inc_a()
Definition:
issue-87307.c:8
a
int a
Definition:
issue-87307.c:6
main
int main()
Definition:
issue-87307.c:16
i
#define i
Definition:
kmp_stub.cpp:87
omp_set_max_active_levels
#define omp_set_max_active_levels
Definition:
kmp_stub.cpp:29
omp_set_dynamic
#define omp_set_dynamic
Definition:
kmp_stub.cpp:35
omp_get_num_threads
int omp_get_num_threads()
Generated on Wed Jan 29 2025 20:58:02 for LLVM OpenMP by
1.9.6