Skip to content

roxtar/mayhappy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MAY HAPPEN IN PARALLEL ANALYSIS
-------------------------------

Program Based on the paper 
1. http://www.cs.ucla.edu/~palsberg/paper/ppopp10.pdf
2. http://www.cs.ucla.edu/~palsberg/draft/lpm10.pdf

Requirements

javacc version 5.0 http://javacc.java.net/
jtb version 1.2.2 http://www.cs.ucla.edu/~palsberg/jtb/
javac version 1.6.*


Build:
	make

Run:
	java MayHappyMain examples/Simple.x10

Where Simple.x10 is a Featherweight X10 source file. The analysis
will follow X10's program executionp path -- i.e it will follow the
flow of statements as described in the main function.

Output:

For each line of ClassName.FuncName the MHP set will be shown.

For example, for the code:

 public class Simple {    
    public static void main(String[] args) {
	new Foo().foo();
    }
}

class Foo {
    public void foo() {
	int i = 0;
	System.out.println("Hello there");
	async (0) {
	    i = i + 1;
	    i = i + 3;
	}	
	i  = i -1;
	i = i + 2;
    }
}

The final result should be :

MHP (End)
{
(L2:i=i+1;, L4:i=i-1;)
(L5:i=i+2;, L3:i=i+3;)
(L3:i=i+3;, L5:i=i+2;)
(L4:i=i-1;, L2:i=i+1;)
(L3:i=i+3;, L4:i=i-1;)
(L2:i=i+1;, L5:i=i+2;)
(L4:i=i-1;, L3:i=i+3;)
(L5:i=i+2;, L2:i=i+1;)
}

The above listing shows the statements which can be executed in
parallel (may happen in parallel -- MHP) to the end of the
program. The output actually contains more detail. In fact it contains
the MHP sets at each statement. 

In the output at any stage the M, O, L values denote:
   M -- The statements that may be executing in parallel
	at that particular stage.
   O -- The statements which will be executing after the end of 
	the particular statement.
   L -- the statements which were executed as part of the statement.

Notes:

1. The jtb example to invoke the visitor on the top level javacc
parser class goes something like:

     try {
         Node root = parser.CompilationUnit();
         System.err.println("Java program parsed successfully.");
         root.accept(new DepthFirstVisitor());
      }

With newer version of javacc this is changed to:

     try {
         Node root = parser.File();
         System.err.println("Java program parsed successfully.");
         root.accept(new DepthFirstVisitor());
      }

Design

Each node has the sets, M, O and L. The meaning of s : M, O, L is that
s has MHP information M , that while s is executing statements with
labels in L will be executed, and when s terminates, statements with
labels in O may still be executing. Paper 2, illustrates the rules in
deriving these values (Section 5 Type Systems).


The program maintains the (M, O, L) sets per statement and also at a
global level. The global (M_g, O_g, L_g) contain values which are used
to compute the local (M, O, L) sets. 

The class MhpVisitor traverses through the syntax tree of the program
and sets the (M, O, L) values of each statement. Initially (M_g, O_g,
L_g) are all ({}, {}, {}) empty sets. When the MhpVisitor traverses
the syntax tree, these sets are populated according to the rules.

Rules:

	async s1 -- M = M, O = L_s1, L = L_s1
	finish s1 -- M = M, O = O_s1 - L_s1, L = L_s1
	loop s1 -- M = symcross(O_s1, L_s1), O=O_s1, L=L_s1
	s1;s2 -- M = symcross(O_s1, L_s2), O = O_s1 U O_s2, L = L_s1 U L_s2

Author:
Rohit Kumar	

About

May Happen In Parallel Analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages