X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fcell%2FCellBuildFileVisitor.java;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fcell%2FCellBuildFileVisitor.java;h=31daef5471fff583f14a4879d5dc8b3a92fc6e43;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/cell/CellBuildFileVisitor.java b/dol/src/dol/visitor/cell/CellBuildFileVisitor.java new file mode 100644 index 0000000..31daef5 --- /dev/null +++ b/dol/src/dol/visitor/cell/CellBuildFileVisitor.java @@ -0,0 +1,110 @@ +package dol.visitor.cell; + +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 cell + * + * @author lschor, 2008-10-30 + * + * Revision: + * 2008-10-30: Updated the file for the CBE + * 2008-11-08: Add double buffering + */ +public class CellBuildFileVisitor extends PNVisitor { + + /** + * Constructor. + * + * @param dir + * path of the Makefile + */ + public CellBuildFileVisitor(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 the DOL application on the Cell processor"); + ps + .println("# Start the Cell-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(" mkdir " + 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; + +}