From 73ee65e317724cd48087f0dc0bd8ed8c63a9ffa6 Mon Sep 17 00:00:00 2001 From: jihoonl Date: Thu, 8 Oct 2009 23:28:12 +0000 Subject: [PATCH] state.DSMTASK flag is added --- .../Analysis/Locality/LocalityAnalysis.java | 72 ++++++++++--------- Robust/src/IR/Flat/BuildCode.java | 13 ++-- Robust/src/IR/State.java | 1 + Robust/src/IR/TypeUtil.java | 5 ++ 4 files changed, 55 insertions(+), 36 deletions(-) diff --git a/Robust/src/Analysis/Locality/LocalityAnalysis.java b/Robust/src/Analysis/Locality/LocalityAnalysis.java index 07cfb310..27c0c9c9 100644 --- a/Robust/src/Analysis/Locality/LocalityAnalysis.java +++ b/Robust/src/Analysis/Locality/LocalityAnalysis.java @@ -193,10 +193,14 @@ public class LocalityAnalysis { Stack lbstack=new Stack(); 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()); 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()); - classtolb.get(lbexecute.getMethod().getClassDesc()).add(lbexecute); - - if (!methodtolb.containsKey(lbexecute.getMethod())) - methodtolb.put(lbexecute.getMethod(), new HashSet()); - 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()); + classtolb.get(lbexecute.getMethod().getClassDesc()).add(lbexecute); + + if (!methodtolb.containsKey(lbexecute.getMethod())) + methodtolb.put(lbexecute.getMethod(), new HashSet()); + 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"); } } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 31f3a482..0cac7b65 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -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())); diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index 9785db6c..ebec6914 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -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; diff --git a/Robust/src/IR/TypeUtil.java b/Robust/src/IR/TypeUtil.java index ce0ead6f..50b02076 100644 --- a/Robust/src/IR/TypeUtil.java +++ b/Robust/src/IR/TypeUtil.java @@ -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()) -- 2.34.1