From b6e4cdc7983f36eecbdd72b86e7608b5a1f92204 Mon Sep 17 00:00:00 2001 From: adash Date: Sun, 13 Apr 2008 04:11:39 +0000 Subject: [PATCH] New benchmark --- .../Benchmarks/Prefetch/Em3d/dsm/Barrier.java | 52 ++++ .../Benchmarks/Prefetch/Em3d/dsm/BiGraph.java | 108 ++++++++ .../Benchmarks/Prefetch/Em3d/dsm/Em3d.java | 252 ++++++++++++++++++ .../Benchmarks/Prefetch/Em3d/dsm/Node.java | 217 +++++++++++++++ .../src/Benchmarks/Prefetch/Em3d/dsm/makefile | 15 ++ 5 files changed, 644 insertions(+) create mode 100644 Robust/src/Benchmarks/Prefetch/Em3d/dsm/Barrier.java create mode 100644 Robust/src/Benchmarks/Prefetch/Em3d/dsm/BiGraph.java create mode 100644 Robust/src/Benchmarks/Prefetch/Em3d/dsm/Em3d.java create mode 100644 Robust/src/Benchmarks/Prefetch/Em3d/dsm/Node.java create mode 100644 Robust/src/Benchmarks/Prefetch/Em3d/dsm/makefile diff --git a/Robust/src/Benchmarks/Prefetch/Em3d/dsm/Barrier.java b/Robust/src/Benchmarks/Prefetch/Em3d/dsm/Barrier.java new file mode 100644 index 00000000..482b695a --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Em3d/dsm/Barrier.java @@ -0,0 +1,52 @@ +public class Barrier { + int numthreads; + int entercount; + boolean cleared; + + public Barrier(int n) { + numthreads=n; + cleared = false; + entercount = 0; + } + + public Barrier() { + } + + public void reset() { + cleared = false; + entercount = 0; + } + + public static void enterBarrier(Barrier b) { + int tmp; + boolean retry=true; + + do { + atomic { + if (!b.cleared) { + b.entercount++; + tmp = b.entercount; + if (tmp==b.numthreads) { + if(b.numthreads > 1) + b.cleared=true; + b.entercount--; + return; + } + retry=false; + } + } + } while(retry); + + while(true) { + atomic { + if (b.cleared) { + b.entercount--; + int count = b.entercount; + if (count==0) + b.cleared=false; + return; + } + } + } + } +} diff --git a/Robust/src/Benchmarks/Prefetch/Em3d/dsm/BiGraph.java b/Robust/src/Benchmarks/Prefetch/Em3d/dsm/BiGraph.java new file mode 100644 index 00000000..f952f7e2 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Em3d/dsm/BiGraph.java @@ -0,0 +1,108 @@ +/** + * A class that represents the irregular bipartite graph used in + * EM3D. The graph contains two linked structures that represent the + * E nodes and the N nodes in the application. + **/ +public class BiGraph +{ + public BiGraph() { + } + /** + * Nodes that represent the electrical field. + **/ + Node eNodes; + /** + * Nodes that representhe the magnetic field. + **/ + Node hNodes; + + /** + * Construct the bipartite graph. + * @param e the nodes representing the electric fields + * @param h the nodes representing the magnetic fields + **/ + BiGraph(Node e, Node h) + { + eNodes = e; + hNodes = h; + } + + /** + * Create the bi graph that contains the linked list of + * e and h nodes. + * @param numNodes the number of nodes to create + * @param numDegree the out-degree of each node + * @param verbose should we print out runtime messages + * @return the bi graph that we've created. + **/ + + BiGraph create(int numNodes, int numDegree, boolean verbose, Random r) + { + Node newnode = new Node(); + + // making nodes (we create a table) + //if (verbose) System.printString("making nodes (tables in orig. version)"); + Node[] hTable = newnode.fillTable(numNodes, numDegree, r); + Node[] eTable = newnode.fillTable(numNodes, numDegree, r); + + // making neighbors + //if (verbose) System.printString("updating from and coeffs"); + for(int i = 0; i< numNodes; i++) { + Node n = hTable[i]; + n.makeUniqueNeighbors(eTable, r); + } + + for (int i = 0; i < numNodes; i++) { + Node n = eTable[i]; + n.makeUniqueNeighbors(hTable, r); + } + + // Create the fromNodes and coeff field + //if (verbose) System.printString("filling from fields"); + for(int i = 0; i< numNodes; i++) { + Node n = hTable[i]; + n.makeFromNodes(); + } + + for (int i = 0; i < numNodes; i++) { + Node n = eTable[i]; + n.makeFromNodes(); + } + + // Update the fromNodes + for (int i = 0; i < numNodes; i++) { + Node n = hTable[i]; + n.updateFromNodes(r); + } + for (int i = 0; i < numNodes; i++) { + Node n = eTable[i]; + n.updateFromNodes(r); + } + + BiGraph g = new BiGraph(eTable[0], hTable[0]); + return g; + } + + /** + * Override the toString method to print out the values of the e and h nodes. + * @return a string contain the values of the e and h nodes. + **/ + public String toString() + { + StringBuffer retval = new StringBuffer(); + Node tmp = eNodes; + while(tmp!=null) { + Node n = tmp; + retval.append("E: " + n + "\n"); + tmp = tmp.next; + } + tmp = hNodes; + while(tmp!=null) { + Node n = tmp; + retval.append("H: " + n + "\n"); + tmp = tmp.next; + } + return retval.toString(); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/Em3d/dsm/Em3d.java b/Robust/src/Benchmarks/Prefetch/Em3d/dsm/Em3d.java new file mode 100644 index 00000000..28ffe641 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Em3d/dsm/Em3d.java @@ -0,0 +1,252 @@ +/** + * + * + * Java implementation of the em3d Olden benchmark. This Olden + * benchmark models the propagation of electromagnetic waves through + * objects in 3 dimensions. It is a simple computation on an irregular + * bipartite graph containing nodes representing electric and magnetic + * field values. + * + *

+ * D. Culler, A. Dusseau, S. Goldstein, A. Krishnamurthy, S. Lumetta, T. von + * Eicken and K. Yelick. "Parallel Programming in Split-C". Supercomputing + * 1993, pages 262-273. + * + **/ +public class Em3d extends Thread +{ + + /** + * The number of nodes (E and H) + **/ + private int numNodes; + /** + * The out-degree of each node. + **/ + private int numDegree; + /** + * The number of compute iterations + **/ + private int numIter; + /** + * Should we print the results and other runtime messages + **/ + private boolean printResult; + /** + * Print information messages? + **/ + private boolean printMsgs; + + BiGraph bg; + int upperlimit; + int lowerlimit; + //Random rand; + Barrier mybarr; + + public Em3d() { + numNodes = 0; + numDegree = 0; + numIter = 1; + printResult = false; + printMsgs = false; + } + + public Em3d(BiGraph bg, int lowerlimit, int upperlimit, int numIter, Barrier mybarr) { + this.bg = bg; + this.lowerlimit = lowerlimit; + this.upperlimit = upperlimit; + this.numIter = numIter; + this.mybarr = mybarr; + } + + public void run() { + int iteration; + atomic { + iteration = numIter; + } + + for (int i = 0; i < iteration; i++) { + Barrier runBarrier = new Barrier(); + /* for eNodes */ + Node prev, curr; + atomic { + prev = bg.eNodes; + curr = null; + for(int j = 0; j numThreads = " + numThreads); + Barrier mybarr; + atomic { + mybarr = global new Barrier(numThreads); + } + BiGraph graph; + BiGraph graph1; + atomic { + graph1 = global new BiGraph(); + graph = global new BiGraph(); + graph = graph1.create(em.numNodes, em.numDegree, em.printResult, rand); + } + + long end0 = System.currentTimeMillis(); + + // compute a single iteration of electro-magnetic propagation + if (printMsgs) + System.printString("Propagating field values for " + numIter + + " iteration(s)..."); + long start1 = System.currentTimeMillis(); + Em3d[] em3d; + atomic { + em3d = global new Em3d[numThreads]; + } + + atomic { + em3d[0] = global new Em3d(graph, 1, em.numNodes/2, em.numIter, mybarr); + em3d[1] = global new Em3d(graph, (em.numNodes/2)+1, em.numNodes, em.numIter, mybarr); + } + + int mid = (128<<24)|(195<<16)|(175<<8)|73; + Em3d tmp; + for(int i = 0; i -d [-p] [-m] [-h]"); + System.printString(" -n the number of nodes"); + System.printString(" -d the out-degree of each node"); + System.printString(" -i the number of iterations"); + System.printString(" -p (print detailed results)"); + System.printString(" -m (print informative messages)"); + System.printString(" -h (this message)"); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/Em3d/dsm/Node.java b/Robust/src/Benchmarks/Prefetch/Em3d/dsm/Node.java new file mode 100644 index 00000000..6c5095b5 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/Em3d/dsm/Node.java @@ -0,0 +1,217 @@ +/** + * This class implements nodes (both E- and H-nodes) of the EM graph. Sets + * up random neighbors and propagates field values among neighbors. + */ +public class Node { + /** + * The value of the node. + **/ + double value; + /** + * The next node in the list. + **/ + protected Node next; + /** + * Array of nodes to which we send our value. + **/ + Node[] toNodes; + /** + * Array of nodes from which we receive values. + **/ + Node[] fromNodes; + /** + * Coefficients on the fromNodes edges + **/ + double[] coeffs; + /** + * The number of fromNodes edges + **/ + int fromCount; + /** + * Used to create the fromEdges - keeps track of the number of edges that have + * been added + **/ + int fromLength; + + public Node() { + + } + + /** + * Constructor for a node with given `degree'. The value of the + * node is initialized to a random value. + **/ + public Node(int degree, Random r) + { + value = r.nextDouble(); + // create empty array for holding toNodes + toNodes = new Node[degree]; + + next = null; + for (int i = 0; i