LLVM OpenMP
20.0.0git
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
c
d
e
g
h
i
m
n
p
r
s
t
u
Functions
c
d
e
g
i
m
n
p
r
s
u
Variables
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
w
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
Enumerations
Enumerator
Related Functions
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Typedefs
_
a
b
c
d
e
i
k
l
m
n
o
p
r
t
u
Enumerations
_
b
c
d
f
k
l
n
o
s
t
Enumerator
_
a
b
c
d
e
f
k
l
n
o
p
r
s
t
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
runtime
test
parallel
omp_nested.c
Go to the documentation of this file.
1
// RUN: %libomp-compile-and-run
2
#include <stdio.h>
3
#include "
omp_testsuite.h
"
4
5
/*
6
* Test if the compiler supports nested parallelism
7
* By Chunhua Liao, University of Houston
8
* Oct. 2005
9
*/
10
int
test_omp_nested
()
11
{
12
#ifdef _OPENMP
13
if
(
omp_get_max_threads
() > 4)
14
omp_set_num_threads
(4);
15
if
(
omp_get_max_threads
() < 2)
16
omp_set_num_threads
(2);
17
#endif
18
19
int
counter
= 0;
20
#ifdef _OPENMP
21
omp_set_nested
(1);
22
omp_set_max_active_levels
(omp_get_supported_active_levels());
23
#endif
24
25
#pragma omp parallel shared(counter)
26
{
27
#pragma omp critical
28
counter
++;
29
#pragma omp parallel
30
{
31
#pragma omp critical
32
counter
--;
33
}
34
}
35
return
(
counter
!= 0);
36
}
37
38
int
main
()
39
{
40
int
i
;
41
int
num_failed=0;
42
43
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
44
if
(!
test_omp_nested
()) {
45
num_failed++;
46
}
47
}
48
return
num_failed;
49
}
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_num_threads
#define omp_set_num_threads
Definition:
kmp_stub.cpp:34
omp_set_nested
#define omp_set_nested
Definition:
kmp_stub.cpp:36
counter
int counter
Definition:
kmp_taskloop.c:13
test_omp_nested
int test_omp_nested()
Definition:
omp_nested.c:10
main
int main()
Definition:
omp_nested.c:38
omp_testsuite.h
REPETITIONS
#define REPETITIONS
Definition:
omp_testsuite.h:13
omp_get_max_threads
int omp_get_max_threads()
Generated on Wed Jun 11 2025 14:17:21 for LLVM OpenMP by
1.9.6