LLVM OpenMP
nest-zero-trip.c
Go to the documentation of this file.
1// RUN: %libomp-compile -fopenmp-version=60 && %libomp-run \
2// RUN: | FileCheck %s --match-full-lines
3
4// After tile/stripe of a loop nest, each loop variable must hold the value it
5// would have without the directive (OpenMP 6.0). An inner loop variable is
6// only assigned if every enclosing loop has iterations.
7
8#ifndef HEADER
9#define HEADER
10
11#include <stdlib.h>
12#include <stdio.h>
13
14static void tile(int n, int m) {
15 int i = 77, j = 111;
16#pragma omp tile sizes(2, 3)
17 for (i = 0; i < n; i++)
18 for (j = 0; j < m; j++)
19 ;
20 printf("tile n=%d m=%d: i=%d j=%d\n", n, m, i, j);
21}
22
23static void stripe(int n, int m) {
24 int i = 77, j = 111;
25#pragma omp stripe sizes(2, 3)
26 for (i = 0; i < n; i++)
27 for (j = 0; j < m; j++)
28 ;
29 printf("stripe n=%d m=%d: i=%d j=%d\n", n, m, i, j);
30}
31
32int main() {
33 // Outer loop never runs: j untouched.
34 tile(0, 5);
35 // Inner loop never runs: j gets its init value.
36 tile(6, 0);
37 // All loops run: exit values.
38 tile(6, 5);
39 stripe(0, 5);
40 stripe(6, 0);
41 stripe(6, 5);
42 return EXIT_SUCCESS;
43}
44#endif /* HEADER */
45
46// CHECK: tile n=0 m=5: i=0 j=111
47// CHECK-NEXT: tile n=6 m=0: i=6 j=0
48// CHECK-NEXT: tile n=6 m=5: i=6 j=5
49// CHECK-NEXT: stripe n=0 m=5: i=0 j=111
50// CHECK-NEXT: stripe n=6 m=0: i=6 j=0
51// CHECK-NEXT: stripe n=6 m=5: i=6 j=5
int main()
#define i
Definition kmp_stub.cpp:88
static void tile(int n, int m)
static void stripe(int n, int m)