bondhugula / pluto

Pluto: An automatic polyhedral parallelizer and locality optimizer
http://pluto-compiler.sourceforge.net
MIT License
274 stars 66 forks source link

Code distribution failed #32

Open ThinhinaneIhadadene opened 5 years ago

ThinhinaneIhadadene commented 5 years ago

I tried to distribute this implementation of warp_affine, which I could parallelize with Pluto

  float A00,A01,A10,A11;
  int coord_00_c,coord_00_r,coord_01_c,coord_01_r,coord_10_c,coord_10_r,coord_11_c,coord_11_r;
  float o_r,o_c,r,c;  double t_start, t_end;
    init_array() ;
    IF_TIME(t_start = rtclock());
  int n_r,n_c;
 int i,j;
 const float a00=0.1f;
 const float a01=0.1f;
 const float a10=0.1f;
 const float a11=0.1f;
 const float b00=0.1f;
 const float b10 =0.1f;
#pragma scop
    for (n_r = 0; n_r < ROWS; n_r++) {
        for (n_c = 0; n_c < COLS; n_c++) {
            o_r = a11 * n_r + a10 * n_c + b00;
            o_c = a01 * n_r + a00 * n_c + b10;
            r = o_r - floorf(o_r);
            c = o_c - floorf(o_c);
            coord_00_r = floorf(o_r);
            coord_00_c = floorf(o_c);
            coord_01_r = coord_00_r;
            coord_01_c = coord_00_c + 1;
            coord_10_r = coord_00_r + 1;
            coord_10_c = coord_00_c;
            coord_11_r = coord_00_r + 1;
            coord_11_c = coord_00_c + 1;
            coord_00_r = clamp(coord_00_r, 0, ROWS - 1);
            coord_00_c = clamp(coord_00_c, 0, COLS - 1);
            coord_01_r = clamp(coord_01_r, 0, ROWS - 1);
            coord_01_c = clamp(coord_01_c, 0, COLS - 1);
            coord_10_r = clamp(coord_10_r, 0, ROWS - 1);
            coord_10_c = clamp(coord_10_c, 0, COLS - 1);
            coord_11_r = clamp(coord_11_r, 0, ROWS - 1);
            coord_11_c = clamp(coord_11_c, 0, COLS - 1);
             A00 = src[coord_00_r][coord_00_c];
             A10 = src[coord_10_r][coord_10_c];
             A01 = src[coord_01_r][coord_01_c];
             A11 = src[coord_11_r][coord_11_c];
           dst[n_r][n_c] = mixf(mixf(A00, A10, r), mixf(A01, A11, r), c);
          }
        }
#pragma endscop

and it failed with this error :

[CLooG] INFO: 1 dimensions (over 3) are scalar.
pluto: ast_transform.c:193: pluto_mark_parallel: Assertion `stmt->ploop_id == i' failed.
../../polycc: line 60:  5016 Aborted                 (core dumped) $pluto $*

Here is the folder which contains the whole code and all the required files, it also contains the full output. warp_affine.zip. I get the same error when I try to use a scalar variable with a reduction, here is an example :

int q,w,cc,e,r;
init_array() ;
 float prod1;
#pragma scop
for (int q = 0; q < ROWS - 5; q++) {
    for (int w = 0; w < COLS - 5; w++) {
        for (int cc = 0; cc < 3; cc++) {
            prod1=0.0f;
            for (int r = 0; r < 5; r++) {
              prod1 += src[q + r][w][cc] * kernelX[r];
            }
            temp[q][w][cc] = prod1;
        }
    }
}
#pragma endscop

I also get ./isl_list_templ.c:246: index out of bounds when running make par, I couldn't understand why. Thanks.

bondhugula commented 5 years ago

Thanks for reporting this. Sorry about the slow response - I'll be able to look at this by this weekend. Pluto has no support for detecting private / local vars. So I wouldn't replace temp[q][w][cc] by a scalar. The compiler you finally use will likely do this scalar replacement on the generated code.

ThinhinaneIhadadene commented 5 years ago

Thanks. what about the warp affine algorithm, why it couldn't be distributed while it could be parallelized?

bondhugula commented 5 years ago

Can I know which version of Pluto you are using?

$ ./polycc -v

ThinhinaneIhadadene commented 5 years ago

the output of ./polycc -v is PLUTO 0.11.4-311-g28e4655