X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fcbe%2FCbeBuildFileVisitor.java;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fcbe%2FCbeBuildFileVisitor.java;h=4500d91f649e3ea5e5fe13ab6558a4a40a4282bd;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/cbe/CbeBuildFileVisitor.java b/dol/src/dol/visitor/cbe/CbeBuildFileVisitor.java new file mode 100644 index 0000000..4500d91 --- /dev/null +++ b/dol/src/dol/visitor/cbe/CbeBuildFileVisitor.java @@ -0,0 +1,109 @@ +/* $Id: CbeBuildFileVisitor.java 1 2010-02-24 13:03:05Z haidw $ */ +package dol.visitor.cbe; + +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.util.Vector; + +import dol.datamodel.pn.Process; +import dol.datamodel.pn.ProcessNetwork; +import dol.visitor.PNVisitor; + +/** + * This class is a class for a visitor that is used to generate the build + * file for the application on the CBE (i.e. a bash file for the CBE) + * + * @author lschor, 2008-10-30 + * + * Revision: + * 2008-10-30: Updated the file for the CBE + * 2008-11-08: Add double buffering + */ +public class CbeBuildFileVisitor extends PNVisitor { + + /** + * Constructor. + * + * @param dir path of the Makefile + */ + public CbeBuildFileVisitor(String dir) { + _dir = dir; + } + + /** + * Create a Makefile for the given process network. + * + * @param pn process network + */ + public void visitComponent(ProcessNetwork pn) { + try { + String filename = _dir + _delimiter + "pncbe.sh"; + OutputStream file = new FileOutputStream(filename); + PrintStream ps = new PrintStream(file); + + // General information / notes and commands + ps.println("#!/bin/bash"); + ps.println("clear"); + ps.println(); + ps.println("# Bash file to run a DOL application on the CBE"); + ps.println("# Start the CBE-Simulator and enter the " + + "following commands: "); + ps.println("# callthru source /pncbe.sh > pncbe.sh"); + ps.println("# for example: callthru source /opt/cell/sdk/src/" + + "tutorial/pn_test/pncbe.sh > pncbe.sh"); + ps.println("# chmod +x pncbe.sh"); + ps.println(); + ps.println("# To run the DOL application, use the following " + + "command: "); + ps.println("# ./pncbe.sh"); + ps.println(); + ps.println("# Folder in which the application is stored"); + ps.println("FOLDER=/opt/cell/sdk/src/tutorial/pn_test"); + ps.println(); + + // Go through each process and copy its data to the Cell + String subdirectory = ""; + String applicationName = ""; + Vector pList = new Vector(); + + for (Process process : pn.getProcessList()) { + String basename = process.getBasename(); + if (!pList.contains(basename) + && process.getNumOfInports() > 0 + && process.getNumOfOutports() > 0) { + subdirectory = "spu_" + basename; + applicationName = subdirectory + "/spu_" + + basename + "_wrapper"; + + ps.println("# " + basename); + ps.println("if [ ! -d " + subdirectory + " ]; then"); + ps.println("\tmkdir " + subdirectory); + ps.println("fi;"); + ps.println("callthru source $FOLDER/" + + applicationName + " > " + applicationName); + ps.println("chmod +x " + applicationName); + ps.println(); + pList.add(basename); + } + } + + // Load also the main application to the CBE + ps.println("# Main program"); + ps.println("callthru source $FOLDER/ppu_main > ppu_main"); + ps.println("chmod +x ppu_main"); + ps.println(); + + // Run the main program + ps.println("# run the main program"); + ps.println("./ppu_main"); + } catch (Exception e) { + System.out.println("CbeMakefileVisitor: exception occured: " + + e.getMessage()); + e.printStackTrace(); + } + } + + protected String _dir = null; +}