Go to the previous, next section.

### Simple Examples

Here we show a couple of simple examples to illustrate how to use tiling, and what the resulting code looks like. Given the following code (since tiling only changes the loop bounds and not the body, we only show the bounds here):

```for (i = 0; i <= N; i++) {
for (j = i; j <= N; j++) {
...
}
}
```

If we use the following parameters:

```trip[0] = 100; trip[1] = 50;
nregions = 1;
coalesce[0] = FALSE;
first[0] = 0; first[1] = 2;
```

The resulting code is:

```for (i_tile = 0; i_tile <= N; i_tile += 100) {
for (j_tile = i_tile; j_tile <= N; j += 50) {
for (i = i_tile; i <= min(N, i_tile + 99); i++) {
for (j = max(i, j_tile); j <= min(i, j_tile + 49); j++) {
...
}
}
}
}
```

If coalescing is turned on for the above example (setting coalesce[0] = TRUE), the resulting code is:

```for (j_tile = 0; j_tile <= N; j_tile += 50) {
for (i = 0; i <= N; i++) {
for (j = max(i, j_tile); j <= min(i, j_tile + 49); j++) {
...
}
}
}
```

Go to the previous, next section.