LLVM OpenMP
20.0.0git
runtime
test
worksharing
for
omp_for_collapse.c
Go to the documentation of this file.
1
// RUN: %libomp-compile-and-run
2
#include <stdio.h>
3
#include <math.h>
4
#include "
omp_testsuite.h
"
5
6
/* Utility function to check that i is increasing monotonically
7
with each call */
8
static
int
check_i_islarger
(
int
i
)
9
{
10
static
int
last_i
;
11
int
islarger;
12
if
(
i
==1)
13
last_i
=0;
14
islarger = ((
i
>=
last_i
)&&(
i
-
last_i
<=1));
15
last_i
=
i
;
16
return
(islarger);
17
}
18
19
int
test_omp_for_collapse
()
20
{
21
int
is_larger = 1;
22
23
#pragma omp parallel
24
{
25
int
i
,
j
;
26
int
my_islarger = 1;
27
#pragma omp for private(i,j) schedule(static,1) collapse(2) ordered
28
for
(
i
= 1;
i
< 100;
i
++) {
29
for
(
j
=1;
j
<100;
j
++) {
30
#pragma omp ordered
31
my_islarger =
check_i_islarger
(
i
)&&my_islarger;
32
}
33
}
34
#pragma omp critical
35
is_larger = is_larger && my_islarger;
36
}
37
return
(is_larger);
38
}
39
40
int
main
()
41
{
42
int
i
;
43
int
num_failed=0;
44
45
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
46
if
(!
test_omp_for_collapse
()) {
47
num_failed++;
48
}
49
}
50
return
num_failed;
51
}
i
#define i
Definition:
kmp_stub.cpp:87
check_i_islarger
static int check_i_islarger(int i)
Definition:
omp_for_collapse.c:8
test_omp_for_collapse
int test_omp_for_collapse()
Definition:
omp_for_collapse.c:19
main
int main()
Definition:
omp_for_collapse.c:40
last_i
static int last_i
Definition:
omp_for_ordered.c:6
j
int j
Definition:
omp_single_copyprivate.c:6
omp_testsuite.h
REPETITIONS
#define REPETITIONS
Definition:
omp_testsuite.h:13
Generated on Tue Mar 11 2025 11:24:46 for LLVM OpenMP by
1.9.6