Huge thanks for looking into this! It works!
But now I found (perhaps?) another bug when I add this one line to the `transform` function in pet_loopback.c (detailed diff at the below).
```
p = isl_printer_print_schedule_constraints(p, schedule);
```
I get a segfault with the following error message preceding it:
```
isl_output.c:1710: invalid output format for isl_union_set
```
The input file is same as in my previous email, with the fixed index `idx = i * N + j` (correct) instead of `idx = i * M + j` (wrong). File added to the end of the email for completeness.
My question is similar to the one before, is this expected/unexpected? Am I the one doing something wrong?
Best,
E
git diff pet_loopback.c
diff --git a/pet_loopback.c b/pet_loopback.c
index fe22129..de89f2b 100644
--- a/pet_loopback.c
+++ b/pet_loopback.c
@@ -36,6 +36,7 @@
#include <isl/id_to_id.h>
#include <isl/options.h>
#include <isl/printer.h>
+#include <isl/schedule.h>
#include <isl/val.h>
#include <pet.h>
@@ -442,6 +443,7 @@ static __isl_give isl_printer *transform(__isl_take isl_printer *p,
p = print_macros(p, node);
p = isl_ast_node_print(node, p, print_options);
p = print_end_declarations(p, indent);
+ p = isl_printer_print_schedule_constraints(p, schedule);
isl_ast_node_free(node);
isl_ast_build_free(build);
isl_id_to_id_free(id2stmt);
// input.c ///////////////////////////////////////////////////////////////////////////////////////////////
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
void f(size_t M, size_t N, double data[M][N]) {
// first scop: horizontal stencil
for (size_t i = 0; i < M; i++) {
for (size_t j = 1; j < N - 1; j++) {
data[i][j] = (data[i - 1][j] + data[i][j] + data[i + 1][j]) / 3;
}
}
// non-scop part;
int r = rand() % (N * M);
for (size_t t = 1; t < r; t++) {
// int r = rand();
size_t i = r / N, j = r % N;
if (r == 0) {
data[i][j] = 0;
data[i][j] -= 0.5 * data[i][j];
} else {
data[i][j] -= 1.5 * data[i][j];
}
}
// second scop: vertical stencil
for (size_t i = 1; i < M - 1; i++) {
for (size_t j = 0; j < N; j++) {
data[i][j] = (data[i][j - 1] + data[i][j] + data[i][j + 1]) / 3;
}
}
}
void g(size_t M, size_t N, double data[M][N]) {
// third stencil
for (size_t i = 1; i < M - 1; i++) {
for (size_t j = 1; j < N - 1; j++) {
data[i][j] = (data[i][j - 1] + data[i - 1][j] + data[i][j] +
data[i + 1][j] + data[i][j + 1]) /
5;
}
}
}
void init(size_t M, size_t N, double data[M][N]) {
for (size_t i = 0; i < M; i++) {
for (size_t j = 0; j < N; j++) {
data[i][j] = rand();
}
}
}
void print_matrix(size_t M, size_t N, double data[M][N]) {
for (size_t i = 0; i < M; i++) {
for (size_t j = 1; j < N - 1; j++) {
size_t idx = i * N + j;
printf("%15.2lf ", data[i][j]);
}
printf("\n");
}
}
int main(int argc, char *argv[]) {
size_t M = 10, N = 10;
double data[M][N];
init(M, N, data);
print_matrix(M, N, data);
f(M, N, data);
g(M, N, data);
printf("====\n");
print_matrix(M, N, data);
printf("Done\n");
return 0;
}