LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Find Resources
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Cvs-checkins > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: cvs at opencores.org<cvs@o...>
    Date: Mon May 29 11:13:10 CEST 2006
    Subject: [cvs-checkins] MODIFIED: jop ...
    Top
    Date: 00/06/05 29:11:13

    Modified: jop/java/tools/src/com/jopdesign/wcet WCETAnalyser.java
    SetWCETAnalysis.java
    Log:
    LP Solve DLL and Jar in JOP_HOME/java/lib: Put DLL in WINDOWS/SYSTEM32 (or something that is on the PATH)


    Revision Changes Path
    1.24 jop/java/tools/src/com/jopdesign/wcet/WCETAnalyser.java

    http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/com/jopdesign/wcet/WCETAnalyser.java.diff?r1=1.23&r2=1.24

    (In the diff below, changes in quantity of whitespace are not shown.)

    Index: WCETAnalyser.java
    ===================================================================
    RCS file: /cvsroot/rasped/jop/java/tools/src/com/jopdesign/wcet/WCETAnalyser.java,v
    retrieving revision 1.23
    retrieving revision 1.24
    diff -u -b -r1.23 -r1.24
    --- WCETAnalyser.java 28 May 2006 09:39:49 -0000 1.23
    +++ WCETAnalyser.java 29 May 2006 09:13:10 -0000 1.24
    @@ -3,6 +3,7 @@
    import java.util.*;
    import java.io.BufferedReader;
    import java.io.File;
    +import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.FileReader;
    import java.io.IOException;
    @@ -17,6 +18,8 @@
    import com.jopdesign.build.TransitiveHull;
    import com.jopdesign.tools.JopInstr;

    +import lpsolve.*;
    +
    /**
    * The class is for wcet analysis. The class hierarchy is such
    * that WCETAnalyzer creates one WCETMethodBlock for each
    @@ -49,9 +52,6 @@
    // 2006-05-07 rup: Output dot graphs
    // 2006-05-25 rup: "Annotations" and lp_solvable wcet output

    -// TODOs:
    -// TODO: Re-use the existing bytecode mapping to native methods
    -
    /**
    * The thing that controls the WCETClassBlock etc.
    */
    @@ -68,6 +68,8 @@

    PrintWriter out;

    + PrintWriter dotout;
    +
    /**
    * Loaded classes, type is JavaClass
    */
    @@ -86,6 +88,8 @@

    ArrayList javaFiles;

    + static String outFile;
    +
    public WCETAnalyser() {

    // TODO: Debugging from Eclipse creates a different classpath?
    @@ -93,14 +97,13 @@
    mmap = new HashMap();
    javaFiles = new ArrayList();
    javaFilePathMap = new HashMap();
    +
    }

    public static void main(String[] args) {
    - // wcet/P3+Wcet.txt
    - String outFile = null;
    WCETAnalyser wca = new WCETAnalyser();
    HashSet clsArgs = new HashSet();
    -
    + outFile = null; // wcet/P3+Wcet.txt
    //the tables can be easier to use in latex using this property
    boolean latex = System.getProperty("latex", "false").equals("true");
    //dot graphs code generation
    @@ -161,6 +164,8 @@
    // + mainClass);

    wca.out = new PrintWriter(new FileOutputStream(outFile));
    + String ds = new File(WCETAnalyser.outFile).getParentFile().getAbsolutePath()+"\\dotall.bat";
    + wca.dotout = new PrintWriter(new FileOutputStream(ds));

    wca.load(clsArgs);

    @@ -172,6 +177,7 @@
    wca.out.println("Note: Remember to keep WCETAnalyzer updated");
    wca.out.println("each time a bytecode implementation is changed.");
    wca.out.close();
    + wca.dotout.close();
    }
    } catch (Exception e) {
    e.printStackTrace();
    @@ -325,6 +331,10 @@ WCETAnalyser wca; + String lpf = null; + + String dotf = null; + String[] codeLines; // directed graph of the basic blocks @@ -333,6 +343,10 @@ // method size in 32 bit words int n = -1; + int wcetlp; + + HashMap wcetvars; + // create a bb covering the whole method // from here on we split it when necessary public void init(InstructionHandle stih, InstructionHandle endih) { @@ -718,10 +732,34 @@ sb.append(WU.repeat("=",top.length() - 3+wca.las.length())); sb.append("\n"); + + // bytecode listing + sb.append("\nTable of basic blocks' and instructions\n"); + sb.append("=========================================================================\n"); + sb.append("Block Addr. Bytecode Cycles Cache miss Misc. info\n"); + sb.append(" [opcode] invoke return\n"); + sb.append("-------------------------------------------------------------------------\n"); + for (Iterator iter = bbs.keySet().iterator(); iter.hasNext();) { + Integer keyInt = (Integer) iter.next(); + WCETBasicBlock wcbb = (WCETBasicBlock) bbs.get(keyInt); + sb.append(wcbb.toCodeString()); + } + sb.append("=========================================================================\n"); + sb.append("Info: n="+n+" b="+WCETInstruction.calculateB(n)+" a="+WCETInstruction.a+" r="+WCETInstruction.r+" w="+WCETInstruction.w+"\n"); + sb.append("\n"); + if(wca.ls) + sb.append(toLS()); + if(wca.dot) + sb.append(toDot()); + return sb.toString(); + } + + public String toDot() { + StringBuffer sb = new StringBuffer(); // dot graph // use: dot -Tps graph.dot -o graph.ps boolean labels = true; - if(wca.dot){ + sb.append("\n/*"+ jc.getClassName() + "." + method.getName() + method.getSignature()+"*/\n"); sb.append("digraph G {\n"); @@ -731,7 +769,18 @@ sb.append("\tB"+i+" -> "+"B"+j); if(labels){ //sb.append(" [label=\""+dg[i][j]+"\""); - sb.append(" [label=\"f"+i+"."+j+"\""); + String edge = "f"+i+"."+j; + + if(wcetvars.get(edge)!=null){ + int edgeval = Integer.parseInt((String)wcetvars.get(edge)); + if(edgeval>0) + sb.append(" [label=\"f"+i+"."+j+"="+edgeval+"\""); + else + sb.append(" [style=dotted,label=\"f"+i+"."+j+"="+edgeval+"\""); + } + else + sb.append(" [label=\"f"+i+"."+j+"=?\""); + //sb.append(",labelfloat=true"); sb.append("]"); } @@ -744,33 +793,22 @@ WCETBasicBlock wcbb = (WCETBasicBlock) bbs.get(keyInt); int id = wcbb.getId(); sb.append("\tB"+id+" [label=\"B"+id+"\\n"+wcbb.wcetHit+"\"];\n"); - //skhkjh } sb.append("}\n"); - } -//sb.append(method.getName()+"\n"); -//for(int i=0;i<codeLines.length;i++){ -// sb.append(i+":"+codeLines[i]+"\n"); -//} - // bytecode listing - sb.append("\nTable of basic blocks' and instructions\n"); - sb.append("=========================================================================\n"); - sb.append("Block Addr. Bytecode Cycles Cache miss Misc. info\n"); - sb.append(" [opcode] invoke return\n"); - sb.append("-------------------------------------------------------------------------\n"); - for (Iterator iter = bbs.keySet().iterator(); iter.hasNext();) { - Integer keyInt = (Integer) iter.next(); - WCETBasicBlock wcbb = (WCETBasicBlock) bbs.get(keyInt); - sb.append(wcbb.toCodeString()); + try { + dotf = new File(WCETAnalyser.outFile).getParentFile().getAbsolutePath()+"\\"+method.getClass().getName()+"."+method.getName()+".dot"; + dotf = dotf.replace('<','_'); + dotf = dotf.replace('>','_'); + PrintWriter dotout = new PrintWriter(new FileOutputStream(dotf)); + dotout.write(sb.toString()); + dotout.close(); + } catch (FileNotFoundException e1) { + e1.printStackTrace(); } - sb.append("=========================================================================\n"); - sb.append("Info: n="+n+" b="+WCETInstruction.calculateB(n)+" a="+WCETInstruction.a+" r="+WCETInstruction.r+" w="+WCETInstruction.w+"\n"); - sb.append("\n"); - if(wca.ls) - sb.append(toLS()); return sb.toString(); + } //TODO: loop follows loop controller? public String toLS(){ @@ -893,9 +931,43 @@ } + try { + lpf = new File(WCETAnalyser.outFile).getParentFile().getAbsolutePath()+"\\"+method.getClass().getName()+"."+method.getName()+".lp"; + lpf = lpf.replace('<','_'); + lpf = lpf.replace('>','_'); +//System.out.println("about to write:"+lpf); + PrintWriter lsout = new PrintWriter(new FileOutputStream(lpf)); + lsout.write(ls.toString()); + lsout.close(); + } catch (FileNotFoundException e1) { + e1.printStackTrace(); + } - - //ls.append("e"+wcbb.id+" = 1; // t\n"); + try { + LpSolve problem = LpSolve.readLp(lpf, LpSolve.NORMAL, method.getClass().getName()+"."+method.getName()); + problem.setOutputfile(lpf+".output.txt"); + problem.solve(); + problem.setOutputfile(lpf+".solved.txt"); + problem.printObjective(); + problem.printSolution(1); + wcetvars = new HashMap(); + wcetlp = (int)problem.getObjective(); + try { + BufferedReader in = new BufferedReader(new FileReader(lpf+".solved.txt")); + String str; + while ((str = in.readLine()) != null) { + ls.append(str+"\n"); + StringTokenizer st = new StringTokenizer(str); + if(st.countTokens()==2){ + wcetvars.put(st.nextToken(),st.nextToken()); + } + } + in.close(); + } catch (IOException e) { + } + } catch (LpSolveException e) { + e.printStackTrace(); + } return ls.toString(); } 1.4 jop/java/tools/src/com/jopdesign/wcet/SetWCETAnalysis.java http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/com/jopdesign/wcet/SetWCETAnalysis.java.diff?r1=1.3&r2=1.4 (In the diff below, changes in quantity of whitespace are not shown.) Index: SetWCETAnalysis.java =================================================================== RCS file: /cvsroot/rasped/jop/java/tools/src/com/jopdesign/wcet/SetWCETAnalysis.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- SetWCETAnalysis.java 26 Apr 2006 12:10:32 -0000 1.3 +++ SetWCETAnalysis.java 29 May 2006 09:13:10 -0000 1.4 @@ -28,6 +28,7 @@ wcmb.controlFlowGraph(); wcmb.directedGraph(); wca.out.println(wcmb.toString()); + wca.dotout.print("dot -Tps "+wcmb.dotf+" > "+wcmb.dotf.substring(0,wcmb.dotf.length()-4)+".eps\n"); } //System.out.println(wcmb.toString()); //}

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.