X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FMain%2FMain.java;h=748c0027fa06bdfcf33a21ecfae53e671574d0e8;hb=e33201f8be840c89d9e1994a2e742bf01ca8ff0c;hp=5bcfe4353d834fd4ab1bd2d8b8095149d7f0564e;hpb=1c22c0dd30a5c92655985c3376ae174e80217590;p=IRC.git diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 5bcfe435..748c0027 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -17,10 +17,12 @@ import IR.Tree.SemanticCheck; import IR.Flat.BuildCodeMultiCore; import IR.Flat.BuildFlat; import IR.Flat.BuildCode; +import IR.Flat.Inliner; import IR.ClassDescriptor; import IR.State; import IR.TaskDescriptor; import IR.TypeUtil; +import Analysis.Scheduling.MCImplSynthesis; import Analysis.Scheduling.Schedule; import Analysis.Scheduling.ScheduleAnalysis; import Analysis.Scheduling.ScheduleSimulator; @@ -39,6 +41,13 @@ import Analysis.Locality.GenerateConversions; import Analysis.Prefetch.PrefetchAnalysis; import Analysis.FlatIRGraph.FlatIRGraph; import Analysis.OwnershipAnalysis.OwnershipAnalysis; +import Analysis.Disjoint.DisjointAnalysis; +import Analysis.MLP.MLPAnalysis; +import Analysis.Loops.*; +import Analysis.Liveness; +import Analysis.ArrayReferencees; +import IR.MethodDescriptor; +import IR.Flat.FlatMethod; import Interface.*; import Util.GraphNode; import Util.GraphNode.DFS; @@ -51,6 +60,13 @@ public class Main { public static void main(String args[]) throws Exception { String ClassLibraryPrefix="./ClassLibrary/"; State state=new State(); + Vector sourcefiles=new Vector(); + state.classpath.add("."); + + String outputdir = null; + boolean isDistributeInfo = false; + boolean isDisAll = false; + int startnum = 0; for(int i=0; i"); + } + } else if (option.equals("-disjoint-alias-file")) { + state.DISJOINTALIASFILE = args[++i]; + String arg = args[++i]; + if( arg.equals("normal") ) { + state.DISJOINTALIASTAB = false; + } else if( arg.equals("tabbed") ) { + state.DISJOINTALIASTAB = true; + } else { + throw new Error("disjoint-alias-file requires arguments "); + } + } else if (option.equals("-disjoint-debug-callsite")) { + state.DISJOINTDEBUGCALLEE=args[++i]; + state.DISJOINTDEBUGCALLER=args[++i]; + state.DISJOINTDEBUGCALLCOUNT=Integer.parseInt(args[++i]); + } else if (option.equals("-optional")) state.OPTIONAL=true; + else if (option.equals("-optimize")) + state.OPTIMIZE=true; + else if (option.equals("-dcopts")) + state.DCOPTS=true; + else if (option.equals("-arraypad")) + state.ARRAYPAD=true; + else if (option.equals("-delaycomp")) + state.DELAYCOMP=true; else if (option.equals("-raw")) state.RAW=true; else if (option.equals("-scheduling")) state.SCHEDULING=true; - else if (option.equals("-useprofile")) + else if (option.equals("-distributioninfo")) + isDistributeInfo=true; + else if (option.equals("-disall")) + isDisAll=true; + else if (option.equals("-disstart")) + startnum = Integer.parseInt(args[++i]); + else if (option.equals("-useprofile")) { state.USEPROFILE=true; + state.profilename = args[++i]; + } else if (option.equals("-thread")) state.THREAD=true; else if (option.equals("-dsm")) state.DSM=true; + else if (option.equals("-recoverystats")) + state.DSMRECOVERYSTATS=true; + else if (option.equals("-dsmtask")) + state.DSMTASK=true; + else if (option.equals("-singleTM")) + state.SINGLETM=true; + else if (option.equals("-readset")) + state.READSET=true; else if (option.equals("-webinterface")) state.WEBINTERFACE=true; else if (option.equals("-instructionfailures")) state.INSTRUCTIONFAILURE=true; else if (option.equals("-abcclose")) state.ARRAYBOUNDARYCHECK=false; - else if (option.equals("-help")) { + + else if (option.equals("-mlp")) { + state.MLP = true; + state.OWNERSHIP = true; + state.MLP_NUMCORES = Integer.parseInt( args[++i] ); + state.MLP_MAXSESEAGE = Integer.parseInt( args[++i] ); + + } else if (option.equals("-mlpdebug")) { + state.MLPDEBUG=true; + + } else if (option.equals("-methodeffects")) { + state.METHODEFFECTS=true; + }else if (option.equals("-help")) { System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located"); System.out.println("-selfloop task -- this task doesn't self loop its parameters forever"); System.out.println("-dir outputdirectory -- output code in outputdirectory"); System.out.println("-struct structfile -- output structure declarations for repair tool"); System.out.println("-mainclass -- main function to call"); System.out.println("-dsm -- distributed shared memory support"); + System.out.println("-singleTM -- single machine committing transactions"); System.out.println("-abortreaders -- abort readers"); System.out.println("-precise -- use precise garbage collection"); System.out.println("-conscheck -- turn on consistency checking"); @@ -158,12 +274,14 @@ public class Main { System.out.println("-ownallocdepth -- set allocation depth for ownership analysis"); System.out.println("-ownwritedots -- write ownership graphs; can be all results or just final results"); System.out.println("-ownaliasfile -- write a text file showing all detected aliases in program tasks"); + System.out.println("-optimize -- enable optimizations"); System.out.println("-optional -- enable optional arguments"); System.out.println("-abcclose close the array boundary check"); System.out.println("-scheduling do task scheduling"); + System.out.println("-mlp build mlp code"); + System.out.println("-mlpdebug if mlp, report progress and interim results"); System.out.println("-multicore generate multi-core version binary"); System.out.println("-numcore set the number of cores (should be used together with -multicore), defaultly set as 1"); - System.out.println("-raw generate raw version binary (should be used together with -multicore)"); System.out.println("-interrupt generate raw version binary with interruption (should be used togethere with -raw)"); System.out.println("-rawconfig config raw simulator as 4xn (should be used together with -raw)"); System.out.println("-rawpath print out execute path information for raw version (should be used together with -raw)"); @@ -176,93 +294,153 @@ public class Main { System.out.println("-help -- print out help"); System.exit(0); } else { - readSourceFile(state, args[i]); + sourcefiles.add(args[i]); } } + + //add default classpath + if (state.classpath.size()==1) + state.classpath.add(ClassLibraryPrefix); + BuildIR bir=new BuildIR(state); + TypeUtil tu=new TypeUtil(state, bir); + - readSourceFile(state, ClassLibraryPrefix+"System.java"); - readSourceFile(state, ClassLibraryPrefix+"String.java"); - readSourceFile(state, ClassLibraryPrefix+"HashSet.java"); - readSourceFile(state, ClassLibraryPrefix+"HashMap.java"); - readSourceFile(state, ClassLibraryPrefix+"HashMapIterator.java"); - readSourceFile(state, ClassLibraryPrefix+"HashEntry.java"); - readSourceFile(state, ClassLibraryPrefix+"Integer.java"); - readSourceFile(state, ClassLibraryPrefix+"StringBuffer.java"); - //if(!state.RAW) { - readSourceFile(state, ClassLibraryPrefix+"FileInputStream.java"); - readSourceFile(state, ClassLibraryPrefix+"PushbackInputStream.java"); - readSourceFile(state, ClassLibraryPrefix+"InputStream.java"); - readSourceFile(state, ClassLibraryPrefix+"OutputStream.java"); - readSourceFile(state, ClassLibraryPrefix+"FileOutputStream.java"); - readSourceFile(state, ClassLibraryPrefix+"File.java"); - readSourceFile(state, ClassLibraryPrefix+"InetAddress.java"); - readSourceFile(state, ClassLibraryPrefix+"SocketInputStream.java"); - readSourceFile(state, ClassLibraryPrefix+"SocketOutputStream.java"); - readSourceFile(state, ClassLibraryPrefix+"gnu/StringTokenizer.java"); - //} - readSourceFile(state, ClassLibraryPrefix+"Math.java"); - readSourceFile(state, ClassLibraryPrefix+"gnu/Random.java"); - readSourceFile(state, ClassLibraryPrefix+"Vector.java"); - readSourceFile(state, ClassLibraryPrefix+"Enumeration.java"); - readSourceFile(state, ClassLibraryPrefix+"Dictionary.java"); - readSourceFile(state, ClassLibraryPrefix+"Writer.java"); - readSourceFile(state, ClassLibraryPrefix+"BufferedWriter.java"); - readSourceFile(state, ClassLibraryPrefix+"OutputStreamWriter.java"); - readSourceFile(state, ClassLibraryPrefix+"FileWriter.java"); - readSourceFile(state, ClassLibraryPrefix+"Date.java"); + SemanticCheck sc=new SemanticCheck(state,tu); - if (state.TASK) { - if (state.FASTCHECK) - readSourceFile(state, ClassLibraryPrefix+"ObjectFC.java"); - else - readSourceFile(state, ClassLibraryPrefix+"Object.java"); - readSourceFile(state, ClassLibraryPrefix+"TagDescriptor.java"); - } else if (state.DSM) { - readSourceFile(state, ClassLibraryPrefix+"ThreadDSM.java"); - readSourceFile(state, ClassLibraryPrefix+"ObjectJavaDSM.java"); - readSourceFile(state, ClassLibraryPrefix+"Barrier.java"); - } else { - if (state.THREAD) { - readSourceFile(state, ClassLibraryPrefix+"Thread.java"); - readSourceFile(state, ClassLibraryPrefix+"ObjectJava.java"); - } else - readSourceFile(state, ClassLibraryPrefix+"ObjectJavaNT.java"); - } + for(int i=0;i scheduling = mcImplSynthesis.synthesis(); + + //double timeEndAnalysis = (double) System.nanoTime(); + //double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) ); + //System.err.println("The analysis took" + dt + "sec."); + //System.exit(0); - // generate multiple schedulings - ScheduleAnalysis scheduleAnalysis = new ScheduleAnalysis(state, - ta); - // necessary preparation such as read profile info etc. - scheduleAnalysis.preparation(); - scheduleAnalysis.preSchedule(); - scheduleAnalysis.scheduleAnalysis(); - //scheduleAnalysis.setCoreNum(scheduleAnalysis.getSEdges4Test().size()); - scheduleAnalysis.setCoreNum(state.CORENUM); - scheduleAnalysis.schedule(); - - //simulate these schedulings - ScheduleSimulator scheduleSimulator = new ScheduleSimulator(scheduleAnalysis.getCoreNum(), - state, - ta); - Vector> schedulings = scheduleAnalysis.getSchedulings(); - Vector selectedScheduling = scheduleSimulator.simulate(schedulings); - - if(state.MULTICORE) { - Vector scheduling = scheduleAnalysis.getSchedulings().elementAt(selectedScheduling.firstElement()); - BuildCodeMultiCore bcm=new BuildCodeMultiCore(state, - bf.getMap(), - tu, - sa, - scheduling, - scheduleAnalysis.getCoreNum(), - pa); - bcm.setOwnershipAnalysis(oa); - bcm.buildCode(); - scheduling = null; + // generate multicore codes + if(state.MULTICORE) { + BuildCodeMultiCore bcm=new BuildCodeMultiCore(state, + bf.getMap(), + tu, + sa, + scheduling, + mcImplSynthesis.getCoreNum(), + state.CORENUM4GC, + pa); + bcm.setOwnershipAnalysis(oa); + bcm.buildCode(); + } + scheduling.clear(); + scheduling = null; } - schedulings = null; - selectedScheduling = null; } - } - if(!state.MULTICORE) { - if (state.DSM) { + if (state.DSM||state.SINGLETM) { CallGraph callgraph=new CallGraph(state); if (state.PREFETCH) { //speed up prefetch generation using locality analysis results LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu); pa=new PrefetchAnalysis(state, callgraph, tu, la); } - LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu); GenerateConversions gc=new GenerateConversions(la, state); - BuildCode bc=new BuildCode(state, bf.getMap(), tu, la, pa); + BuildCode bc=new BuildCode(state, bf.getMap(), tu, la, pa, mlpa); bc.buildCode(); } else { - BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa, pa); + BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa, pa, mlpa); bc.buildCode(); } } - if (state.FLATIRGRAPH) { - FlatIRGraph firg = new FlatIRGraph(state, - state.FLATIRGRAPHTASKS, - state.FLATIRGRAPHUSERMETHODS, - state.FLATIRGRAPHLIBMETHODS); - } - - if (state.OWNERSHIP) { - CallGraph callGraph = new CallGraph(state); - OwnershipAnalysis oa = new OwnershipAnalysis(state, - tu, - callGraph, - state.OWNERSHIPALLOCDEPTH, - state.OWNERSHIPWRITEDOTS, - state.OWNERSHIPWRITEALL, - state.OWNERSHIPALIASFILE); - } - + System.out.println("Lines="+state.lines); System.exit(0); } - /** Reads in a source file and adds the parse tree to the state object. */ - - private static void readSourceFile(State state, String sourcefile) throws Exception { - Reader fr = new BufferedReader(new FileReader(sourcefile)); - Lex.Lexer l = new Lex.Lexer(fr); - java_cup.runtime.lr_parser g; - g = new Parse.Parser(l); - ParseNode p=null; + public static void loadClass(State state, BuildIR bir, String sourcefile) { try { - p=(ParseNode) g./*debug_*/ parse().value; + ParseNode pn=readSourceFile(state, sourcefile); + bir.buildtree(pn, null); } catch (Exception e) { - System.err.println("Error parsing file:"+sourcefile); + System.out.println("Error in sourcefile:"+sourcefile); + e.printStackTrace(); + System.exit(-1); + } catch (Error e) { + System.out.println("Error in sourcefile:"+sourcefile); e.printStackTrace(); System.exit(-1); } - state.addParseNode(p); - if (l.numErrors()!=0) { - System.out.println("Error parsing "+sourcefile); - System.exit(l.numErrors()); + } + + /** Reads in a source file and adds the parse tree to the state object. */ + + public static ParseNode readSourceFile(State state, String sourcefile) { + try { + Reader fr= new BufferedReader(new FileReader(sourcefile)); + Lex.Lexer l = new Lex.Lexer(fr); + java_cup.runtime.lr_parser g; + g = new Parse.Parser(l); + ParseNode p=null; + try { + p=(ParseNode) g./*debug_*/parse().value; + } catch (Exception e) { + System.err.println("Error parsing file:"+sourcefile); + e.printStackTrace(); + System.exit(-1); + } + state.addParseNode(p); + if (l.numErrors()!=0) { + System.out.println("Error parsing "+sourcefile); + System.exit(l.numErrors()); + } + state.lines+=l.line_num; + return p; + + } catch (Exception e) { + throw new Error(e); } } }