state.DSMTASK flag is added
authorjihoonl <jihoonl>
Thu, 8 Oct 2009 23:28:12 +0000 (23:28 +0000)
committerjihoonl <jihoonl>
Thu, 8 Oct 2009 23:28:12 +0000 (23:28 +0000)
Robust/src/Analysis/Locality/LocalityAnalysis.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/State.java
Robust/src/IR/TypeUtil.java

index 07cfb310ed58da97a5d28531cd2b61686b3799bc..27c0c9c90d720e5a930206db38728f2469c8dbf7 100644 (file)
@@ -193,10 +193,14 @@ public class LocalityAnalysis {
     Stack<LocalityBinding> lbstack=new Stack<LocalityBinding>();
     lbstack.add(lbmain);
     lbstack.add(lbrun);
-    lbstack.add(lbexecute);
+
     lbset.add(lbmain);
     lbset.add(lbrun);
-    lbset.add(lbexecute);
+
+    if(state.DSMTASK) {       // when Task.java is used
+      lbstack.add(lbexecute);
+      lbset.add(lbexecute);
+    }
     while(!lbstack.isEmpty()) {
       LocalityBinding lb=lbstack.pop();
       if (calldep.containsKey(lb)) {
@@ -696,18 +700,20 @@ public class LocalityAnalysis {
       methodtolb.put(lbrun.getMethod(), new HashSet<LocalityBinding>());
     methodtolb.get(lbrun.getMethod()).add(lbrun);
 
-    lbexecute = new LocalityBinding(typeutil.getExecute(), false);
-    lbexecute.setGlobalReturn(EITHER);
-    lbexecute.setGlobalThis(GLOBAL);
-    lbtovisit.add(lbexecute);
-    discovered.put(lbexecute, lbexecute);
-    if (!classtolb.containsKey(lbexecute.getMethod().getClassDesc()))
-      classtolb.put(lbexecute.getMethod().getClassDesc(), new HashSet<LocalityBinding>());
-    classtolb.get(lbexecute.getMethod().getClassDesc()).add(lbexecute);
-
-    if (!methodtolb.containsKey(lbexecute.getMethod()))
-      methodtolb.put(lbexecute.getMethod(), new HashSet<LocalityBinding>());
-    methodtolb.get(lbexecute.getMethod()).add(lbexecute);
+    if(state.DSMTASK) {
+      lbexecute = new LocalityBinding(typeutil.getExecute(), false);
+      lbexecute.setGlobalReturn(EITHER);
+      lbexecute.setGlobalThis(GLOBAL);
+      lbtovisit.add(lbexecute);
+      discovered.put(lbexecute, lbexecute);
+      if (!classtolb.containsKey(lbexecute.getMethod().getClassDesc()))
+        classtolb.put(lbexecute.getMethod().getClassDesc(), new HashSet<LocalityBinding>());
+      classtolb.get(lbexecute.getMethod().getClassDesc()).add(lbexecute);
+
+      if (!methodtolb.containsKey(lbexecute.getMethod()))
+        methodtolb.put(lbexecute.getMethod(), new HashSet<LocalityBinding>());
+      methodtolb.get(lbexecute.getMethod()).add(lbexecute);
+    }
 
     while(!lbtovisit.isEmpty()) {
       LocalityBinding lb=(LocalityBinding) lbtovisit.iterator().next();
@@ -916,27 +922,29 @@ public class LocalityAnalysis {
          methodset.addAll(runmethodset);
        } else throw new Error("Can't find run method");
       }
-    
-      if (nodemd.getClassDesc().getSymbol().equals(TypeUtil.TaskClass) &&
+
+      if(state.DSMTASK) {
+        if (nodemd.getClassDesc().getSymbol().equals(TypeUtil.TaskClass) &&
           nodemd.getSymbol().equals("execution") && !nodemd.getModifiers().isStatic() &&
           nodemd.numParameters() == 0) {
-        assert(nodemd.getModifiers().isNative());
-        
-        MethodDescriptor exemd = null;
-
-        for(Iterator methodit=nodemd.getClassDesc().getMethodTable().getSet("execute").iterator(); methodit.hasNext();) {
-          MethodDescriptor md = (MethodDescriptor) methodit.next();
-
-          if (md.numParameters() != 0 || md.getModifiers().isStatic())
-            continue;
-          exemd = md;
-          break;
+      
+          assert(nodemd.getModifiers().isNative());
+          MethodDescriptor exemd = null;
+
+          for(Iterator methodit=nodemd.getClassDesc().getMethodTable().getSet("execute").iterator(); methodit.hasNext();) {
+            MethodDescriptor md = (MethodDescriptor) methodit.next();
+
+            if (md.numParameters() != 0 || md.getModifiers().isStatic())
+              continue;
+            exemd = md;
+            break;
+          }
+
+          if (exemd != null) {
+            executemethodset = callgraph.getMethods(exemd, fc.getThis().getType());
+            methodset.addAll(executemethodset);
+          } else throw new Error("Can't find execute method");
         }
-
-        if (exemd != null) {
-          executemethodset = callgraph.getMethods(exemd, fc.getThis().getType());
-          methodset.addAll(executemethodset);
-        } else throw new Error("Can't find execute method");
       }
     }
 
index 31f3a482dac3dfbc9198ae1569179b28cd7c082e..0cac7b65b266715e43b76ece9ba9dac2a5f2d40a 100644 (file)
@@ -527,19 +527,24 @@ public class BuildCode {
     outstructs.println("#define MAXCOUNT "+maxcount);
     if (state.DSM||state.SINGLETM) {
       LocalityBinding lbrun=new LocalityBinding(typeutil.getRun(), false);
-      LocalityBinding lbexecute = new LocalityBinding(typeutil.getExecute(), false);
       if (state.DSM) {
        lbrun.setGlobalThis(LocalityAnalysis.GLOBAL);
-  lbexecute.setGlobalThis(LocalityAnalysis.GLOBAL);
       }
       else if (state.SINGLETM) {
        lbrun.setGlobalThis(LocalityAnalysis.NORMAL);
-  lbexecute.setGlobalThis(LocalityAnalysis.NORMAL);
       }
-      outstructs.println("#define EXECUTEMETHOD " + virtualcalls.getLocalityNumber(lbexecute));
       outstructs.println("#define RUNMETHOD "+virtualcalls.getLocalityNumber(lbrun));
     }
 
+    if (state.DSMTASK) {
+      LocalityBinding lbexecute = new LocalityBinding(typeutil.getExecute(), false);
+      if(state.DSM)
+        lbexecute.setGlobalThis(LocalityAnalysis.GLOBAL);
+      else if( state.SINGLETM)
+        lbexecute.setGlobalThis(LocalityAnalysis.NORMAL);
+      outstructs.println("#define EXECUTEMETHOD " + virtualcalls.getLocalityNumber(lbexecute));
+    }
+
     outstructs.println("#define STRINGARRAYTYPE "+
                        (state.getArrayNumber(
                           (new TypeDescriptor(typeutil.getClass(TypeUtil.StringClass))).makeArray(state))+state.numClasses()));
index 9785db6cd5652d377aeddfc81bb43f1782bf7c63..ebec6914f8cac4f9f461a4cc532006b4b7678ba1 100644 (file)
@@ -52,6 +52,7 @@ public class State {
   public boolean TASK=false;
   public boolean FASTCHECK=false;
   public boolean DSM=false;
+  public boolean DSMTASK=false;
   public boolean PREFETCH=false;
   public boolean TASKSTATE=false;
   public boolean TAGSTATE=false;
index ce0ead6fe2060017d3627412b23612b1b7a99166..50b02076f5a9150bf72064159ece52382cf52066 100644 (file)
@@ -52,6 +52,7 @@ public class TypeUtil {
       //have to find class
       addNewClass(classname, todo);
       cd=(ClassDescriptor)state.getClassSymbolTable().get(classname);
+
       System.out.println("Build class:"+cd);
       todo.add(cd);
     }
@@ -86,6 +87,10 @@ public class TypeUtil {
   
   public MethodDescriptor getExecute() {
     ClassDescriptor cd = getClass(TypeUtil.TaskClass);
+
+    if(cd == null && state.DSMTASK)
+      throw new Error("Task.java is not included");
+
     for(Iterator methodit = cd.getMethodTable().getSet("execute").iterator(); methodit.hasNext();) {
       MethodDescriptor md = (MethodDescriptor) methodit.next();
       if (md.numParameters()!=0 || md.getModifiers().isStatic())