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;
54 public Em3d(BiGraph bg, int lowerlimit, int upperlimit, int numIter, Barrier mybarr) {
56 this.lowerlimit = lowerlimit;
57 this.upperlimit = upperlimit;
58 this.numIter = numIter;
68 for (int i = 0; i < iteration; i++) {
69 Barrier runBarrier = new Barrier();
75 for(int j = 0; j<lowerlimit; j++){
79 for(int j = lowerlimit; j<=upperlimit; j++) {
81 for (int k = 0; k < n.fromCount; k++) {
82 n.value -= n.coeffs[k] * n.fromNodes[k].value;
86 runBarrier.enterBarrier(mybarr);
94 for(int j = 0; j<lowerlimit; j++){
98 for(int j = lowerlimit; j<=upperlimit; j++) {
100 for (int k = 0; k < n.fromCount; k++) {
101 n.value -= n.coeffs[k] * n.fromNodes[k].value;
105 runBarrier.enterBarrier(mybarr);
112 * The main roitine that creates the irregular, linked data structure
113 * that represents the electric and magnetic fields and propagates the
114 * waves through the graph.
115 * @param args the command line arguments
117 public static void main(String args[])
119 Random rand = new Random(783);
122 em = global new Em3d();
123 em.parseCmdLine(args, em);
125 boolean printMsgs, printResult;
128 printMsgs = em.printMsgs;
129 numIter = em.numIter;
130 printResult = em.printResult;
133 System.printString("Initializing em3d random graph...");
134 long start0 = System.currentTimeMillis();
136 System.printString("DEBUG -> numThreads = " + numThreads);
139 mybarr = global new Barrier(numThreads);
144 graph1 = global new BiGraph();
145 graph = global new BiGraph();
146 graph = graph1.create(em.numNodes, em.numDegree, em.printResult, rand);
149 long end0 = System.currentTimeMillis();
151 // compute a single iteration of electro-magnetic propagation
153 System.printString("Propagating field values for " + numIter +
155 long start1 = System.currentTimeMillis();
158 em3d = global new Em3d[numThreads];
162 em3d[0] = global new Em3d(graph, 1, em.numNodes/2, em.numIter, mybarr);
163 em3d[1] = global new Em3d(graph, (em.numNodes/2)+1, em.numNodes, em.numIter, mybarr);
166 int mid = (128<<24)|(195<<16)|(175<<8)|73;
168 for(int i = 0; i<numThreads; i++) {
175 for(int i = 0; i<numThreads; i++) {
181 long end1 = System.currentTimeMillis();
183 // print current field values
185 //System.printString(graph);
189 System.printString("EM3D build time "+ (long)((end0 - start0)/1000.0));
190 System.printString("EM3D compute time " + (long)((end1 - start1)/1000.0));
191 System.printString("EM3D total time " + (long)((end1 - start0)/1000.0));
193 System.printString("Done!");
198 * Parse the command line options.
199 * @param args the command line options.
202 public void parseCmdLine(String args[], Em3d em)
207 while (i < args.length && args[i].startsWith("-")) {
210 // check for options that require arguments
211 if (arg.equals("-n")) {
212 if (i < args.length) {
213 em.numNodes = new Integer(args[i++]).intValue();
215 } else if (arg.equals("-d")) {
216 if (i < args.length) {
217 em.numDegree = new Integer(args[i++]).intValue();
219 } else if (arg.equals("-i")) {
220 if (i < args.length) {
222 em.numIter = global new Integer(args[i++]).intValue();
225 } else if (arg.equals("-p")) {
226 em.printResult = true;
227 } else if (arg.equals("-m")) {
229 } else if (arg.equals("-h")) {
234 //if (em.numNodes == 0 || em.numDegree == 0)
239 * The usage routine which describes the program options.
243 System.printString("usage: java Em3d -n <nodes> -d <degree> [-p] [-m] [-h]");
244 System.printString(" -n the number of nodes");
245 System.printString(" -d the out-degree of each node");
246 System.printString(" -i the number of iterations");
247 System.printString(" -p (print detailed results)");
248 System.printString(" -m (print informative messages)");
249 System.printString(" -h (this message)");