how to generate merged loops using cloog?

20 views
Skip to first unread message

Sourav Mukherjee

unread,
Aug 19, 2013, 9:35:40 AM8/19/13
to cl...@googlegroups.com
Hello cloog users,

What option should be passed to cloog to generate merged loops? Suppose I have the following program (named 'merge_try.c'):

int main(void){
int n=100,m=50;
int i,j;
int x[n][m];
int y[n][m];

#pragma scop
for(i=0; i<n; i++)
 for(j=0; j<m; j++)
  x[i][j]=i-j;

for(i=0; i<n; i++)
 for(j=0; j<m; j++)
  y[i][j]=i+j;

#pragma endscop

}


I generate the .scop file using clan

$ clan merge_try.c > merge_try.scop

Now, I want to use cloog to generate the following loop:


for(i=0; i<n; i++)
 for(j=0; j<m; j++)
  x[i][j]=i-j;
  y[i][j]=i+j;



Is it possible to generate the above loop using cloog? When I try:

$ cloog -openscop merge_try.scop

I get the following program as output, in which the loops are not merged:

/* Useful macros. */
#define floord(n,d) (((n)<0) ? -((-(n)+(d)-1)/(d)) : (n)/(d))
#define ceild(n,d)  (((n)<0) ? -((-(n))/(d)) : ((n)+(d)-1)/(d))
#define max(x,y)    ((x) > (y) ? (x) : (y))
#define min(x,y)    ((x) < (y) ? (x) : (y))


int main(void){
int n=100,m=50;
int i,j;
int x[n][m];
int y[n][m];

#pragma scop
if ((m >= 1) && (n >= 1)) {
  for (i=0;i<=n-1;i++) {
    for (j=0;j<=m-1;j++) {
      x[i][j]=(i)-(j);
    }
  }
  for (i=0;i<=n-1;i++) {
    for (j=0;j<=m-1;j++) {
      y[i][j]=i+j;
    }
  }
}
#pragma endscop

}


Kindly help.

(I'm using CLooG 0.18.0 and clan 0.7.1 .)

Thanks,
Sourav

Sourav Mukherjee

unread,
Aug 19, 2013, 9:37:54 AM8/19/13
to cl...@googlegroups.com
(Correction:) I mean to generate the following loop:

Cédric Bastoul

unread,
Aug 19, 2013, 10:05:57 AM8/19/13
to Sourav Mukherjee, CLooG
Hi Sourav,
you need to modify the scattering relation(s) (a.k.a. scheduling relations). The output of Clan has the scattering relations corresponding to the original order. So directly calling CLooG will regenerate something equivalent to the input code. If you change the scattering relation of the second statement to (0,i,0,j,1) you will get the loop fusion you are looking for. I attached the corresponding scop file. I suggest to read this :
or that (chapter 2) :
for a better understanding of scattering relations.
Best,

Cedric

NB : for a direct translation you could do
$ clan merge_try.c | cloog -openscop stdin



--
--
You got this message because you subscribed to the CLooG mailing list.
To send messages to this list, use cl...@googlegroups.com
To stop subscribing, send a mail to cloog+un...@googlegroups.com
For more options and to visit the group, http://groups.google.fr/group/cloog?hl=en
 
---
You received this message because you are subscribed to the Google Groups "CLooG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloog+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

test.scop

Sourav Mukherjee

unread,
Aug 19, 2013, 10:34:15 AM8/19/13
to Cédric Bastoul, CLooG
Dr. Cedric Bastoul,

Thank you for the solution and the relevant docs. Thanks also for the tip to pipe the output of clan to cloog!

Could you please tell me then, for analyzing a .scop file and generating optimized loops (I am especially interested in fused loops) what tool should I use? I have visited http://www.cs.ucla.edu/~pouchet/software/pocc/ . Is Pluto the correct tool?

Regards,
Sourav

Cédric Bastoul

unread,
Aug 19, 2013, 11:10:35 AM8/19/13
to Sourav Mukherjee, CLooG, Taj Khan
On Mon, Aug 19, 2013 at 4:34 PM, Sourav Mukherjee <sourav...@gmail.com> wrote:
Dr. Cedric Bastoul,

Thank you for the solution and the relevant docs. Thanks also for the tip to pipe the output of clan to cloog!

Could you please tell me then, for analyzing a .scop file and generating optimized loops (I am especially interested in fused loops) what tool should I use? I have visited http://www.cs.ucla.edu/~pouchet/software/pocc/ . Is Pluto the correct tool?

Yes. However, Pluto is still working on another .scop format ("SCoPLib", the previous generation). We have a development version of a Pluto/OpenScop (actually the complete toolchain with OpenScop, hopefully it will be merged to the official Pluto soon) : ask Taj (in CC) for further details.

If you are really focusing on fusion, you may have a look at Clay :
This tool offers a scripting system to let you set the sequence of tranformation you need. It alters the .scop according to the sequence of transformation you like. It lacks documentation at the moment but looking at the test directory and at the -help option will help you. Section 3.3 of https://www.lri.fr/~bastoul/research/p, we will send a patch for Pluto soonapers/Bastoul_HDR.pdf will help as well :-).
Best,

Cedric
 

Regards,
Sourav


On Mon, Aug 19, 2013 at 7:35 PM, Cédric Bastoul <cedric....@unistra.fr> wrote:
Hi Sourav,
you need to modify the scattering relation(s) (a.k.a. scheduling relations). The output of Clan has the scattering relations corresponding to the original order. So directly calling CLooG will regenerate something equivalent to the input code. If you change the scattering relation of the second statement to (0,i,0,j,1) you will get the loop fusion you are looking for. I attached the corresponding scop file. I suggest to read this :
or that (chapter 2) :
Reply all
Reply to author
Forward
0 new messages