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.
16 public class Em3d extends Thread
20 * The number of nodes (E and H)
24 * The out-degree of each node.
26 private int numDegree;
28 * The number of compute iterations
32 * Should we print the results and other runtime messages
34 private boolean printResult;
36 * Print information messages?
38 private boolean printMsgs;
53 public Em3d(BiGraph bg, int lowerlimit, int upperlimit, int numIter, Barrier mybarr) {
55 this.lowerlimit = lowerlimit;
56 this.upperlimit = upperlimit;
57 this.numIter = numIter;
68 for (int i = 0; i < iteration; i++) {
74 for(int j = 0; j<lowerlimit; j++){
78 for(int j = lowerlimit; j<=upperlimit; j++) {
80 for (int k = 0; k < n.fromCount; k++) {
81 n.value -= n.coeffs[k] * n.fromNodes[k].value;
85 Barrier.enterBarrier(mybarr);
93 for(int j = 0; j<lowerlimit; j++){
97 for(int j = lowerlimit; j<=upperlimit; j++) {
99 for (int k = 0; k < n.fromCount; k++) {
100 n.value -= n.coeffs[k] * n.fromNodes[k].value;
104 Barrier.enterBarrier(mybarr);
110 * The main roitine that creates the irregular, linked data structure
111 * that represents the electric and magnetic fields and propagates the
112 * waves through the graph.
113 * @param args the command line arguments
115 public static void main(String args[])
119 em = global new Em3d();
120 em.parseCmdLine(args, em);
122 boolean printMsgs, printResult;
125 printMsgs = em.printMsgs;
126 numIter = em.numIter;
127 printResult = em.printResult;
130 System.printString("Initializing em3d random graph...");
131 long start0 = System.currentTimeMillis();
133 System.printString("DEBUG -> numThreads = " + numThreads);
136 mybarr = global new Barrier(numThreads);
142 rand = global new Random(783);
145 graph1 = global new BiGraph();
146 graph = global new BiGraph();
147 graph = graph1.create(em.numNodes, em.numDegree, em.printResult, rand);
150 long end0 = System.currentTimeMillis();
152 // compute a single iteration of electro-magnetic propagation
154 System.printString("Propagating field values for " + numIter +
156 long start1 = System.currentTimeMillis();
159 em3d = global new Em3d[numThreads];
163 em3d[0] = global new Em3d(graph, 1, em.numNodes/2, em.numIter, mybarr);
164 em3d[1] = global new Em3d(graph, (em.numNodes/2)+1, em.numNodes, em.numIter, mybarr);
167 int mid = (128<<24)|(195<<16)|(175<<8)|73;
169 for(int i = 0; i<numThreads; i++) {
176 for(int i = 0; i<numThreads; i++) {
182 long end1 = System.currentTimeMillis();
184 // print current field values
186 //System.printString(graph);
190 System.printString("EM3D build time "+ (long)((end0 - start0)/1000.0));
191 System.printString("EM3D compute time " + (long)((end1 - start1)/1000.0));
192 System.printString("EM3D total time " + (long)((end1 - start0)/1000.0));
194 System.printString("Done!");
199 * Parse the command line options.
200 * @param args the command line options.
203 public void parseCmdLine(String args[], Em3d em)
208 while (i < args.length && args[i].startsWith("-")) {
211 // check for options that require arguments
212 if (arg.equals("-n")) {
213 if (i < args.length) {
214 em.numNodes = new Integer(args[i++]).intValue();
216 } else if (arg.equals("-d")) {
217 if (i < args.length) {
218 em.numDegree = new Integer(args[i++]).intValue();
220 } else if (arg.equals("-i")) {
221 if (i < args.length) {
223 em.numIter = global new Integer(args[i++]).intValue();
226 } else if (arg.equals("-p")) {
227 em.printResult = true;
228 } else if (arg.equals("-m")) {
230 } else if (arg.equals("-h")) {
235 //if (em.numNodes == 0 || em.numDegree == 0)
240 * The usage routine which describes the program options.
244 System.printString("usage: java Em3d -n <nodes> -d <degree> [-p] [-m] [-h]");
245 System.printString(" -n the number of nodes");
246 System.printString(" -d the out-degree of each node");
247 System.printString(" -i the number of iterations");
248 System.printString(" -p (print detailed results)");
249 System.printString(" -m (print informative messages)");
250 System.printString(" -h (this message)");