LLVM OpenMP
runtime
test
transform
flatten
empty.c
Go to the documentation of this file.
1
// RUN: %libomp-compile -fopenmp-version=61 && %libomp-run \
2
// RUN: | FileCheck %s --match-full-lines
3
4
#ifndef HEADER
5
#define HEADER
6
7
#include <stdlib.h>
8
#include <stdio.h>
9
10
// The bounds are runtime values so that an empty iteration space does not
11
// trigger a compile-time division-by-zero diagnostic for the (never executed)
12
// induction-variable recovery.
13
static
void
flatten
(
int
n,
int
m) {
14
#pragma omp flatten
15
for
(
int
i
= 0;
i
< n; ++
i
)
16
for
(
int
j
= 0;
j
< m; ++
j
)
17
printf(
"i=%d j=%d\n"
,
i
,
j
);
18
}
19
20
int
main
() {
21
printf(
"empty-inner-begin\n"
);
22
flatten
(3, 0);
23
printf(
"empty-inner-end\n"
);
24
25
printf(
"empty-outer-begin\n"
);
26
flatten
(0, 3);
27
printf(
"empty-outer-end\n"
);
28
29
printf(
"single-begin\n"
);
30
flatten
(1, 1);
31
printf(
"single-end\n"
);
32
33
printf(
"neg-outer-begin\n"
);
34
#pragma omp flatten
35
for
(
int
i
= 0;
i
< -1; ++
i
)
36
for
(
int
j
= 0;
j
< 3; ++
j
)
37
printf(
"i=%d j=%d\n"
,
i
,
j
);
38
printf(
"neg-outer-end\n"
);
39
40
// Two empty loops must not run: unclamped trip counts are both -1, and
41
// (-1)*(-1) would otherwise flatten to a single iteration.
42
printf(
"neg-both-begin\n"
);
43
#pragma omp flatten
44
for
(
int
i
= 0;
i
< -1; ++
i
)
45
for
(
int
j
= 0;
j
< -1; ++
j
)
46
printf(
"i=%d j=%d\n"
,
i
,
j
);
47
printf(
"neg-both-end\n"
);
48
49
printf(
"neg-both-runtime-begin\n"
);
50
flatten
(-1, -1);
51
printf(
"neg-both-runtime-end\n"
);
52
53
printf(
"neg-both-runtime-5-3-begin\n"
);
54
flatten
(-5, -3);
55
printf(
"neg-both-runtime-5-3-end\n"
);
56
return
EXIT_SUCCESS;
57
}
58
59
#endif
/* HEADER */
60
61
// CHECK: empty-inner-begin
62
// CHECK-NEXT: empty-inner-end
63
// CHECK-NEXT: empty-outer-begin
64
// CHECK-NEXT: empty-outer-end
65
// CHECK-NEXT: single-begin
66
// CHECK-NEXT: i=0 j=0
67
// CHECK-NEXT: single-end
68
// CHECK-NEXT: neg-outer-begin
69
// CHECK-NEXT: neg-outer-end
70
// CHECK-NEXT: neg-both-begin
71
// CHECK-NEXT: neg-both-end
72
// CHECK-NEXT: neg-both-runtime-begin
73
// CHECK-NEXT: neg-both-runtime-end
74
// CHECK-NEXT: neg-both-runtime-5-3-begin
75
// CHECK-NEXT: neg-both-runtime-5-3-end
flatten
static void flatten(int n, int m)
Definition
empty.c:13
main
int main()
Definition
empty.c:20
i
#define i
Definition
kmp_stub.cpp:88
j
int j
Definition
omp_single_copyprivate.c:6
Generated on
for LLVM OpenMP by
1.14.0