1 package dol.visitor.cell;
\r
3 import java.io.FileOutputStream;
\r
4 import java.io.OutputStream;
\r
5 import java.io.PrintStream;
\r
6 import java.util.Vector;
\r
8 import dol.datamodel.pn.Process;
\r
9 import dol.datamodel.pn.ProcessNetwork;
\r
10 import dol.visitor.PNVisitor;
\r
13 * This class is a class for a visitor that is used to generate the build file
\r
14 * for the Application on the CBE (i.e. a bash file for the cell
\r
16 * @author lschor, 2008-10-30
\r
19 * 2008-10-30: Updated the file for the CBE
\r
20 * 2008-11-08: Add double buffering
\r
22 public class CellBuildFileVisitor extends PNVisitor {
\r
28 * path of the Makefile
\r
30 public CellBuildFileVisitor(String dir) {
\r
35 * Create a Makefile for the given process network.
\r
40 public void visitComponent(ProcessNetwork pn) {
\r
42 String filename = _dir + _delimiter + "pncbe.sh";
\r
43 OutputStream file = new FileOutputStream(filename);
\r
44 PrintStream ps = new PrintStream(file);
\r
46 // General information / notes and commands
\r
47 ps.println("#!/bin/bash");
\r
48 ps.println("clear");
\r
51 .println("# Bash file to run the DOL application on the Cell processor");
\r
53 .println("# Start the Cell-Simulator and enter the following commands: ");
\r
55 .println("# callthru source <Absolute path to the folder of this file>/pncbe.sh > pncbe.sh");
\r
57 .println("# for example: callthru source /opt/cell/sdk/src/tutorial/pn_test/pncbe.sh > pncbe.sh");
\r
58 ps.println("# chmod +x pncbe.sh");
\r
61 .println("# To run the DOL application, use the following command: ");
\r
62 ps.println("# ./pncbe.sh");
\r
64 ps.println("# Folder in which the application is stored");
\r
65 ps.println("FOLDER=/opt/cell/sdk/src/tutorial/pn_test");
\r
68 // Go through each process and copy its data to the Cell
\r
69 String subdirectory = "";
\r
70 String applicationName = "";
\r
71 Vector<String> pList = new Vector<String>();
\r
73 for (Process process : pn.getProcessList()) {
\r
74 String basename = process.getBasename();
\r
75 if (!pList.contains(basename) && process.getNumOfInports() > 0 && process.getNumOfOutports() > 0) {
\r
76 subdirectory = "spu_" + basename;
\r
77 applicationName = subdirectory + "/spu_"
\r
78 + basename + "_wrapper";
\r
80 ps.println("# " + basename);
\r
81 ps.println("if [ ! -d " + subdirectory + " ]; then");
\r
82 ps.println(" mkdir " + subdirectory);
\r
84 ps.println("callthru source $FOLDER/" + applicationName
\r
85 + " > " + applicationName);
\r
86 ps.println("chmod +x " + applicationName);
\r
88 pList.add(basename);
\r
92 // Load also the main application to the CBE
\r
93 ps.println("# Main program");
\r
94 ps.println("callthru source $FOLDER/ppu_main > ppu_main");
\r
95 ps.println("chmod +x ppu_main");
\r
98 // Run the main program
\r
99 ps.println("# run the main program");
\r
100 ps.println("./ppu_main");
\r
101 } catch (Exception e) {
\r
102 System.out.println("CbeMakefileVisitor: exception occured: "
\r
104 e.printStackTrace();
\r
108 protected String _dir = null;
\r