working with JCForLoop

Jonathan Gibbons jonathan.gibbons at oracle.com
Wed Mar 2 21:47:53 PST 2011


Omkar,

Tree transformations are normally better done in Lower.

-- Jon


On 03/02/2011 05:22 PM, Omkar Raut wrote:
> Hi
>
> I am trying to modify the for loop for parallelization as part of 
> school project i.e. when the body of for loop can be parallelized I 
> will put some threads which do the partial iterations of loop and at 
> the end combine the result. Something like below:
> *Original statements:*
> int[] a = new int[8];
> for(int i=0;i <8; i++){ a[i] = i;}
> *After my modification:*
> int[] a = new int[8];
> class ForThread extends Thread { ... define constructor to take array 
> a, define run method to execute for loop for partial range i.e. a[0] - 
> a[3] & a[4] - a[7] }
> ForThread t1 = new ForThread(a, 0, 3);
> ForThread t2 = new ForThread(a, 4, 7);
> t1.start();
> t2.start();
>
> My approach:
> For this I am changing the AST to include a new Node. I am trying to 
> modify the JavacParser.java at method parseStatement(). When in 
> encounter case FOR: I will return a JCBlock object which has the 
> thread definition and the following statements to execute threads.
>
> Am I going in the right direction? Or I should define a new 
> JCParForLoop object instead of putting JCBlock for the parallelization?
>
> Thank you!
> Omkar Raut

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20110302/0d55988d/attachment.html 


More information about the compiler-dev mailing list