4 * Java implementation of the <tt>em3d</tt> Olden benchmark. This Olden
5 * benchmark models the propagation of electromagnetic waves through
6 * objects in 3 dimensions. It is a simple computation on an irregular
7 * bipartite graph containing nodes representing electric and magnetic
11 * D. Culler, A. Dusseau, S. Goldstein, A. Krishnamurthy, S. Lumetta, T. von
12 * Eicken and K. Yelick. "Parallel Programming in Split-C". Supercomputing
13 * 1993, pages 262-273.
19 * The number of nodes (E and H)
23 * The out-degree of each node.
25 private int numDegree;
27 * The number of compute iterations
31 * Should we print the results and other runtime messages
33 private boolean printResult;
35 * Print information messages?
37 private boolean printMsgs;
48 public Em3d(BiGraph bg, int lowerlimit, int upperlimit, int numIter, int numDegree, int threadindex) {
50 this.lowerlimit = lowerlimit;
51 this.upperlimit = upperlimit;
52 this.numIter = numIter;
53 this.numDegree = numDegree;
54 this.threadindex=threadindex;
64 //barr = new Barrier("128.195.175.84");
67 random = new Random(lowerlimit);
69 //This is going to conflict badly...Minimize work here
70 bg.allocateNodes ( lowerlimit, upperlimit, threadindex);
71 //Barrier.enterBarrier(barr);
74 //initialize the eNodes
75 bg.initializeNodes(bg.eNodes, bg.hNodes, bg.hreversetable, lowerlimit, upperlimit, degree, random, threadindex);
76 //Barrier.enterBarrier(barr);
78 //initialize the hNodes
79 bg.initializeNodes(bg.hNodes, bg.eNodes, bg.ereversetable, lowerlimit, upperlimit, degree, random, threadindex);
80 //Barrier.enterBarrier(barr);
82 bg.makeFromNodes(bg.hNodes, bg.hreversetable, lowerlimit, upperlimit, random);
83 //Barrier.enterBarrier(barr);
85 bg.makeFromNodes(bg.eNodes, bg.ereversetable, lowerlimit, upperlimit, random);
86 //Barrier.enterBarrier(barr);
89 for (int i = 0; i < iteration; i++) {
91 for(int j = lowerlimit; j<upperlimit; j++) {
92 Node n = bg.eNodes[j];
94 for (int k = 0; k < n.fromCount; k++) {
95 n.value -= n.coeffs[k] * n.fromNodes[k].value;
99 //Barrier.enterBarrier(barr);
102 for(int j = lowerlimit; j<upperlimit; j++) {
103 Node n = bg.hNodes[j];
104 for (int k = 0; k < n.fromCount; k++) {
105 n.value -= n.coeffs[k] * n.fromNodes[k].value;
108 //Barrier.enterBarrier(barr);
113 * The main roitine that creates the irregular, linked data structure
114 * that represents the electric and magnetic fields and propagates the
115 * waves through the graph.
116 * @param args the command line arguments
118 public static void main(String args[]) {
119 Em3d em = new Em3d();
120 Em3d.parseCmdLine(args, em);
122 System.printString("Initializing em3d random graph...\n");
123 long start0 = System.currentTimeMillis();
124 int numThreads = em.numThreads;
126 int[] mid = new int[8];
127 mid[0] = (128<<24)|(195<<16)|(175<<8)|84;//dw-10
128 mid[1] = (128<<24)|(195<<16)|(175<<8)|85;//dw-11
129 mid[2] = (128<<24)|(195<<16)|(175<<8)|86;//dw-12
130 mid[3] = (128<<24)|(195<<16)|(175<<8)|87;//dw-13
131 mid[4] = (128<<24)|(195<<16)|(175<<8)|88;//dw-14
132 mid[5] = (128<<24)|(195<<16)|(175<<8)|89;//dw-15
133 mid[6] = (128<<24)|(195<<16)|(175<<8)|90;//dw-16
134 mid[7] = (128<<24)|(195<<16)|(175<<8)|91;//dw-17
137 System.printString("DEBUG -> numThreads = " + numThreads+"\n");
138 //BarrierServer mybarr;
142 // initialization step 1: allocate BiGraph
143 // System.printString( "Allocating BiGraph.\n" );
145 //mybarr = new BarrierServer(numThreads);
146 graph = BiGraph.create(em.numNodes, em.numDegree, numThreads);
148 //mybarr.start(mid[0]);
151 Em3dWrap[] em3d=new Em3dWrap[numThreads];
152 int increment = em.numNodes/numThreads;
155 // initialization step 2: divide work of allocating nodes
156 // System.printString( "Launching distributed allocation of nodes.\n" );
159 for(int i=0;i<numThreads;i++) {
161 if ((i+1)==numThreads)
162 tmp = new Em3d(graph, base, em.numNodes, em.numIter, em.numDegree, i);
164 tmp = new Em3d(graph, base, base+increment, em.numIter, em.numDegree, i);
165 em3d[i]=new Em3dWrap(tmp);
170 boolean waitfordone=true;
177 //System.printString("Starting Barrier run\n");
178 for(int i = 0; i<numThreads; i++) {
179 //em3d[i].em3d.start(mid[i]);
183 for(int i = 0; i<numThreads; i++) {
187 System.printString("Done!"+ "\n");
192 * Parse the command line options.
193 * @param args the command line options.
196 public static void parseCmdLine(String args[], Em3d em)
201 while (i < args.length && args[i].startsWith("-")) {
204 // check for options that require arguments
205 if (arg.equals("-N")) {
206 if (i < args.length) {
207 em.numNodes = new Integer(args[i++]).intValue();
209 } else if (arg.equals("-T")) {
210 if (i < args.length) {
211 em.numThreads = new Integer(args[i++]).intValue();
213 } else if (arg.equals("-d")) {
214 if (i < args.length) {
215 em.numDegree = new Integer(args[i++]).intValue();
217 } else if (arg.equals("-i")) {
218 if (i < args.length) {
219 em.numIter = new Integer(args[i++]).intValue();
221 } else if (arg.equals("-p")) {
222 em.printResult = true;
223 } else if (arg.equals("-m")) {
225 } else if (arg.equals("-h")) {
230 if (em.numNodes == 0 || em.numDegree == 0)
235 * The usage routine which describes the program options.
239 System.printString("usage: java Em3d -T <threads> -N <nodes> -d <degree> [-p] [-m] [-h]\n");
240 System.printString(" -N the number of nodes\n");
241 System.printString(" -T the number of threads\n");
242 System.printString(" -d the out-degree of each node\n");
243 System.printString(" -i the number of iterations\n");
244 System.printString(" -p (print detailed results\n)");
245 System.printString(" -m (print informative messages)\n");
246 System.printString(" -h (this message)\n");