MAINCLASS=Array
SRC1=${MAINCLASS}.java
-FLAGS=-dsm -prefetch -optimize -debug -excprefetch Array.Array -mainclass ${MAINCLASS} -trueprob 0.7
-FLAGS2=-dsm -optimize -debug -excprefetch Array.Array -mainclass ${MAINCLASS} -trueprob 0.7
+FLAGS=-dsm -prefetch -optimize -debug -excprefetch Array.Array -mainclass ${MAINCLASS} -trueprob 0.98
+FLAGS2=-dsm -optimize -debug -excprefetch Array.Array -mainclass ${MAINCLASS}
default:
../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC1}
../../../buildscript ${FLAGS} -o ${MAINCLASS}P ${SRC1}
+ cp ${MAINCLASS}NP.bin ${MAINCLASS}1NP.bin
+ cp ${MAINCLASS}P.bin ${MAINCLASS}1.bin
clean:
rm *.bin
SRC1=${MAINCLASS}.java
FLAGS=-dsm -prefetch -optimize -debug -excprefetch Chase.main -excprefetch Chase.Chase -mainclass ${MAINCLASS} -trueprob 0.7
FLAGS2=-dsm -optimize -debug -mainclass ${MAINCLASS} -trueprob 0.7
+#for testing no java option
+#FLAGS=-dsm -prefetch -optimize -debug -excprefetch Chase.main -excprefetch Chase.Chase -mainclass ${MAINCLASS} -trueprob 0.99 -nojava
default:
../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC1}
../../../buildscript ${FLAGS} -o ${MAINCLASS}P ${SRC1}
+ cp ${MAINCLASS}NP.bin ${MAINCLASS}1NP.bin
+ cp ${MAINCLASS}P.bin ${MAINCLASS}1.bin
clean:
rm *.bin
//import java.util.*;
//import jgfutil.*;
+/*
class IDEATest
{
int [] Z; // Encryption subkey (userkey derived).
int [] DK; // Decryption subkey (userkey derived).
- void Do(int nthreads, JGFInstrumentor instr)
+ void Do(int nthreads)
{
int mid = (128<<24)|(195<<16)|(175<<8)|73;
- IDEARunner tmp;
IDEARunner[] th;
atomic {
th = global new IDEARunner [nthreads];
}
// Start the stopwatch.
- instr.startTimer("Section2:Crypt:Kernel");
+ //instr.startTimer("Section2:Crypt:Kernel");
// Encrypt plain1.
+ IDEARunner tmp;
for(int i=1;i<nthreads;i++) {
atomic {
th[i] = global new IDEARunner(i,plain1,crypt1,Z,nthreads);
// Stop the stopwatch.
- instr.stopTimer("Section2:Crypt:Kernel");
+ //instr.stopTimer("Section2:Crypt:Kernel");
}
// Create three byte arrays that will be used (and reused) for
// encryption/decryption operations.
- plain1 = new byte [array_rows];
- crypt1 = new byte [array_rows];
- plain2 = new byte [array_rows];
+ plain1 = global new byte [array_rows];
+ crypt1 = global new byte [array_rows];
+ plain2 = global new byte [array_rows];
- Random rndnum = new Random(136506717L); // Create random number generator.
+
+ Random rndnum = global new Random(136506717L); // Create random number generator.
// Allocate three arrays to hold keys: userkey is the 128-bit key.
// then a final output transform with four of the keys; (8 * 6)
// + 4 = 52 subkeys.
- userkey = new short [8]; // User key has 8 16-bit shorts.
- Z = new int [52]; // Encryption subkey (user key derived).
- DK = new int [52]; // Decryption subkey (user key derived).
+ userkey = global new short [8]; // User key has 8 16-bit shorts.
+ Z = global new int [52]; // Encryption subkey (user key derived).
+ DK = global new int [52]; // Decryption subkey (user key derived).
// Generate user key randomly; eight 16-bit values in an array.
}
}
+*/
-
-class IDEARunner extends Thread {
+public class IDEARunner extends Thread {
int id,key[];
byte text1[],text2[];
} // End routine.
} // End of class
-
-
-
-
-
-
-
-
-
jgfutil/JGFTimer.java \
crypt/JGFCryptBench.java
FLAGS=-dsm -prefetch -excprefetch JGFCryptBench.buildTestData -excprefetch JGFCryptBench.JGFvalidate -excprefetch JGFCryptBench.calcDecryptKey -excprefetch JGFCryptBench.freeTestData -excprefetch JGFCryptBench.calcEncryptKey -excprefetch JGFCryptBenchSizeA.main -excprefetch JGFCryptBench.JGFinitialise -excprefetch JGFCryptBench.JGFvalidate -optimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS} -trueprob 0.8
-FLAGS2=-dsm -excprefetch JGFCryptBench.buildTestData -excprefetch JGFCryptBench.JGFvalidate -excprefetch JGFCryptBench.calcDecryptKey -excprefetch JGFCryptBench.freeTestData -excprefetch JGFCryptBench.calcEncryptKey -excprefetch JGFCryptBenchSizeA.main -excprefetch JGFCryptBench.JGFinitialise -excprefetch JGFCryptBench.JGFvalidate -optimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS}NP
+FLAGS2=-dsm -optimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS}NP
default:
../../../../buildscript ${FLAGS2} ${SRC}
if(b.numthreads > 1)
b.cleared=true;
b.entercount--;
- //return;
ret1 = true;
}
retry=false;
}
}
} while(retry);
- if (ret1) return;
+ if (ret1) {
+ return;
+ }
while(ret2) {
atomic {
if (b.cleared) {
int count = b.entercount;
if (count==0)
b.cleared=false;
- //return;
ret2=false;
}
}
**/
public void makeNeighbors( int indexBegin, int indexEnd, Random r )
{
- System.printString( "Making unique neighbors for hNodes...\n" );
+ //System.printString( "Making unique neighbors for hNodes...\n" );
// making neighbors
//if (verbose) System.printString("updating from and coeffs");
n.makeUniqueNeighbors(eNodes, r);
}
- System.printString( "Making unique neighbors for eNodes...\n" );
+ //System.printString( "Making unique neighbors for eNodes...\n" );
for (int i = indexBegin; i < indexEnd; i++) {
Node n = eNodes[i];
public void makeFromNodes( int indexBegin, int indexEnd )
{
- System.printString( "Making h fromNodes...\n" );
+ //System.printString( "Making h fromNodes...\n" );
// Create the fromNodes and coeff field
//if (verbose) System.printString("filling from fields");
n.makeFromNodes();
}
- System.printString( "Making e fromNodes...\n" );
+ //System.printString( "Making e fromNodes...\n" );
for(int i = indexBegin; i < indexEnd; i++) {
Node n = eNodes[i];
public void makeFromLinks( int indexBegin, int indexEnd, Random r )
{
- System.printString( "Updating h fromNodes...\n" );
+ //System.printString( "Updating h fromNodes...\n" );
// Update the fromNodes
for(int i = indexBegin; i < indexEnd; i++) {
n.updateFromNodes(r);
}
- System.printString( "Updating e fromNodes...\n" );
+ //System.printString( "Updating e fromNodes...\n" );
for(int i = indexBegin; i < indexEnd; i++) {
Node n = eNodes[i];
+++ /dev/null
-/**
- *
- *
- * Java implementation of the <tt>em3d</tt> 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.
- *
- * <p><cite>
- * 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.
- * </cite>
- **/
-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;
- 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;
- Barrier barr;
- Node enodebase;
- Node hnodebase;
-
- atomic {
- iteration = numIter;
- barr=mybarr;
- }
- atomic {
- enodebase=bg.eNodes;
- hnodebase=bg.hNodes;
- for(int j = 0; j<lowerlimit; j++){
- enodebase = enodebase.next;
- hnodebase = hnodebase.next;
- }
- }
-
- for (int i = 0; i < iteration; i++) {
- /* for eNodes */
- atomic {
- Node n = enodebase;
- for(int j = lowerlimit; j<upperlimit; j++) {
- for (int k = 0; k < n.fromCount; k++) {
- n.value -= n.coeffs[k] * n.fromNodes[k].value;
- }
- n = n.next;
- }
- }
-
- Barrier.enterBarrier(barr);
- System.clearPrefetchCache();
-
- /* for hNodes */
- atomic {
- Node n = hnodebase;
- for(int j = lowerlimit; j<upperlimit; j++) {
- for (int k = 0; k < n.fromCount; k++) {
- n.value -= n.coeffs[k] * n.fromNodes[k].value;
- }
- n=n.next;
- }
- }
- Barrier.enterBarrier(barr);
- System.clearPrefetchCache();
- }
- }
-
- /**
- * The main roitine that creates the irregular, linked data structure
- * that represents the electric and magnetic fields and propagates the
- * waves through the graph.
- * @param args the command line arguments
- **/
- public static void main(String args[]) {
- Em3d em = new Em3d();
- Em3d.parseCmdLine(args, em);
- if (em.printMsgs)
- System.printString("Initializing em3d random graph...\n");
- long start0 = System.currentTimeMillis();
- int numThreads = 1;
- int[] mid = new int[numThreads];
- mid[0] = (128<<24)|(195<<16)|(175<<8)|79;
- System.printString("DEBUG -> numThreads = " + numThreads+"\n");
- Barrier mybarr;
- atomic {
- mybarr = global new Barrier(numThreads);
- }
- BiGraph graph;
- Random rand = new Random(783);
- atomic {
- graph = BiGraph.create(em.numNodes, em.numDegree, em.printResult, rand);
- }
-
- long end0 = System.currentTimeMillis();
-
- // compute a single iteration of electro-magnetic propagation
- if (em.printMsgs)
- System.printString("Propagating field values for " + em.numIter +
- " iteration(s)...\n");
- long start1 = System.currentTimeMillis();
- Em3d[] em3d;
- atomic {
- em3d = global new Em3d[numThreads];
- em3d[0] = global new Em3d(graph, 0, em.numNodes, em.numIter, mybarr);
- }
-
- Em3d tmp;
- for(int i = 0; i<numThreads; i++) {
- atomic {
- tmp = em3d[i];
- }
- tmp.start(mid[i]);
- }
-
- for(int i = 0; i<numThreads; i++) {
- atomic {
- tmp = em3d[i];
- }
- tmp.join();
- }
- long end1 = System.currentTimeMillis();
-
- // print current field values
- if (em.printResult) {
- StringBuffer retval = new StringBuffer();
- double dvalue;
- atomic {
- dvalue = graph.hNodes.value;
- }
- int intvalue = (int)dvalue;
- }
-
- if (em.printMsgs) {
- System.printString("EM3D build time "+ (long)((end0 - start0)/1000.0) + "\n");
- System.printString("EM3D compute time " + (long)((end1 - start1)/1000.0) + "\n");
- System.printString("EM3D total time " + (long)((end1 - start0)/1000.0) + "\n");
- }
- System.printString("Done!"+ "\n");
- }
-
-
- /**
- * Parse the command line options.
- * @param args the command line options.
- **/
-
- public static void parseCmdLine(String args[], Em3d em)
- {
- int i = 0;
- String arg;
-
- while (i < args.length && args[i].startsWith("-")) {
- arg = args[i++];
-
- // check for options that require arguments
- if (arg.equals("-N")) {
- if (i < args.length) {
- em.numNodes = new Integer(args[i++]).intValue();
- }
- } else if (arg.equals("-d")) {
- if (i < args.length) {
- em.numDegree = new Integer(args[i++]).intValue();
- }
- } else if (arg.equals("-i")) {
- if (i < args.length) {
- em.numIter = new Integer(args[i++]).intValue();
- }
- } else if (arg.equals("-p")) {
- em.printResult = true;
- } else if (arg.equals("-m")) {
- em.printMsgs = true;
- } else if (arg.equals("-h")) {
- em.usage();
- }
- }
-
- if (em.numNodes == 0 || em.numDegree == 0)
- em.usage();
- }
-
- /**
- * The usage routine which describes the program options.
- **/
- public void usage()
- {
- System.printString("usage: java Em3d -N <nodes> -d <degree> [-p] [-m] [-h]\n");
- System.printString(" -N the number of nodes\n");
- System.printString(" -d the out-degree of each node\n");
- System.printString(" -i the number of iterations\n");
- System.printString(" -p (print detailed results\n)");
- System.printString(" -m (print informative messages)\n");
- System.printString(" -h (this message)\n");
- }
-
-}
+++ /dev/null
-/**
- *
- *
- * Java implementation of the <tt>em3d</tt> 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.
- *
- * <p><cite>
- * 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.
- * </cite>
- **/
-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;
- 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;
- Barrier barr;
- Node enodebase;
- Node hnodebase;
-
- atomic {
- iteration = numIter;
- barr=mybarr;
- }
- atomic {
- enodebase=bg.eNodes;
- hnodebase=bg.hNodes;
- for(int j = 0; j<lowerlimit; j++){
- enodebase = enodebase.next;
- hnodebase = hnodebase.next;
- }
- }
-
- for (int i = 0; i < iteration; i++) {
- /* for eNodes */
- atomic {
- Node n = enodebase;
- for(int j = lowerlimit; j<upperlimit; j++) {
- for (int k = 0; k < n.fromCount; k++) {
- n.value -= n.coeffs[k] * n.fromNodes[k].value;
- }
- n = n.next;
- }
- }
-
- Barrier.enterBarrier(barr);
- System.clearPrefetchCache();
-
- /* for hNodes */
- atomic {
- Node n = hnodebase;
- for(int j = lowerlimit; j<upperlimit; j++) {
- for (int k = 0; k < n.fromCount; k++) {
- n.value -= n.coeffs[k] * n.fromNodes[k].value;
- }
- n=n.next;
- }
- }
- Barrier.enterBarrier(barr);
- System.clearPrefetchCache();
- }
- }
-
- /**
- * The main roitine that creates the irregular, linked data structure
- * that represents the electric and magnetic fields and propagates the
- * waves through the graph.
- * @param args the command line arguments
- **/
- public static void main(String args[]) {
- Em3d em = new Em3d();
- Em3d.parseCmdLine(args, em);
- if (em.printMsgs)
- System.printString("Initializing em3d random graph...\n");
- long start0 = System.currentTimeMillis();
- int numThreads = 2;
- int[] mid = new int[numThreads];
- mid[0] = (128<<24)|(195<<16)|(175<<8)|78;
- mid[1] = (128<<24)|(195<<16)|(175<<8)|79;
- System.printString("DEBUG -> numThreads = " + numThreads+"\n");
- Barrier mybarr;
- atomic {
- mybarr = global new Barrier(numThreads);
- }
- BiGraph graph;
- Random rand = new Random(783);
- atomic {
- graph = BiGraph.create(em.numNodes, em.numDegree, em.printResult, rand);
- }
-
- long end0 = System.currentTimeMillis();
-
- // compute a single iteration of electro-magnetic propagation
- if (em.printMsgs)
- System.printString("Propagating field values for " + em.numIter +
- " iteration(s)...\n");
- long start1 = System.currentTimeMillis();
- Em3d[] em3d;
- atomic {
- em3d = global new Em3d[numThreads];
- em3d[0] = global new Em3d(graph, 0, em.numNodes/2, em.numIter, mybarr);
- em3d[1] = global new Em3d(graph, (em.numNodes/2) + 1, em.numNodes, em.numIter, mybarr);
- }
-
- Em3d tmp;
- for(int i = 0; i<numThreads; i++) {
- atomic {
- tmp = em3d[i];
- }
- tmp.start(mid[i]);
- }
-
- for(int i = 0; i<numThreads; i++) {
- atomic {
- tmp = em3d[i];
- }
- tmp.join();
- }
- long end1 = System.currentTimeMillis();
-
- // print current field values
- if (em.printResult) {
- StringBuffer retval = new StringBuffer();
- double dvalue;
- atomic {
- dvalue = graph.hNodes.value;
- }
- int intvalue = (int)dvalue;
- }
-
- if (em.printMsgs) {
- System.printString("EM3D build time "+ (long)((end0 - start0)/1000.0) + "\n");
- System.printString("EM3D compute time " + (long)((end1 - start1)/1000.0) + "\n");
- System.printString("EM3D total time " + (long)((end1 - start0)/1000.0) + "\n");
- }
- System.printString("Done!"+ "\n");
- }
-
-
- /**
- * Parse the command line options.
- * @param args the command line options.
- **/
-
- public static void parseCmdLine(String args[], Em3d em)
- {
- int i = 0;
- String arg;
-
- while (i < args.length && args[i].startsWith("-")) {
- arg = args[i++];
-
- // check for options that require arguments
- if (arg.equals("-N")) {
- if (i < args.length) {
- em.numNodes = new Integer(args[i++]).intValue();
- }
- } else if (arg.equals("-d")) {
- if (i < args.length) {
- em.numDegree = new Integer(args[i++]).intValue();
- }
- } else if (arg.equals("-i")) {
- if (i < args.length) {
- em.numIter = new Integer(args[i++]).intValue();
- }
- } else if (arg.equals("-p")) {
- em.printResult = true;
- } else if (arg.equals("-m")) {
- em.printMsgs = true;
- } else if (arg.equals("-h")) {
- em.usage();
- }
- }
-
- if (em.numNodes == 0 || em.numDegree == 0)
- em.usage();
- }
-
- /**
- * The usage routine which describes the program options.
- **/
- public void usage()
- {
- System.printString("usage: java Em3d -N <nodes> -d <degree> [-p] [-m] [-h]\n");
- System.printString(" -N the number of nodes\n");
- System.printString(" -d the out-degree of each node\n");
- System.printString(" -i the number of iterations\n");
- System.printString(" -p (print detailed results\n)");
- System.printString(" -m (print informative messages)\n");
- System.printString(" -h (this message)\n");
- }
-
-}
+++ /dev/null
-/**
- *
- *
- * Java implementation of the <tt>em3d</tt> 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.
- *
- * <p><cite>
- * 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.
- * </cite>
- **/
-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;
- 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;
- Barrier barr;
- Node enodebase;
- Node hnodebase;
-
- atomic {
- iteration = numIter;
- barr=mybarr;
- }
- atomic {
- enodebase=bg.eNodes;
- hnodebase=bg.hNodes;
- for(int j = 0; j<lowerlimit; j++){
- enodebase = enodebase.next;
- hnodebase = hnodebase.next;
- }
- }
-
- for (int i = 0; i < iteration; i++) {
- /* for eNodes */
- atomic {
- Node n = enodebase;
- for(int j = lowerlimit; j<upperlimit; j++) {
- for (int k = 0; k < n.fromCount; k++) {
- n.value -= n.coeffs[k] * n.fromNodes[k].value;
- }
- n = n.next;
- }
- }
-
- Barrier.enterBarrier(barr);
- System.clearPrefetchCache();
-
- /* for hNodes */
- atomic {
- Node n = hnodebase;
- for(int j = lowerlimit; j<upperlimit; j++) {
- for (int k = 0; k < n.fromCount; k++) {
- n.value -= n.coeffs[k] * n.fromNodes[k].value;
- }
- n=n.next;
- }
- }
- Barrier.enterBarrier(barr);
- System.clearPrefetchCache();
- }
- }
-
- /**
- * The main roitine that creates the irregular, linked data structure
- * that represents the electric and magnetic fields and propagates the
- * waves through the graph.
- * @param args the command line arguments
- **/
- public static void main(String args[]) {
- Em3d em = new Em3d();
- Em3d.parseCmdLine(args, em);
- if (em.printMsgs)
- System.printString("Initializing em3d random graph...\n");
- long start0 = System.currentTimeMillis();
- int numThreads = 4;
- int[] mid = new int[numThreads];
- mid[0] = (128<<24)|(195<<16)|(175<<8)|80;
- mid[1] = (128<<24)|(195<<16)|(175<<8)|78;
- mid[2] = (128<<24)|(195<<16)|(175<<8)|73;
- mid[3] = (128<<24)|(195<<16)|(175<<8)|79;
- System.printString("DEBUG -> numThreads = " + numThreads+"\n");
- Barrier mybarr;
- atomic {
- mybarr = global new Barrier(numThreads);
- }
- BiGraph graph;
- Random rand = new Random(783);
- atomic {
- graph = BiGraph.create(em.numNodes, em.numDegree, em.printResult, rand);
- }
-
- long end0 = System.currentTimeMillis();
-
- // compute a single iteration of electro-magnetic propagation
- if (em.printMsgs)
- System.printString("Propagating field values for " + em.numIter +
- " iteration(s)...\n");
- long start1 = System.currentTimeMillis();
- Em3d[] em3d;
- atomic {
- em3d = global new Em3d[numThreads];
- em3d[0] = global new Em3d(graph, 0, em.numNodes/4, em.numIter, mybarr);
- em3d[1] = global new Em3d(graph, (em.numNodes/4) + 1, em.numNodes/2, em.numIter, mybarr);
- em3d[2] = global new Em3d(graph, (em.numNodes/2) + 1, (3*em.numNodes)/4, em.numIter, mybarr);
- em3d[3] = global new Em3d(graph, ((3*em.numNodes)/4 + 1), em.numNodes, em.numIter, mybarr);
- }
-
- Em3d tmp;
- for(int i = 0; i<numThreads; i++) {
- atomic {
- tmp = em3d[i];
- }
- tmp.start(mid[i]);
- }
-
- for(int i = 0; i<numThreads; i++) {
- atomic {
- tmp = em3d[i];
- }
- tmp.join();
- }
- long end1 = System.currentTimeMillis();
-
- // print current field values
- if (em.printResult) {
- StringBuffer retval = new StringBuffer();
- double dvalue;
- atomic {
- dvalue = graph.hNodes.value;
- }
- int intvalue = (int)dvalue;
- }
-
- if (em.printMsgs) {
- System.printString("EM3D build time "+ (long)((end0 - start0)/1000.0) + "\n");
- System.printString("EM3D compute time " + (long)((end1 - start1)/1000.0) + "\n");
- System.printString("EM3D total time " + (long)((end1 - start0)/1000.0) + "\n");
- }
- System.printString("Done!"+ "\n");
- }
-
-
- /**
- * Parse the command line options.
- * @param args the command line options.
- **/
-
- public static void parseCmdLine(String args[], Em3d em)
- {
- int i = 0;
- String arg;
-
- while (i < args.length && args[i].startsWith("-")) {
- arg = args[i++];
-
- // check for options that require arguments
- if (arg.equals("-N")) {
- if (i < args.length) {
- em.numNodes = new Integer(args[i++]).intValue();
- }
- } else if (arg.equals("-d")) {
- if (i < args.length) {
- em.numDegree = new Integer(args[i++]).intValue();
- }
- } else if (arg.equals("-i")) {
- if (i < args.length) {
- em.numIter = new Integer(args[i++]).intValue();
- }
- } else if (arg.equals("-p")) {
- em.printResult = true;
- } else if (arg.equals("-m")) {
- em.printMsgs = true;
- } else if (arg.equals("-h")) {
- em.usage();
- }
- }
-
- if (em.numNodes == 0 || em.numDegree == 0)
- em.usage();
- }
-
- /**
- * The usage routine which describes the program options.
- **/
- public void usage()
- {
- System.printString("usage: java Em3d -N <nodes> -d <degree> [-p] [-m] [-h]\n");
- System.printString(" -N the number of nodes\n");
- System.printString(" -d the out-degree of each node\n");
- System.printString(" -i the number of iterations\n");
- System.printString(" -p (print detailed results\n)");
- System.printString(" -m (print informative messages)\n");
- System.printString(" -h (this message)\n");
- }
-
-}
long start0 = System.currentTimeMillis();
int numThreads = em.numThreads;
int[] mid = new int[4];
- mid[0] = (128<<24)|(195<<16)|(175<<8)|69;//dw-1
- mid[1] = (128<<24)|(195<<16)|(175<<8)|70;//dw-2
+ mid[0] = (128<<24)|(195<<16)|(175<<8)|79;//dw-1
+ mid[1] = (128<<24)|(195<<16)|(175<<8)|80;//dw-2
mid[2] = (128<<24)|(195<<16)|(175<<8)|73;
mid[3] = (128<<24)|(195<<16)|(175<<8)|78;
System.printString("DEBUG -> numThreads = " + numThreads+"\n");
// initialization step 1: allocate BiGraph
- System.printString( "Allocating BiGraph.\n" );
+ // System.printString( "Allocating BiGraph.\n" );
atomic {
mybarr = global new Barrier(numThreads);
// initialization step 2: divide work of allocating nodes
- System.printString( "Launching distributed allocation of nodes.\n" );
+ // System.printString( "Launching distributed allocation of nodes.\n" );
atomic {
em3d = global new Em3d[numThreads];
// initialization step 3: link together the ends of segments
// that were allocated and internally linked in step 2
- System.printString( "Linking together allocated segments.\n" );
+ // System.printString( "Linking together allocated segments.\n" );
base = 0;
for(int i = 0; i < numThreads - 1; i++) {
}
// initialization step 4: divide work of making links
- System.printString( "Launching distributed neighbor initialization.\n" );
+ // System.printString( "Launching distributed neighbor initialization.\n" );
atomic {
em3d = global new Em3d[numThreads];
}
// initialization step 5: divide work of making from links
- System.printString( "Launching distributed makeFromNodes initialization.\n" );
+ //System.printString( "Launching distributed makeFromNodes initialization.\n" );
atomic {
em3d = global new Em3d[numThreads];
}
// initialization step 6: divide work of making from links
- System.printString( "Launching distributed fromLink initialization.\n" );
+ //System.printString( "Launching distributed fromLink initialization.\n" );
atomic {
em3d = global new Em3d[numThreads];
}
// initialization complete
- System.printString( "Initialization complete.\n" );
+ //System.printString( "Initialization complete.\n" );
long end0 = System.currentTimeMillis();
--- /dev/null
+Create the dstm.conf file
+To compile:
+ make
+To run the Em3dNP.bin on single machine
+ ./Em3dNP.bin master -T <number of threads> -N <number of nodes> -d <no of iteration> -p
+
BiGraph.java \
Node.java \
Barrier.java
-SRC1=${MAINCLASS}N.java \
- BiGraphN.java \
+SRC1=${MAINCLASS}Nold.java \
+ BiGraphNold.java \
Node.java \
Barrier.java
-FLAGS=-dsm -prefetch -excprefetch Em3d.main -excprefetch BiGraph.create -excprefetch Node.Node -excprefetch Node.fillTable -excprefetch Node.makeUniqueNeighbors -excprefetch Node.makeFromNodes -excprefetch Node.updateFromNodes -nooptimize -debug -mainclass ${MAINCLASS}
-FLAGS2=-dsm -nooptimize -debug -mainclass ${MAINCLASS}
+FLAGS=-dsm -prefetch -profile -excprefetch Em3d.main -excprefetch BiGraph.create -excprefetch Node.Node -excprefetch Node.fillTable -excprefetch Node.makeUniqueNeighbors -excprefetch Node.makeFromNodes -excprefetch Node.updateFromNodes -nooptimize -debug -mainclass ${MAINCLASS} -trueprob 0.91
+FLAGS2=-dsm -nooptimize -debug -profile -mainclass ${MAINCLASS}
default:
- ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC1}
- ../../../../buildscript ${FLAGS} -o ${MAINCLASS}P ${SRC1}
+ ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC}
+ ../../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC}
+ ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NNP ${SRC1}
+ ../../../../buildscript ${FLAGS} -o ${MAINCLASS}N ${SRC1}
+ cp ${MAINCLASS}NNP.bin ${MAINCLASS}1NP.bin
+ cp ${MAINCLASS}N.bin ${MAINCLASS}1.bin
+ cp ${MAINCLASS}NNP.bin ${MAINCLASS}2NP.bin
+ cp ${MAINCLASS}N.bin ${MAINCLASS}2.bin
+ cp ${MAINCLASS}NNP.bin ${MAINCLASS}3NP.bin
+ cp ${MAINCLASS}N.bin ${MAINCLASS}3.bin
+ cp ${MAINCLASS}NNP.bin ${MAINCLASS}4NP.bin
+ cp ${MAINCLASS}N.bin ${MAINCLASS}4.bin
clean:
rm -rf tmpbuilddirectory
if(b.numthreads > 1)
b.cleared=true;
b.entercount--;
- //return;
ret1 = true;
}
retry=false;
int count = b.entercount;
if (count==0)
b.cleared=false;
- //return;
ret2=false;
}
}
JGFInstrumentor.java \
JGFTimer.java \
Barrier.java \
-Linpack.java \
LinpackRunner.java
-FLAGS=-dsm -prefetch -nooptimize -debug -profile -excprefetch JGFLUFactBench.JGFkernel -excprefetch JGFLUFactBench.dmxpy -excprefetch JGFLUFactBench.JGFvalidate -excprefetch JGFLUFactBench.JGFinitialise -excprefetch JGFLUFactBench.matgen -excprefetch JGFLUFactBench.dgesl -mainclass ${MAINCLASS} -o ${MAINCLASS} -trueprob 0.8
-FLAGS2=-dsm -nooptimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS}NP
+FLAGS=-dsm -prefetch -nooptimize -debug -profile -excprefetch JGFLUFactBench.JGFkernel -excprefetch JGFLUFactBench.dmxpy -excprefetch JGFLUFactBench.JGFvalidate -excprefetch JGFLUFactBench.JGFinitialise -excprefetch JGFLUFactBench.matgen -excprefetch JGFLUFactBench.dgesl -mainclass ${MAINCLASS} -trueprob 0.95
+FLAGS2=-dsm -nooptimize -debug -profile -mainclass ${MAINCLASS}
default:
- ../../../../buildscript ${FLAGS2} ${SRC}
- ../../../../buildscript ${FLAGS} ${SRC}
+#../../../../buildscript ${FLAGS2} ${SRC}
+# ../../../../buildscript ${FLAGS} ${SRC}
+ ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}1NP ${SRC}
+ ../../../../buildscript ${FLAGS} -o ${MAINCLASS}1 ${SRC}
+ cp ${MAINCLASS}1NP.bin ${MAINCLASS}2NP.bin
+ cp ${MAINCLASS}1.bin ${MAINCLASS}2.bin
+ cp ${MAINCLASS}1NP.bin ${MAINCLASS}3NP.bin
+ cp ${MAINCLASS}1.bin ${MAINCLASS}3.bin
+ cp ${MAINCLASS}1NP.bin ${MAINCLASS}4NP.bin
+ cp ${MAINCLASS}1.bin ${MAINCLASS}4.bin
clean:
rm -rf tmpbuilddirectory
+++ /dev/null
-public class MatrixMultiply extends Thread{
- MMul mmul;
- public int x0, y0, x1, y1;
-
- public MatrixMultiply(MMul mmul, int x0, int y0, int x1, int y1) {
- this.mmul = mmul;
- this.x0 = x0;
- this.y0 = y0;
- this.x1 = x1;
- this.y1 = y1;
- }
-
- public void run() {
- double localresults[][];
-
- atomic {
- //compute the results
- localresults=new double[1+x1-x0][1+y1-y0];
-
- //Use b transpose for cache performance
- for(int i = x0; i<= x1; i++){
- double a[]=mmul.a[i];
- int M=mmul.M;
- for (int j = y0; j <= y1; j++) {
- double innerProduct=0;
- double b[] = mmul.btranspose[j];
- for(int k = 0; k < M; k++) {
- innerProduct += a[k] *b[k];
- }
- localresults[i-x0][j-y0]=innerProduct;
- }
- }
- }
-
- atomic {
- //write the results
- for(int i=x0;i<=x1;i++) {
- double c[]=mmul.c[i];
- for(int j=y0;j<=y1;j++) {
- c[j]=localresults[i-x0][j-y0];
- }
- }
- }
- }
-
- public static void main(String[] args) {
- int NUM_THREADS = 1;
- int[] mid = new int[NUM_THREADS];
- mid[0] = (128<<24)|(195<<16)|(175<<8)|79;
- int p, q, r;
- MatrixMultiply[] mm;
- MatrixMultiply tmp;
- MMul matrix;
-
- atomic {
- matrix = global new MMul(600, 600, 600);
- matrix.setValues();
- matrix.transpose();
- }
-
- atomic{
- mm = global new MatrixMultiply[NUM_THREADS];
- }
-
- atomic {
- mm[0] = global new MatrixMultiply(matrix,0,0,599,599);
- }
-
- atomic {
- p = matrix.L;
- q = matrix.M;
- r = matrix.N;
- }
-
- // print out the matrices to be multiplied
- System.printString("\n");
- System.printString("MatrixMultiply: L=");
- System.printInt(p);
- System.printString("\t");
- System.printString("M=");
- System.printInt(q);
- System.printString("\t");
- System.printString("N=");
- System.printInt(r);
- System.printString("\n");
-
- // start a thread to compute each c[l,n]
- for (int i = 0; i < NUM_THREADS; i++) {
- atomic {
- tmp = mm[i];
- }
- tmp.start(mid[i]);
- }
-
- // wait for them to finish
- for (int i = 0; i < NUM_THREADS; i++) {
- atomic {
- tmp = mm[i];
- }
- tmp.join();
- }
-
- // print out the result of the matrix multiply
- System.printString("Starting\n");
- System.printString("Matrix Product c =\n");
- double val;
- atomic {
- for (int i = 0; i < p; i++) {
- double c[]=matrix.c[i];
- for (int j = 0; j < r; j++) {
- val = c[j];
- }
- }
- }
- System.printString("Finished\n");
- }
-}
-
-public class MMul{
-
- public int L, M, N;
- public double[][] a;
- public double[][] b;
- public double[][] c;
- public double[][] btranspose;
-
- public MMul(int L, int M, int N) {
- this.L = L;
- this.M = M;
- this.N = N;
- a = global new double[L][M];
- b = global new double[M][N];
- c = global new double[L][N];
- btranspose = global new double[N][M];
- }
-
- public void setValues() {
- for(int i = 0; i < L; i++) {
- double ai[] = a[i];
- for(int j = 0; j < M; j++) {
- ai[j] = j+1;
- }
- }
-
- for(int i = 0; i < M; i++) {
- double bi[] = b[i];
- for(int j = 0; j < N; j++) {
- bi[j] = j+1;
- }
- }
-
- for(int i = 0; i < L; i++) {
- double ci[] = c[i];
- for(int j = 0; j < N; j++) {
- ci[j] = 0;
- }
- }
- for(int i = 0; i < N; i++) {
- double btransposei[] = btranspose[i];
- for(int j = 0; j < M; j++) {
- btransposei[j] = 0;
- }
- }
- }
-
- public void transpose() {
- for(int row = 0; row < M; row++) {
- double brow[] = b[row];
- for(int col = 0; col < N; col++) {
- btranspose[col][row] = brow[col];
- }
- }
- }
-}
+++ /dev/null
-public class MatrixMultiply extends Thread{
- MMul mmul;
- public int x0, y0, x1, y1;
-
- public MatrixMultiply(MMul mmul, int x0, int y0, int x1, int y1) {
- this.mmul = mmul;
- this.x0 = x0;
- this.y0 = y0;
- this.x1 = x1;
- this.y1 = y1;
- }
-
- public void run() {
- double localresults[][];
-
- atomic {
- //compute the results
- localresults=new double[1+x1-x0][1+y1-y0];
-
- //Use b transpose for cache performance
- for(int i = x0; i<= x1; i++){
- double a[]=mmul.a[i];
- int M=mmul.M;
- for (int j = y0; j <= y1; j++) {
- double innerProduct=0;
- double b[] = mmul.btranspose[j];
- for(int k = 0; k < M; k++) {
- innerProduct += a[k] *b[k];
- }
- localresults[i-x0][j-y0]=innerProduct;
- }
- }
- }
-
- atomic {
- //write the results
- for(int i=x0;i<=x1;i++) {
- double c[]=mmul.c[i];
- for(int j=y0;j<=y1;j++) {
- c[j]=localresults[i-x0][j-y0];
- }
- }
- }
- }
-
- public static void main(String[] args) {
- int NUM_THREADS = 2;
- int[] mid = new int[NUM_THREADS];
- mid[0] = (128<<24)|(195<<16)|(175<<8)|79;
- mid[1] = (128<<24)|(195<<16)|(175<<8)|78;
- int p, q, r;
- MatrixMultiply[] mm;
- MatrixMultiply tmp;
- MMul matrix;
-
- atomic {
- matrix = global new MMul(600, 600, 600);
- matrix.setValues();
- matrix.transpose();
- }
-
- atomic{
- mm = global new MatrixMultiply[NUM_THREADS];
- }
-
- atomic {
- mm[0] = global new MatrixMultiply(matrix,0,0,599,300);
- mm[1] = global new MatrixMultiply(matrix,0,301,599,599);
- }
-
- atomic {
- p = matrix.L;
- q = matrix.M;
- r = matrix.N;
- }
-
- // print out the matrices to be multiplied
- System.printString("\n");
- System.printString("MatrixMultiply: L=");
- System.printInt(p);
- System.printString("\t");
- System.printString("M=");
- System.printInt(q);
- System.printString("\t");
- System.printString("N=");
- System.printInt(r);
- System.printString("\n");
-
- // start a thread to compute each c[l,n]
- for (int i = 0; i < NUM_THREADS; i++) {
- atomic {
- tmp = mm[i];
- }
- tmp.start(mid[i]);
- }
-
- // wait for them to finish
- for (int i = 0; i < NUM_THREADS; i++) {
- atomic {
- tmp = mm[i];
- }
- tmp.join();
- }
-
- // print out the result of the matrix multiply
- System.printString("Starting\n");
- System.printString("Matrix Product c =\n");
- double val;
- atomic {
- for (int i = 0; i < p; i++) {
- double c[]=matrix.c[i];
- for (int j = 0; j < r; j++) {
- val = c[j];
- }
- }
- }
- System.printString("Finished\n");
- }
-}
-
-public class MMul{
-
- public int L, M, N;
- public double[][] a;
- public double[][] b;
- public double[][] c;
- public double[][] btranspose;
-
- public MMul(int L, int M, int N) {
- this.L = L;
- this.M = M;
- this.N = N;
- a = global new double[L][M];
- b = global new double[M][N];
- c = global new double[L][N];
- btranspose = global new double[N][M];
- }
-
- public void setValues() {
- for(int i = 0; i < L; i++) {
- double ai[] = a[i];
- for(int j = 0; j < M; j++) {
- ai[j] = j+1;
- }
- }
-
- for(int i = 0; i < M; i++) {
- double bi[] = b[i];
- for(int j = 0; j < N; j++) {
- bi[j] = j+1;
- }
- }
-
- for(int i = 0; i < L; i++) {
- double ci[] = c[i];
- for(int j = 0; j < N; j++) {
- ci[j] = 0;
- }
- }
- for(int i = 0; i < N; i++) {
- double btransposei[] = btranspose[i];
- for(int j = 0; j < M; j++) {
- btransposei[j] = 0;
- }
- }
- }
-
- public void transpose() {
- for(int row = 0; row < M; row++) {
- double brow[] = b[row];
- for(int col = 0; col < N; col++) {
- btranspose[col][row] = brow[col];
- }
- }
- }
-}
+++ /dev/null
-public class MatrixMultiply extends Thread{
- MMul mmul;
- public int x0, y0, x1, y1;
-
- public MatrixMultiply(MMul mmul, int x0, int y0, int x1, int y1) {
- this.mmul = mmul;
- this.x0 = x0;
- this.y0 = y0;
- this.x1 = x1;
- this.y1 = y1;
- }
-
- public void run() {
- double localresults[][];
-
- atomic {
- //compute the results
- localresults=new double[1+x1-x0][1+y1-y0];
-
- //Use b transpose for cache performance
- for(int i = x0; i<= x1; i++){
- double a[]=mmul.a[i];
- int M=mmul.M;
- for (int j = y0; j <= y1; j++) {
- double innerProduct=0;
- double b[] = mmul.btranspose[j];
- for(int k = 0; k < M; k++) {
- innerProduct += a[k] *b[k];
- }
- localresults[i-x0][j-y0]=innerProduct;
- }
- }
- }
-
- atomic {
- //write the results
- for(int i=x0;i<=x1;i++) {
- double c[]=mmul.c[i];
- for(int j=y0;j<=y1;j++) {
- c[j]=localresults[i-x0][j-y0];
- }
- }
- }
- }
-
- public static void main(String[] args) {
- int NUM_THREADS = 4;
- int[] mid = new int[NUM_THREADS];
- mid[0] = (128<<24)|(195<<16)|(175<<8)|80;
- mid[1] = (128<<24)|(195<<16)|(175<<8)|73;
- mid[2] = (128<<24)|(195<<16)|(175<<8)|78;
- mid[3] = (128<<24)|(195<<16)|(175<<8)|79;
- //int mid1 = (128<<24)|(195<<16)|(175<<8)|69;
- //int mid2 = (128<<24)|(195<<16)|(175<<8)|73;
- int p, q, r;
- MatrixMultiply[] mm;
- MatrixMultiply tmp;
- MMul matrix;
-
- atomic {
- matrix = global new MMul(600, 600, 600);
- matrix.setValues();
- matrix.transpose();
- }
-
- atomic{
- mm = global new MatrixMultiply[NUM_THREADS];
- }
-
- atomic {
- mm[0] = global new MatrixMultiply(matrix,0,0,300,300);
- mm[1] = global new MatrixMultiply(matrix,0,301,300,599);
- mm[2] = global new MatrixMultiply(matrix,301,0,599,300);
- mm[3] = global new MatrixMultiply(matrix,301,301,599,599);
- }
-
- atomic {
- p = matrix.L;
- q = matrix.M;
- r = matrix.N;
- }
-
- // print out the matrices to be multiplied
- System.printString("\n");
- System.printString("MatrixMultiply: L=");
- System.printInt(p);
- System.printString("\t");
- System.printString("M=");
- System.printInt(q);
- System.printString("\t");
- System.printString("N=");
- System.printInt(r);
- System.printString("\n");
-
- // start a thread to compute each c[l,n]
- for (int i = 0; i < NUM_THREADS; i++) {
- atomic {
- tmp = mm[i];
- }
- tmp.start(mid[i]);
- }
-
- // wait for them to finish
- for (int i = 0; i < NUM_THREADS; i++) {
- atomic {
- tmp = mm[i];
- }
- tmp.join();
- }
-
- // print out the result of the matrix multiply
- System.printString("Starting\n");
- System.printString("Matrix Product c =\n");
- double val;
- atomic {
- for (int i = 0; i < p; i++) {
- double c[]=matrix.c[i];
- for (int j = 0; j < r; j++) {
- val = c[j];
- }
- }
- }
- System.printString("Finished\n");
- }
-}
-
-public class MMul{
-
- public int L, M, N;
- public double[][] a;
- public double[][] b;
- public double[][] c;
- public double[][] btranspose;
-
- public MMul(int L, int M, int N) {
- this.L = L;
- this.M = M;
- this.N = N;
- a = global new double[L][M];
- b = global new double[M][N];
- c = global new double[L][N];
- btranspose = global new double[N][M];
- }
-
- public void setValues() {
- for(int i = 0; i < L; i++) {
- double ai[] = a[i];
- for(int j = 0; j < M; j++) {
- ai[j] = j+1;
- }
- }
-
- for(int i = 0; i < M; i++) {
- double bi[] = b[i];
- for(int j = 0; j < N; j++) {
- bi[j] = j+1;
- }
- }
-
- for(int i = 0; i < L; i++) {
- double ci[] = c[i];
- for(int j = 0; j < N; j++) {
- ci[j] = 0;
- }
- }
- for(int i = 0; i < N; i++) {
- double btransposei[] = btranspose[i];
- for(int j = 0; j < M; j++) {
- btransposei[j] = 0;
- }
- }
- }
-
- public void transpose() {
- for(int row = 0; row < M; row++) {
- double brow[] = b[row];
- for(int col = 0; col < N; col++) {
- btranspose[col][row] = brow[col];
- }
- }
- }
-}
MAINCLASS=MatrixMultiply
SRC1=${MAINCLASS}N.java
SRC2=${MAINCLASS}Nrun.java
-FLAGS=-dsm -prefetch -optimize -debug -excprefetch MatrixMultiply.main -excprefetch MMul.setValues -excprefetch MMul.transpose -mainclass ${MAINCLASS} -trueprob 0.7
+FLAGS=-dsm -prefetch -optimize -debug -excprefetch MatrixMultiply.main -excprefetch MMul.setValues -excprefetch MMul.transpose -mainclass ${MAINCLASS} -trueprob 0.90
FLAGS2=-dsm -optimize -debug -excprefetch MatrixMultiply.main -excprefetch MMul.setValues -excprefetch MMul.transpose -mainclass ${MAINCLASS}
default:
- ../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC1}
- ../../../buildscript ${FLAGS} -o ${MAINCLASS}P ${SRC1}
- ../../../buildscript ${FLAGS2} -o ${MAINCLASS}NrunNP ${SRC2}
- ../../../buildscript ${FLAGS} -o ${MAINCLASS}NrunP ${SRC2}
+ ../../../buildscript ${FLAGS2} -o ${MAINCLASS}NNP ${SRC1}
+ ../../../buildscript ${FLAGS} -o ${MAINCLASS}N ${SRC1}
+ ../../../buildscript ${FLAGS2} -o ${MAINCLASS}1NP ${SRC2}
+ ../../../buildscript ${FLAGS} -o ${MAINCLASS}1 ${SRC2}
+ cp ${MAINCLASS}1NP.bin ${MAINCLASS}2NP.bin
+ cp ${MAINCLASS}1.bin ${MAINCLASS}2.bin
+ cp ${MAINCLASS}1NP.bin ${MAINCLASS}3NP.bin
+ cp ${MAINCLASS}1.bin ${MAINCLASS}3.bin
+ cp ${MAINCLASS}1NP.bin ${MAINCLASS}4NP.bin
+ cp ${MAINCLASS}1.bin ${MAINCLASS}4.bin
clean:
rm *.bin
boolean cleared;
public Barrier(int n) {
- System.printString("Initializing barrier for "+n+" threads.\n");
+ //System.printString("Initializing barrier for "+n+" threads.\n");
numthreads=n;
cleared = false;
entercount = 0;
do {
atomic {
- System.printString("Entering barrier with ec="+b.entercount+" cl="+b.cleared+"\n");
+ //System.printString("Entering barrier with ec="+b.entercount+" cl="+b.cleared+"\n");
if (!b.cleared) {
b.entercount++;
tmp = b.entercount;
if(b.numthreads > 1)
b.cleared=true;
b.entercount--;
- System.printString("Exiting Barrier #1\n");
+ //System.printString("Exiting Barrier #1\n");
return;
}
retry=false;
}
}
} while(retry);
- System.printString("Waiting for last thread to enter\n");
+ //System.printString("Waiting for last thread to enter\n");
while(true) {
atomic {
if (b.cleared) {
int count = b.entercount;
if (count==0)
b.cleared=false;
- System.printString("Exiting Barrier #2\n");
+ //System.printString("Exiting Barrier #2\n");
return;
}
}
--- /dev/null
+public class Barrier {
+ int numthreads;
+ int entercount;
+ boolean cleared;
+
+ public Barrier(int n) {
+ numthreads=n;
+ cleared = false;
+ }
+
+ public Barrier() {
+
+ }
+
+ public void reset() {
+ cleared = false;
+ entercount = 0;
+ }
+
+ public static void enterBarrier(Barrier b) {
+ int tmp;
+ boolean retry=true;
+
+ do {
+ 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) {
+ if (b.cleared) {
+ b.entercount--;
+ int count = b.entercount;
+ if (count==0)
+ b.cleared=false;
+ return;
+ }
+ }
+ }
+}
* All rights reserved. *
* *
**************************************************************************/
-
-import java.util.*;
-
public class JGFInstrumentor{
protected HashMap timers;
public static void addTimer (String name, HashMap timers){
if (timers.containsKey(name)) {
- System.out.println("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists");
+ System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
+ " already exists\n");
}
else {
timers.put(name, new JGFTimer(name));
public static void addTimer (String name, String opname, HashMap timers){
if (timers.containsKey(name)) {
- System.out.println("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists");
+ System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
+ " already exists\n");
}
else {
timers.put(name, new JGFTimer(name,opname));
public static void addTimer (String name, String opname, int size, HashMap timers){
if (timers.containsKey(name)) {
- System.out.println("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists");
+ System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
+ " already exists\n");
}
else {
timers.put(name, new JGFTimer(name,opname,size));
((JGFTimer) timers.get(name)).start();
}
else {
- System.out.println("JGFInstrumentor.startTimer: failed - timer " + name +
- " does not exist");
+ System.printString("JGFInstrumentor.startTimer: failed - timer " + name +
+ " does not exist\n");
}
}
((JGFTimer) timers.get(name)).stop();
}
else {
- System.out.println("JGFInstrumentor.stopTimer: failed - timer " + name +
- " does not exist");
+ System.printString("JGFInstrumentor.stopTimer: failed - timer " + name +
+ " does not exist\n");
}
}
((JGFTimer) timers.get(name)).addops(count);
}
else {
- System.out.println("JGFInstrumentor.addOpsToTimer: failed - timer " + name +
- " does not exist");
+ System.printString("JGFInstrumentor.addOpsToTimer: failed - timer " + name +
+ " does not exist\n");
}
}
((JGFTimer) timers.get(name)).addtime(added_time);
}
else {
- System.out.println("JGFInstrumentor.addTimeToTimer: failed - timer " + name +
- " does not exist");
+ System.printString("JGFInstrumentor.addTimeToTimer: failed - timer " + name +
+ " does not exist\n");
}
time = ((JGFTimer) timers.get(name)).time;
}
else {
- System.out.println("JGFInstrumentor.readTimer: failed - timer " + name +
- " does not exist");
+ System.printString("JGFInstrumentor.readTimer: failed - timer " + name +
+ " does not exist\n");
time = 0.0;
}
return time;
((JGFTimer) timers.get(name)).reset();
}
else {
- System.out.println("JGFInstrumentor.resetTimer: failed - timer " + name +
- " does not exist");
+ System.printString("JGFInstrumentor.resetTimer: failed - timer " + name +
+ " does not exist\n");
}
}
((JGFTimer) timers.get(name)).print();
}
else {
- System.out.println("JGFInstrumentor.printTimer: failed - timer " + name +
- " does not exist");
+ System.printString("JGFInstrumentor.printTimer: failed - timer " + name +
+ " does not exist\n");
}
}
((JGFTimer) timers.get(name)).printperf();
}
else {
- System.out.println("JGFInstrumentor.printTimer: failed - timer " + name +
- " does not exist");
+ System.printString("JGFInstrumentor.printTimer: failed - timer " + name +
+ " does not exist\n");
}
}
header = "";
base = "Java Grande Forum Thread Benchmark Suite - Version 1.0 - Section ";
- switch (section) {
- case 1:
- header = base + "1";
- break;
- case 2:
- switch (size) {
- case 0:
- header = base + "2 - Size A";
- break;
- case 1:
- header = base + "2 - Size B";
- break;
- case 2:
- header = base + "2 - Size C";
- break;
- }
- break;
- case 3:
- switch (size) {
- case 0:
- header = base + "3 - Size A";
- break;
- case 1:
- header = base + "3 - Size B";
- break;
- }
- break;
- }
-
- System.out.println(header);
+ if (section == 1)
+ {
+ header = base + "1";
+ }
+ else if (section == 2)
+ {
+ if (size == 0)
+ header = base + "2 - Size A";
+ else if (size == 1)
+ header = base + "2 - Size B";
+ else if (size == 2)
+ header = base + "2 - Size C";
+ }
+ else if (section == 3)
+ {
+ if (size == 0)
+ header = base + "3 - Size A";
+ else if (size == 1)
+ header = base + "3 - Size B";
+ }
+
+ System.printString(header + "\n");
if (nthreads == 1) {
- System.out.println("Executing on " + nthreads + " thread");
+ System.printString("Executing on " + nthreads + " thread\n");
}
else {
- System.out.println("Executing on " + nthreads + " threads");
+ System.printString("Executing on " + nthreads + " threads\n");
}
- System.out.println("");
-
+ System.printString(" \n");
}
-
}
* All rights reserved. *
* *
**************************************************************************/
-
-import java.io.*;
-
public class JGFMolDynBench {
public int ITERS;
public double LENGTH;
public int nthreads;
public JGFInstrumentor instr;
- public JGFMolDynBench(int nthreads, JGFInstrumentor instr) {
+ public JGFMolDynBench(int nthreads) {
this.nthreads=nthreads;
- this.instr = instr;
}
public void JGFsetsize(int size){
kb = 1.38066e-23;
TSIM = 50;
deltat = 5e-16;
-
- //initialise();
}
- public void JGFapplication() {
+ public static void JGFapplication(JGFMolDynBench mold) {
// Create new arrays
- epot = new double [nthreads];
- vir = new double [nthreads];
- ek = new double [nthreads];
+ mold.epot = new double [mold.nthreads];
+ mold.vir = new double [mold.nthreads];
+ mold.ek = new double [mold.nthreads];
+ mold.interacts = new int [mold.nthreads];
- interacts = new int [nthreads];
+ int partsize, numthreads;
+ partsize = mold.PARTSIZE;
+ numthreads = mold.nthreads;
- double sh_force [][] = new double[3][PARTSIZE];
- double sh_force2 [][][] = new double[3][nthreads][PARTSIZE];
+ double sh_force [][];
+ double sh_force2 [][][];
+ sh_force = new double[3][partsize];
+ sh_force2 = new double[3][numthreads][partsize];
// spawn threads
- Thread thobjects[] = new Thread [nthreads];
- TournamentBarrier br= new TournamentBarrier(nthreads);
- //Barrier br = new Barrier(nthreads);
-
- for(int i=1;i<nthreads;i++) {
- thobjects[i] = new mdRunner(i,mm,sh_force,sh_force2,br,instr,nthreads,this);
- thobjects[i].start();
+ mdRunner[] thobjects;
+ Barrier br;
+ thobjects = new mdRunner[numthreads];
+ br= new Barrier(numthreads);
+
+ int[] mid = new int[2];
+ mid[0] = (128<<24)|(195<<16)|(175<<8)|73;
+ mid[1] = (128<<24)|(195<<16)|(175<<8)|69;
+ mdRunner tmp;
+
+ for(int i=1;i<numthreads;i++) {
+ thobjects[i] = new mdRunner(i,mold.mm,sh_force,sh_force2,br,mold.nthreads,mold);
+ tmp = thobjects[i];
+ //System.printString("Starting thread "+ i + "\n");
+ tmp.start();
}
-
- thobjects[0] = new mdRunner(0,mm,sh_force,sh_force2,br,instr,nthreads,this);
- thobjects[0].run();
-
- for(int i=1;i<nthreads;i++) {
- try {
- thobjects[i].join();
- }
- catch (InterruptedException e) {}
+ //System.printString("Finished starting rest threads\n");
+
+ thobjects[0] = new mdRunner(0,mold.mm,sh_force,sh_force2,br,mold.nthreads,mold);
+ tmp = thobjects[0];
+ //System.printString("Starting thread 0\n");
+ tmp.start();
+ tmp.join();
+ //System.printString("Finishing start\n");
+
+ for(int i=1;i<numthreads;i++) {
+ //System.printString("Joining thread "+ i + "\n");
+ tmp = thobjects[i];
+ tmp.join();
}
+ //System.printString("Finished joining all threads\n");
}
public void JGFvalidate(){
double[] refval = new double[2];
refval[0] = 1731.4306625334357;
refval[1] = 7397.392307839352;
- double dev = Math.abs(ek[0] - refval[size]);
+ double dev = Math.fabs(ek[0] - refval[size]);
if (dev > 1.0e-10 ){
- System.out.println("Validation failed");
- System.out.println("Kinetic Energy = " + ek[0] + " " + dev + " " + size);
+ //System.printString("Validation failed\n");
+ //System.printString("Kinetic Energy = " + (long)ek[0] + " " + (long)dev + " " + size + "\n");
}
}
}
class mdRunner extends Thread {
double count;
- int id,i,j,k,lg,mdsize,move,mm;
+ int id,i,j,k,lg,mdsize,mm;
double l,rcoff,rcoffs,side,sideh,hsq,hsq2,vel,velt;
double a,r,sum,tscale,sc,ekin,ts,sp;
double den;
int irep;
int istop;
int iprint;
- int movemx;
- TournamentBarrier br;
- //Barrier br;
+ Barrier br;
random randnum;
- JGFInstrumentor instr;
JGFMolDynBench mymd;
int nthreads;
particle[] one;
- public mdRunner(int id, int mm, double [][] sh_force, double [][][] sh_force2,TournamentBarrier br,
- //public mdRunner(int id, int mm, double [][] sh_force, double [][][] sh_force2,Barrier br,
- JGFInstrumentor instr, int nthreads, JGFMolDynBench mymd) {
+ public mdRunner(int id, int mm, double [][] sh_force, double [][][] sh_force2,Barrier br,
+ int nthreads, JGFMolDynBench mymd) {
this.id=id;
this.mm=mm;
this.sh_force=sh_force;
this.sh_force2=sh_force2;
this.br=br;
- this.instr = instr;
this.nthreads = nthreads;
this.mymd = mymd;
count = 0.0;
irep = 10;
istop = 19;
iprint = 10;
- movemx = 50;
}
public void run() {
+ //System.printString("Start run method\n");
+
/* Parameter determination */
- mdsize = mymd.PARTSIZE;
- one = new particle [mdsize];
- l = mymd.LENGTH;
-
- side = Math.pow((mdsize/den),0.3333333);
- rcoff = mm/4.0;
-
- a = side/mm;
- sideh = side*0.5;
- hsq = h*h;
- hsq2 = hsq*0.5;
- npartm = mdsize - 1;
- rcoffs = rcoff * rcoff;
- tscale = 16.0 / (1.0 * mdsize - 1.0);
- vaver = 1.13 * Math.sqrt(tref / 24.0);
- vaverh = vaver * h;
-
- /* Particle Generation */
-
- xvelocity = 0.0;
- yvelocity = 0.0;
- zvelocity = 0.0;
-
- ijk = 0;
- for (lg=0; lg<=1; lg++) {
- for (i=0; i<mm; i++) {
- for (j=0; j<mm; j++) {
- for (k=0; k<mm; k++) {
- one[ijk] = new particle((i*a+lg*a*0.5),(j*a+lg*a*0.5),(k*a),
- xvelocity,yvelocity,zvelocity,sh_force,sh_force2,id,this);
- ijk = ijk + 1;
+ int tmpmdsize;
+ double tmpden;
+ int movemx=50;
+ Barrier tmpbr;
+
+ tmpbr=br;
+ mdsize = mymd.PARTSIZE;
+ one = new particle[mdsize];
+ l = mymd.LENGTH;
+ tmpmdsize = mdsize;
+ tmpden = den;
+ side = Math.pow((tmpmdsize/tmpden),0.3333333);
+ rcoff = mm/4.0;
+
+ a = side/mm;
+ sideh = side*0.5;
+ hsq = h*h;
+ hsq2 = hsq*0.5;
+ npartm = tmpmdsize - 1;
+ rcoffs = rcoff * rcoff;
+ tscale = 16.0 / (1.0 * tmpmdsize - 1.0);
+ vaver = 1.13 * Math.sqrt(tref / 24.0);
+ vaverh = vaver * h;
+
+ /* Particle Generation */
+
+ xvelocity = 0.0;
+ yvelocity = 0.0;
+ zvelocity = 0.0;
+ ijk = 0;
+
+ for (lg=0; lg<=1; lg++) {
+ for (i=0; i<mm; i++) {
+ for (j=0; j<mm; j++) {
+ for (k=0; k<mm; k++) {
+ one[ijk] = new particle((i*a+lg*a*0.5),(j*a+lg*a*0.5),(k*a),
+ xvelocity,yvelocity,zvelocity,sh_force,sh_force2,id,this);
+ ijk = ijk + 1;
+ }
}
}
}
- }
- for (lg=1; lg<=2; lg++) {
- for (i=0; i<mm; i++) {
- for (j=0; j<mm; j++) {
- for (k=0; k<mm; k++) {
- one[ijk] = new particle((i*a+(2-lg)*a*0.5),(j*a+(lg-1)*a*0.5),
- (k*a+a*0.5),xvelocity,yvelocity,zvelocity,sh_force,sh_force2,id,this);
- ijk = ijk + 1;
+
+ for (lg=1; lg<=2; lg++) {
+ for (i=0; i<mm; i++) {
+ for (j=0; j<mm; j++) {
+ for (k=0; k<mm; k++) {
+ one[ijk] = new particle((i*a+(2-lg)*a*0.5),(j*a+(lg-1)*a*0.5),
+ (k*a+a*0.5),xvelocity,yvelocity,zvelocity,sh_force,sh_force2,id,this);
+ ijk = ijk + 1;
+ }
}
}
}
- }
-
- /* Initialise velocities */
+ /* Initialise velocities */
- iseed = 0;
- v1 = 0.0;
- v2 = 0.0;
+ iseed = 0;
+ v1 = 0.0;
+ v2 = 0.0;
+ randnum = new random(iseed,v1,v2);
- randnum = new random(iseed,v1,v2);
-
- for (i=0; i<mdsize; i+=2) {
- r = randnum.seed();
- one[i].xvelocity = r*randnum.v1;
- one[i+1].xvelocity = r*randnum.v2;
- }
-
- for (i=0; i<mdsize; i+=2) {
- r = randnum.seed();
- one[i].yvelocity = r*randnum.v1;
- one[i+1].yvelocity = r*randnum.v2;
- }
+ for (i=0; i<tmpmdsize; i+=2) {
+ r = randnum.seed();
+ one[i].xvelocity = r*randnum.v1;
+ one[i+1].xvelocity = r*randnum.v2;
+ }
- for (i=0; i<mdsize; i+=2) {
- r = randnum.seed();
- one[i].zvelocity = r*randnum.v1;
- one[i+1].zvelocity = r*randnum.v2;
- }
+ for (i=0; i<tmpmdsize; i+=2) {
+ r = randnum.seed();
+ one[i].yvelocity = r*randnum.v1;
+ one[i+1].yvelocity = r*randnum.v2;
+ }
+ for (i=0; i<tmpmdsize; i+=2) {
+ r = randnum.seed();
+ one[i].zvelocity = r*randnum.v1;
+ one[i+1].zvelocity = r*randnum.v2;
+ }
- /* velocity scaling */
- ekin = 0.0;
- sp = 0.0;
+ /* velocity scaling */
- for(i=0;i<mdsize;i++) {
- sp = sp + one[i].xvelocity;
- }
- sp = sp / mdsize;
+ ekin = 0.0;
+ sp = 0.0;
- for(i=0;i<mdsize;i++) {
- one[i].xvelocity = one[i].xvelocity - sp;
- ekin = ekin + one[i].xvelocity*one[i].xvelocity;
- }
+ for(i=0;i<tmpmdsize;i++) {
+ sp = sp + one[i].xvelocity;
+ }
+ sp = sp / tmpmdsize;
- sp = 0.0;
- for(i=0;i<mdsize;i++) {
- sp = sp + one[i].yvelocity;
- }
- sp = sp / mdsize;
+ for(i=0;i<tmpmdsize;i++) {
+ one[i].xvelocity = one[i].xvelocity - sp;
+ ekin = ekin + one[i].xvelocity*one[i].xvelocity;
+ }
- for(i=0;i<mdsize;i++) {
- one[i].yvelocity = one[i].yvelocity - sp;
- ekin = ekin + one[i].yvelocity*one[i].yvelocity;
- }
+ sp = 0.0;
+ for(i=0;i<tmpmdsize;i++) {
+ sp = sp + one[i].yvelocity;
+ }
+ sp = sp / tmpmdsize;
+ for(i=0;i<tmpmdsize;i++) {
+ one[i].yvelocity = one[i].yvelocity - sp;
+ ekin = ekin + one[i].yvelocity*one[i].yvelocity;
+ }
- sp = 0.0;
- for(i=0;i<mdsize;i++) {
- sp = sp + one[i].zvelocity;
- }
- sp = sp / mdsize;
- for(i=0;i<mdsize;i++) {
- one[i].zvelocity = one[i].zvelocity - sp;
- ekin = ekin + one[i].zvelocity*one[i].zvelocity;
- }
+ sp = 0.0;
+ for(i=0;i<tmpmdsize;i++) {
+ sp = sp + one[i].zvelocity;
+ }
+ sp = sp / tmpmdsize;
- ts = tscale * ekin;
- sc = h * Math.sqrt(tref/ts);
+ for(i=0;i<tmpmdsize;i++) {
+ one[i].zvelocity = one[i].zvelocity - sp;
+ ekin = ekin + one[i].zvelocity*one[i].zvelocity;
+ }
+ ts = tscale * ekin;
+ sc = h * Math.sqrt(tref/ts);
- for(i=0;i<mdsize;i++) {
- one[i].xvelocity = one[i].xvelocity * sc;
- one[i].yvelocity = one[i].yvelocity * sc;
- one[i].zvelocity = one[i].zvelocity * sc;
+ for(i=0;i<tmpmdsize;i++) {
- }
+ one[i].xvelocity = one[i].xvelocity * sc;
+ one[i].yvelocity = one[i].yvelocity * sc;
+ one[i].zvelocity = one[i].zvelocity * sc;
+ }
/* Synchronise threads and start timer before MD simulation */
- br.DoBarrier(id);
- //Barrier.enterBarrier(br);
- if (id == 0) JGFInstrumentor.startTimer("Section3:MolDyn:Run", instr.timers);
- // Barrier.enterBarrier(br);
- br.DoBarrier(id);
-
+ Barrier.enterBarrier(tmpbr);
+ //System.clearPrefetchCache();
+ //int myid;
+ //atomic {
+ // myid = id;
+ //}
+ //TournamentBarrier.enterBarrier(myid, tmpbr);
+ //if (id == 0) JGFInstrumentor.startTimer("Section3:MolDyn:Run", instr.timers);
+ //Barrier.enterBarrier(tmpbr);
/* MD simulation */
- move = 0;
- for (move=0;move<movemx;move++) {
-
- /* move the particles and update velocities */
+ for (int move=0;move<movemx;move++) {
+ /* move the particles and update velocities */
- for (i=0;i<mdsize;i++) {
- one[i].domove(side,i);
- }
+ for (i=0;i<tmpmdsize;i++) {
+ one[i].domove(side,i);
+ }
/* Barrier */
- br.DoBarrier(id);
- //Barrier.enterBarrier(br);
-
- if(id==0) {
- for(j=0;j<3;j++) {
- for (i=0;i<mdsize;i++) {
- sh_force[j][i] = 0.0;
+ //System.printString("Barrier #2\n");
+ Barrier.enterBarrier(tmpbr);
+ //System.clearPrefetchCache();
+ //TournamentBarrier.enterBarrier(myid, tmpbr);
+
+ if(id==0) {
+ for(j=0;j<3;j++) {
+ for (i=0;i<tmpmdsize;i++) {
+ sh_force[j][i] = 0.0;
+ }
}
}
- }
- mymd.epot[id] = 0.0;
- mymd.vir[id] = 0.0;
- mymd.interacts[id] = 0;
-
- /* Barrier */
- //Barrier.enterBarrier(br);
- br.DoBarrier(id);
+ mymd.epot[id] = 0.0;
+ mymd.vir[id] = 0.0;
+ mymd.interacts[id] = 0;
+ /* Barrier */
+ //System.printString("Barrier #3\n");
+ Barrier.enterBarrier(tmpbr);
+ //System.clearPrefetchCache();
+ //TournamentBarrier.enterBarrier(myid, tmpbr);
- /* compute forces */
+ /* compute forces */
- for (i=0+id;i<mdsize;i+=nthreads) {
- one[i].force(side,rcoff,mdsize,i,xx,yy,zz,mymd);
- }
+ for (i=0+id;i<tmpmdsize;i+=nthreads) {
+ one[i].force(side,rcoff,tmpmdsize,i,xx,yy,zz,mymd);
+ }
/* Barrier */
- //Barrier.enterBarrier(br);
- br.DoBarrier(id);
+ //System.printString("Barrier #4\n");
+ Barrier.enterBarrier(tmpbr);
+ //System.clearPrefetchCache();
+ //TournamentBarrier.enterBarrier(myid, tmpbr);
/* update force arrays */
-
- if(id == 0) {
- for(int k=0;k<3;k++) {
- for(i=0;i<mdsize;i++) {
- for(j=0;j<nthreads;j++) {
- sh_force[k][i] += sh_force2[k][j][i];
+ if(id == 0) {
+ for(int k=0;k<3;k++) {
+ for(i=0;i<tmpmdsize;i++) {
+ for(j=0;j<nthreads;j++) {
+ sh_force[k][i] += sh_force2[k][j][i];
+ }
}
}
}
- }
- if(id == 0) {
- for(int k=0;k<3;k++) {
- for(i=0;i<mdsize;i++) {
- for(j=0;j<nthreads;j++) {
- sh_force2[k][j][i] = 0.0;
+ if(id == 0) {
+ for(int k=0;k<3;k++) {
+ for(i=0;i<tmpmdsize;i++) {
+ for(j=0;j<nthreads;j++) {
+ sh_force2[k][j][i] = 0.0;
+ }
}
}
}
- }
- if(id==0) {
- for(j=1;j<nthreads;j++) {
- mymd.epot[0] += mymd.epot[j];
- mymd.vir[0] += mymd.vir[j];
- }
- for(j=1;j<nthreads;j++) {
- mymd.epot[j] = mymd.epot[0];
- mymd.vir[j] = mymd.vir[0];
- }
- for(j=0;j<nthreads;j++) {
- mymd.interactions += mymd.interacts[j];
+ if(id==0) {
+ for(j=1;j<nthreads;j++) {
+ mymd.epot[0] += mymd.epot[j];
+ mymd.vir[0] += mymd.vir[j];
+ }
+ for(j=1;j<nthreads;j++) {
+ mymd.epot[j] = mymd.epot[0];
+ mymd.vir[j] = mymd.vir[0];
+ }
+ for(j=0;j<nthreads;j++) {
+ mymd.interactions += mymd.interacts[j];
+ }
}
- }
/* Barrier */
- //Barrier.enterBarrier(br);
- br.DoBarrier(id);
-
- if(id == 0) {
- for (j=0;j<3;j++) {
- for (i=0;i<mdsize;i++) {
- sh_force[j][i] = sh_force[j][i] * hsq2;
+ //System.printString("Barrier #5\n");
+ Barrier.enterBarrier(tmpbr);
+ //System.clearPrefetchCache();
+ //TournamentBarrier.enterBarrier(myid, tmpbr);
+
+ if(id == 0) {
+ for (j=0;j<3;j++) {
+ for (i=0;i<tmpmdsize;i++) {
+ sh_force[j][i] = sh_force[j][i] * hsq2;
+ }
}
}
- }
- sum = 0.0;
+ sum = 0.0;
+
/* Barrier */
- //Barrier.enterBarrier(br);
- br.DoBarrier(id);
+ //System.printString("Barrier #6\n");
+ Barrier.enterBarrier(tmpbr);
+ //System.clearPrefetchCache();
+ //TournamentBarrier.enterBarrier(myid, tmpbr);
- /*scale forces, update velocities */
+ /*scale forces, update velocities */
- for (i=0;i<mdsize;i++) {
- sum = sum + one[i].mkekin(hsq2,i);
- }
+ for (i=0;i<tmpmdsize;i++) {
+ sum = sum + one[i].mkekin(hsq2,i);
+ }
- ekin = sum/hsq;
+ ekin = sum/hsq;
- vel = 0.0;
- count = 0.0;
+ vel = 0.0;
+ count = 0.0;
- /* average velocity */
+ /* average velocity */
- for (i=0;i<mdsize;i++) {
- velt = one[i].velavg(vaverh,h);
- if(velt > vaverh) { count = count + 1.0; }
- vel = vel + velt;
- }
+ for (i=0;i<tmpmdsize;i++) {
+ velt = one[i].velavg(vaverh,h);
+ if(velt > vaverh) { count = count + 1.0; }
+ vel = vel + velt;
+ }
- vel = vel / h;
+ vel = vel / h;
- /* temperature scale if required */
+ /* temperature scale if required */
- if((move < istop) && (((move+1) % irep) == 0)) {
- sc = Math.sqrt(tref / (tscale*ekin));
- for (i=0;i<mdsize;i++) {
- one[i].dscal(sc,1);
+ if((move < istop) && (((move+1) % irep) == 0)) {
+ sc = Math.sqrt(tref / (tscale*ekin));
+ for (i=0;i<tmpmdsize;i++) {
+ one[i].dscal(sc,1);
+ }
+ ekin = tref / tscale;
}
- ekin = tref / tscale;
- }
- /* sum to get full potential energy and virial */
+ /* sum to get full potential energy and virial */
- if(((move+1) % iprint) == 0) {
- mymd.ek[id] = 24.0*ekin;
- mymd.epot[id] = 4.0*mymd.epot[id];
- etot = mymd.ek[id] + mymd.epot[id];
- temp = tscale * ekin;
- pres = den * 16.0 * (ekin - mymd.vir[id]) / mdsize;
- vel = vel / mdsize;
- rp = (count / mdsize) * 100.0;
- }
-
- //Barrier.enterBarrier(br);
- br.DoBarrier(id);
+ if(((move+1) % iprint) == 0) {
+ mymd.ek[id] = 24.0*ekin;
+ mymd.epot[id] = 4.0*mymd.epot[id];
+ etot = mymd.ek[id] + mymd.epot[id];
+ temp = tscale * ekin;
+ pres = tmpden * 16.0 * (ekin - mymd.vir[id]) / tmpmdsize;
+ vel = vel / tmpmdsize;
+ rp = (count / tmpmdsize) * 100.0;
+ }
+ //System.printString("Barrier #7\n");
+ Barrier.enterBarrier(tmpbr);
+ //System.clearPrefetchCache();
+ //TournamentBarrier.enterBarrier(myid, tmpbr);
}
-
- //Barrier.enterBarrier(br);
- br.DoBarrier(id);
- if (id == 0) JGFInstrumentor.stopTimer("Section3:MolDyn:Run", instr.timers);
-
+ //System.printString("Barrier #8\n");
+ Barrier.enterBarrier(tmpbr);
+ //System.clearPrefetchCache();
+ //TournamentBarrier.enterBarrier(myid, tmpbr);
+ //if (id == 0) JGFInstrumentor.stopTimer("Section3:MolDyn:Run", instr.timers);
+ //System.printString("End run method\n");
}
}
* All rights reserved. *
* *
**************************************************************************/
-import java.io.*;
-import java.util.*;
-
public class JGFMolDynBenchSizeA {
public static void main(String argv[]){
if(argv.length != 0 ) {
nthreads = Integer.parseInt(argv[0]);
} else {
- System.out.println("The no of threads has not been specified, defaulting to 1");
- System.out.println(" ");
+ System.printString("The no of threads has not been specified, defaulting to 1\n");
+ System.printString(" " + "\n");
nthreads = 1;
}
JGFInstrumentor instr = new JGFInstrumentor();
JGFInstrumentor.printHeader(3,0,nthreads);
- JGFMolDynBench mold = new JGFMolDynBench(nthreads, instr);
+ JGFMolDynBench mold;
+ mold = new JGFMolDynBench(nthreads);
int size = 0;
JGFInstrumentor.addTimer("Section3:MolDyn:Total", "Solutions",size, instr.timers);
JGFInstrumentor.addTimer("Section3:MolDyn:Run", "Interactions",size, instr.timers);
- mold.JGFsetsize(size);
+ mold.JGFsetsize(size);
JGFInstrumentor.startTimer("Section3:MolDyn:Total", instr.timers);
- mold.JGFinitialise();
- mold.JGFapplication();
- mold.JGFvalidate();
+ JGFMolDynBench tmp;
+ mold.JGFinitialise();
+ JGFMolDynBench.JGFapplication(mold);
+ /* Validate data */
+ double[] refval = new double[2];
+ refval[0] = 1731.4306625334357;
+ refval[1] = 7397.392307839352;
+ double dval;
+ //System.printString("Here #1\n");
+ dval = mold.ek[0];
+ //System.printString("Here #2\n");
+ double dev = Math.fabs(dval - refval[size]);
+ //long ldev = (long)dev * 1000000;
+ //System.printString("ldev= "+ldev);
+ //long ltmp = (long)1.0e-10 * 1000000;
+ //System.printString("ltmp= "+ltmp);
+ if (dev > 1.0e-10 ){
+ //if (ldev > ltmp ){
+ System.printString("Validation failed\n");
+ System.printString("Kinetic Energy = " + (long)dval + " " + (long)dev + " " + size + "\n");
+ }
+ System.printString("End of JGFvalidate\n");
JGFInstrumentor.stopTimer("Section3:MolDyn:Total", instr.timers);
+ double interactions;
+ System.printString("Here #3\n");
+ interactions = mold.interactions;
+ System.printString("Here #4\n");
- JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Run", (double) (mold.interactions), instr.timers);
+ JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Run", (double) interactions, instr.timers);
JGFInstrumentor.addOpsToTimer("Section3:MolDyn:Total", 1, instr.timers);
JGFInstrumentor.printTimer("Section3:MolDyn:Run", instr.timers);
}
public JGFTimer(String name){
- this(name,"");
+ this.name = name;
+ this.opname = "";
+ reset();
}
public void start(){
- if (on) System.out.println("Warning timer " + name + " was already turned on");
+ if (on) System.printString("Warning timer " + " was already turned on\n");
on = true;
start_time = System.currentTimeMillis();
}
public void stop(){
time += (double) (System.currentTimeMillis()-start_time) / 1000.;
- if (!on) System.out.println("Warning timer " + name + " wasn't turned on");
+ if (!on) System.printString("Warning timer " + " wasn't turned on\n");
calls++;
on = false;
}
}
public void longprint(){
- System.out.println("Timer Calls Time(s) Performance("+opname+"/s)");
- System.out.println(name + " " + calls + " " + time + " " + this.perf());
+ System.printString("Timer Calls Time(s) Performance("+opname+"/s)\n");
+ System.printString(name + " " + calls + " " + (long)time + " " + (long)this.perf() + "\n");
}
public void print(){
if (opname.equals("")) {
- System.out.println(name + " " + time + " (s)");
+ System.printString(name + " " + (long)time + " (s)\n");
}
else {
-
- switch(size) {
- case 0:
- System.out.println(name + ":SizeA" + "\t" + time + " (s) \t " + (float)this.perf() + "\t"
- + " ("+opname+"/s)");
- break;
- case 1:
- System.out.println(name + ":SizeB" + "\t" + time + " (s) \t " + (float)this.perf() + "\t"
- + " ("+opname+"/s)");
- break;
- case 2:
- System.out.println(name + ":SizeC" + "\t" + time + " (s) \t " + (float)this.perf() + "\t"
- + " ("+opname+"/s)");
- break;
- default:
- System.out.println(name + "\t" + time + " (s) \t " + (float)this.perf() + "\t"
- + " ("+opname+"/s)");
- break;
+ if(size == 0) {
+ System.printString(name + ":SizeA" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
+ } else if (size == 1) {
+ System.printString(name + ":SizeB" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
+ } else if (size == 2) {
+ System.printString(name + ":SizeC" + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
+ } else{
+ System.printString(name + "\t" + (long)time + " (s) \t " + (long)this.perf() + "\t" + " ("+opname+"/s)\n");
}
-
}
}
// pad name to 40 characters
while ( name.length() < 40 ) name = name + " ";
- System.out.println(name + "\t" + (float)this.perf() + "\t"
- + " ("+opname+"/s)");
+ System.printString(name + "\t" + (long)this.perf() + "\t"
+ + " ("+opname+"/s)\n");
}
}
-SRC = JGFMolDynBenchSizeA
+
+#SRC = JGFMolDynBenchSizeA
+#default:
+# javac ${SRC}.java
+#run:
+# java ${SRC} 2
+#
+#clean:
+# rm *.class
+
+MAINCLASS=JGFMolDynBenchSizeA
+SRC=${MAINCLASS}.java \
+JGFInstrumentor.java \
+JGFTimer.java \
+JGFMolDynBench.java \
+Barrier.java
+#FLAGS=-dsm -prefetch -excprefetch particle.force -excprefetch particle.domove -excprefetch particle.mkekin -excprefetch TournamentBarrier.DoBarrier -excprefetch JGFMolDynBench.JGFvalidate -excprefetch JGFMolDynBench.JGFapplication -optimize -debug -profile -mainclass ${MAINCLASS} -o ${MAINCLASS} -trueprob 0.8
+FLAGS2= -thread -mainclass ${MAINCLASS} -o ${MAINCLASS}NP
+
default:
- javac ${SRC}.java
-run:
- java ${SRC} 2
+ ../../../../buildscript ${FLAGS2} ${SRC}
+# ../../../../buildscript ${FLAGS} ${SRC}
clean:
- rm *.class
+ rm -rf tmpbuilddirectory/
+ rm *.bin
FLAGS2=-dsm -nooptimize -debug -profile -mainclass ${MAINCLASS}
default:
-# ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC}
-# ../../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC}
- ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}1NP ${SRC}
- ../../../../buildscript ${FLAGS} -o ${MAINCLASS}1 ${SRC}
- cp ${MAINCLASS}1NP.bin ${MAINCLASS}2NP.bin
- cp ${MAINCLASS}1.bin ${MAINCLASS}2.bin
- cp ${MAINCLASS}1NP.bin ${MAINCLASS}3NP.bin
- cp ${MAINCLASS}1.bin ${MAINCLASS}3.bin
- cp ${MAINCLASS}1NP.bin ${MAINCLASS}4NP.bin
- cp ${MAINCLASS}1.bin ${MAINCLASS}4.bin
+ ../../../../buildscript ${FLAGS2} -o ${MAINCLASS}NP ${SRC}
+ ../../../../buildscript ${FLAGS} -o ${MAINCLASS}P ${SRC}
+ cp ${MAINCLASS}NP.bin ${MAINCLASS}1NP.bin
+ cp ${MAINCLASS}P.bin ${MAINCLASS}1.bin
+ cp ${MAINCLASS}NP.bin ${MAINCLASS}2NP.bin
+ cp ${MAINCLASS}P.bin ${MAINCLASS}2.bin
+ cp ${MAINCLASS}NP.bin ${MAINCLASS}3NP.bin
+ cp ${MAINCLASS}P.bin ${MAINCLASS}3.bin
+ cp ${MAINCLASS}NP.bin ${MAINCLASS}4NP.bin
+ cp ${MAINCLASS}P.bin ${MAINCLASS}4.bin
clean:
rm -rf tmpbuilddirectory
--- /dev/null
+#!/bin/sh
+
+for file in `ls runlog/*.txt`
+do
+ echo -n $file
+ cat $file | awk '{sum += $1} END {print " "sum/NR}'
+done
JGFSORBenchSizeA:SOR/dsm::2:3:4:sorverA
JGFLUFactBenchSizeA:LUFact/dsm::2:4:lufactverA
-JGFLUFactBenchSizeB:LUFact/dsm::2:4:lufactverB
MatrixMultiply:MatrixMultiply:1 200 30:2 200 30:3 200 30:4 200 30:mmver200
MatrixMultiply:MatrixMultiply:1 600:2 600:3 600:4 600:mmver600
Em3d:Em3d/dsm:-T 1 -N 4000 -d 130 -p -i 3:-T 2 -N 4000 -d 130 -p -i 3:-T 3 -N 4000 -d 130 -p -i 3:-T 4 -N 4000 -d 130 -p -i 3:em3dver40001303
cd $BMDIR
echo "---------- Running local $BMDIR non-prefetch on 1 machine ---------- "
-#localrun 10
+ localrun 10
echo "---------- Running single thread remote $BMDIR non-prefetch on 2 machines ---------- "
-# oneremote 10 1 $NONPREFETCH
+ oneremote 10 1 $NONPREFETCH
echo "---------- Running single thread remote $BMDIR prefetch on 2 machines ---------- "
-# oneremote 10 1 $PREFETCH
+ oneremote 10 1 $PREFETCH
echo "---------- Running two threads $BMDIR non-prefetch on 2 machines ---------- "
-# run 10 2 $NONPREFETCH2
+ run 10 2 $NONPREFETCH2
echo "---------- Running two threads $BMDIR prefetch on 2 machines ---------- "
- run 4 2 $PREFETCH2
+ run 10 2 $PREFETCH2
echo "---------- Running three threads $BMDIR non-prefetch on 3 machines ---------- "
-# run 10 3 $NONPREFETCH3
+ run 10 3 $NONPREFETCH3
echo "---------- Running three threads $BMDIR prefetch on 3 machines ---------- "
-# run 10 3 $PREFETCH3
+ run 10 3 $PREFETCH3
echo "---------- Running four threads $BMDIR non-prefetch on 4 machines ---------- "
-# run 10 4 $NONPREFETCH4
+ run 10 4 $NONPREFETCH4
echo "---------- Running four threads $BMDIR prefetch on 4 machines ---------- "
-# run 10 4 $PREFETCH4
+ run 10 4 $PREFETCH4
cd $TOPDIR
}
cd $TOPDIR
}
-benchmarks='array'
-#benchmarks='array chase mmver200 mmver600 em3dver40001303 sorverA'
+benchmarks='array chase mmver200 mmver600 em3dver40001303 sorverA'
echo "---------- Clean old files ---------- "
rm runlog/*
fi
done
+#----------Calulates the averages -----------
for file in `ls runlog/*.txt`
do
echo -n $file >> average.txt
+++ /dev/null
-/**************************************************************************
-* *
-* Java Grande Forum Benchmark Suite - Thread Version 1.0 *
-* *
-* produced by *
-* *
-* Java Grande Benchmarking Project *
-* *
-* at *
-* *
-* Edinburgh Parallel Computing Centre *
-* *
-* email: epcc-javagrande@epcc.ed.ac.uk *
-* *
-* *
-* This version copyright (c) The University of Edinburgh, 2001. *
-* All rights reserved. *
-* *
-**************************************************************************/
-/**************************************************************************
-* Ported for DSTM Benchmark *
-**************************************************************************/
-
-
-import crypt.*;
-import jgfutil.*;
-
-public class JGFCryptBenchSizeA{
-
- global JGFIntrumentor instr;
-
- public static void main(String argv[]){
-
- int nthreads;
-
- if(argv.length != 0 ) {
- nthreads = Integer.parseInt(argv[0]);
- } else {
- System.printString("The no of threads has not been specified, defaulting to 1");
- System.printString(" ");
- nthreads = 1;
- }
-
- instr = new JGFInstrumentor();
- instr.printHeader(2,0,nthreads);
-
- JGFCryptBench cb = new JGFCryptBench(nthreads, instr);
- cb.JGFrun(0);
-
- }
-}
-
-
+++ /dev/null
-/**************************************************************************
-* *
-* Java Grande Forum Benchmark Suite - Thread Version 1.0 *
-* *
-* produced by *
-* *
-* Java Grande Benchmarking Project *
-* *
-* at *
-* *
-* Edinburgh Parallel Computing Centre *
-* *
-* email: epcc-javagrande@epcc.ed.ac.uk *
-* *
-* Original version of this code by *
-* Gabriel Zachmann (zach@igd.fhg.de) *
-* *
-* This version copyright (c) The University of Edinburgh, 2001. *
-* All rights reserved. *
-* *
-**************************************************************************/
-/**************************************************************************
-* Ported for DSTM Benchmark *
-**************************************************************************/
-
-
-/**
-* Class IDEATest
-*
-* This test performs IDEA encryption then decryption. IDEA stands
-* for International Data Encryption Algorithm. The test is based
-* on code presented in Applied Cryptography by Bruce Schnier,
-* which was based on code developed by Xuejia Lai and James L.
-* Massey.
-
-**/
-
-package crypt;
-
-import java.util.*;
-import jgfutil.*;
-
-class IDEATest
-{
-
-// Declare class data. Byte buffer plain1 holds the original
-// data for encryption, crypt1 holds the encrypted data, and
-// plain2 holds the decrypted data, which should match plain1
-// byte for byte.
-
-int array_rows;
-
-byte [] plain1; // Buffer for plaintext data.
-byte [] crypt1; // Buffer for encrypted data.
-byte [] plain2; // Buffer for decrypted data.
-
-short [] userkey; // Key for encryption/decryption.
-int [] Z; // Encryption subkey (userkey derived).
-int [] DK; // Decryption subkey (userkey derived).
-
-
-
-void Do()
-{
-
- IDEARunner th[] = new IDEARunner [JGFCryptBench.nthreads];
-
- // Start the stopwatch.
- JGFInstrumentor.startTimer("Section2:Crypt:Kernel");
-
- // Encrypt plain1.
- for(int i=1;i<JGFCryptBench.nthreads;i++) {
- th[i] = new IDEARunner(i,plain1,crypt1,Z);
- th[i].start();
- }
-
- th[0] = new IDEARunner(0,plain1,crypt1,Z);
- th[0].start();
-
-
- for(int i=1;i<JGFCryptBench.nthreads;i++) {
- th[i].join();
- }
-
- // Decrypt.
- for(int i=1;i<JGFCryptBench.nthreads;i++) {
- th[i] = new IDEARunner(i,crypt1,plain2,DK);
- th[i].start();
- }
-
- th[0] = new IDEARunner(0,crypt1,plain2,DK);
- th[0].start();
-
-
- for(int i=1;i<JGFCryptBench.nthreads;i++) {
- th[i].join();
- }
-
-
- // Stop the stopwatch.
- JGFInstrumentor.stopTimer("Section2:Crypt:Kernel");
-
-}
-
-/*
-* buildTestData
-*
-* Builds the data used for the test -- each time the test is run.
-*/
-
-void buildTestData()
-{
-
-
- // Create three byte arrays that will be used (and reused) for
- // encryption/decryption operations.
-
- plain1 = new byte [array_rows];
- crypt1 = new byte [array_rows];
- plain2 = new byte [array_rows];
-
-
- Random rndnum = new Random(136506717L); // Create random number generator.
-
-
- // Allocate three arrays to hold keys: userkey is the 128-bit key.
- // Z is the set of 16-bit encryption subkeys derived from userkey,
- // while DK is the set of 16-bit decryption subkeys also derived
- // from userkey. NOTE: The 16-bit values are stored here in
- // 32-bit int arrays so that the values may be used in calculations
- // as if they are unsigned. Each 64-bit block of plaintext goes
- // through eight processing rounds involving six of the subkeys
- // then a final output transform with four of the keys; (8 * 6)
- // + 4 = 52 subkeys.
-
- userkey = new short [8]; // User key has 8 16-bit shorts.
- Z = new int [52]; // Encryption subkey (user key derived).
- DK = new int [52]; // Decryption subkey (user key derived).
-
- // Generate user key randomly; eight 16-bit values in an array.
-
- for (int i = 0; i < 8; i++)
- {
- // Again, the random number function returns int. Converting
- // to a short type preserves the bit pattern in the lower 16
- // bits of the int and discards the rest.
-
- userkey[i] = (short) rndnum.nextInt();
- }
-
- // Compute encryption and decryption subkeys.
-
- calcEncryptKey();
- calcDecryptKey();
-
- // Fill plain1 with "text."
- for (int i = 0; i < array_rows; i++)
- {
- plain1[i] = (byte) i;
-
- // Converting to a byte
- // type preserves the bit pattern in the lower 8 bits of the
- // int and discards the rest.
- }
-}
-
-/*
-* calcEncryptKey
-*
-* Builds the 52 16-bit encryption subkeys Z[] from the user key and
-* stores in 32-bit int array. The routing corrects an error in the
-* source code in the Schnier book. Basically, the sense of the 7-
-* and 9-bit shifts are reversed. It still works reversed, but would
-* encrypted code would not decrypt with someone else's IDEA code.
-*/
-
-private void calcEncryptKey()
-{
- int j; // Utility variable.
-
- for (int i = 0; i < 52; i++) // Zero out the 52-int Z array.
- Z[i] = 0;
-
- for (int i = 0; i < 8; i++) // First 8 subkeys are userkey itself.
- {
- Z[i] = userkey[i] & 0xffff; // Convert "unsigned"
- // short to int.
- }
-
- // Each set of 8 subkeys thereafter is derived from left rotating
- // the whole 128-bit key 25 bits to left (once between each set of
- // eight keys and then before the last four). Instead of actually
- // rotating the whole key, this routine just grabs the 16 bits
- // that are 25 bits to the right of the corresponding subkey
- // eight positions below the current subkey. That 16-bit extent
- // straddles two array members, so bits are shifted left in one
- // member and right (with zero fill) in the other. For the last
- // two subkeys in any group of eight, those 16 bits start to
- // wrap around to the first two members of the previous eight.
-
- for (int i = 8; i < 52; i++)
- {
- j = i % 8;
- if (j < 6)
- {
- Z[i] = ((Z[i -7]>>>9) | (Z[i-6]<<7)) // Shift and combine.
- & 0xFFFF; // Just 16 bits.
- continue; // Next iteration.
- }
-
- if (j == 6) // Wrap to beginning for second chunk.
- {
- Z[i] = ((Z[i -7]>>>9) | (Z[i-14]<<7))
- & 0xFFFF;
- continue;
- }
-
- // j == 7 so wrap to beginning for both chunks.
-
- Z[i] = ((Z[i -15]>>>9) | (Z[i-14]<<7))
- & 0xFFFF;
- }
-}
-
-/*
-* calcDecryptKey
-*
-* Builds the 52 16-bit encryption subkeys DK[] from the encryption-
-* subkeys Z[]. DK[] is a 32-bit int array holding 16-bit values as
-* unsigned.
-*/
-
-private void calcDecryptKey()
-{
- int j, k; // Index counters.
- int t1, t2, t3; // Temps to hold decrypt subkeys.
-
- t1 = inv(Z[0]); // Multiplicative inverse (mod x10001).
- t2 = - Z[1] & 0xffff; // Additive inverse, 2nd encrypt subkey.
- t3 = - Z[2] & 0xffff; // Additive inverse, 3rd encrypt subkey.
-
- DK[51] = inv(Z[3]); // Multiplicative inverse (mod x10001).
- DK[50] = t3;
- DK[49] = t2;
- DK[48] = t1;
-
- j = 47; // Indices into temp and encrypt arrays.
- k = 4;
- for (int i = 0; i < 7; i++)
- {
- t1 = Z[k++];
- DK[j--] = Z[k++];
- DK[j--] = t1;
- t1 = inv(Z[k++]);
- t2 = -Z[k++] & 0xffff;
- t3 = -Z[k++] & 0xffff;
- DK[j--] = inv(Z[k++]);
- DK[j--] = t2;
- DK[j--] = t3;
- DK[j--] = t1;
- }
-
- t1 = Z[k++];
- DK[j--] = Z[k++];
- DK[j--] = t1;
- t1 = inv(Z[k++]);
- t2 = -Z[k++] & 0xffff;
- t3 = -Z[k++] & 0xffff;
- DK[j--] = inv(Z[k++]);
- DK[j--] = t3;
- DK[j--] = t2;
- DK[j--] = t1;
-}
-
-
-
-
-
-/*
-* mul
-*
-* Performs multiplication, modulo (2**16)+1. This code is structured
-* on the assumption that untaken branches are cheaper than taken
-* branches, and that the compiler doesn't schedule branches.
-* Java: Must work with 32-bit int and one 64-bit long to keep
-* 16-bit values and their products "unsigned." The routine assumes
-* that both a and b could fit in 16 bits even though they come in
-* as 32-bit ints. Lots of "& 0xFFFF" masks here to keep things 16-bit.
-* Also, because the routine stores mod (2**16)+1 results in a 2**16
-* space, the result is truncated to zero whenever the result would
-* zero, be 2**16. And if one of the multiplicands is 0, the result
-* is not zero, but (2**16) + 1 minus the other multiplicand (sort
-* of an additive inverse mod 0x10001).
-
-* NOTE: The java conversion of this routine works correctly, but
-* is half the speed of using Java's modulus division function (%)
-* on the multiplication with a 16-bit masking of the result--running
-* in the Symantec Caje IDE. So it's not called for now; the test
-* uses Java % instead.
-*/
-
-private int mul(int a, int b)
-{
- int ret;
- long p; // Large enough to catch 16-bit multiply
- // without hitting sign bit.
- if (a != 0)
- {
- if(b != 0)
- {
- p = (long) a * b;
- b = (int) p & 0xFFFF; // Lower 16 bits.
- a = (int) p >>> 16; // Upper 16 bits.
- if (b < a)
- return (b - a + 1) & 0xFFFF;
- else
- return (b - a) & 0xFFFF;
- }
- else
- return ((1 - a) & 0xFFFF); // If b = 0, then same as
- // 0x10001 - a.
- }
- else // If a = 0, then return
- return((1 - b) & 0xFFFF); // same as 0x10001 - b.
-}
-
-/*
-* inv
-*
-* Compute multiplicative inverse of x, modulo (2**16)+1 using
-* extended Euclid's GCD (greatest common divisor) algorithm.
-* It is unrolled twice to avoid swapping the meaning of
-* the registers. And some subtracts are changed to adds.
-* Java: Though it uses signed 32-bit ints, the interpretation
-* of the bits within is strictly unsigned 16-bit.
-*/
-
-private int inv(int x)
-{
- int t0, t1;
- int q, y;
-
- if (x <= 1) // Assumes positive x.
- return(x); // 0 and 1 are self-inverse.
-
- t1 = 0x10001 / x; // (2**16+1)/x; x is >= 2, so fits 16 bits.
- y = 0x10001 % x;
- if (y == 1)
- return((1 - t1) & 0xFFFF);
-
- t0 = 1;
- do {
- q = x / y;
- x = x % y;
- t0 += q * t1;
- if (x == 1) return(t0);
- q = y / x;
- y = y % x;
- t1 += q * t0;
- } while (y != 1);
-
- return((1 - t1) & 0xFFFF);
-}
-
-/*
-* freeTestData
-*
-* Nulls arrays and forces garbage collection to free up memory.
-*/
-
-void freeTestData()
-{
- plain1 = null;
- crypt1 = null;
- plain2 = null;
- userkey = null;
- Z = null;
- DK = null;
-
- //System.gc(); // Force garbage collection.
-}
-
-
-}
-
-
-
-class IDEARunner extends Thread {
-
- int id,key[];
- byte text1[],text2[];
-
- public IDEARunner(int id, byte [] text1, byte [] text2, int [] key) {
- this.id = id;
- this.text1=text1;
- this.text2=text2;
- this.key=key;
- }
-/*
-* run()
-*
-* IDEA encryption/decryption algorithm. It processes plaintext in
-* 64-bit blocks, one at a time, breaking the block into four 16-bit
-* unsigned subblocks. It goes through eight rounds of processing
-* using 6 new subkeys each time, plus four for last step. The source
-* text is in array text1, the destination text goes into array text2
-* The routine represents 16-bit subblocks and subkeys as type int so
-* that they can be treated more easily as unsigned. Multiplication
-* modulo 0x10001 interprets a zero sub-block as 0x10000; it must to
-* fit in 16 bits.
-*/
-
- public void run() {
- int ilow, iupper, slice, tslice, ttslice;
-
- tslice = text1.length / 8;
- ttslice = (tslice + JGFCryptBench.nthreads-1) / JGFCryptBench.nthreads;
- slice = ttslice*8;
-
- ilow = id*slice;
- iupper = (id+1)*slice;
- if(iupper > text1.length) iupper = text1.length;
-
-int i1 = ilow; // Index into first text array.
-int i2 = ilow; // Index into second text array.
-int ik; // Index into key array.
-int x1, x2, x3, x4, t1, t2; // Four "16-bit" blocks, two temps.
-int r; // Eight rounds of processing.
-
- for (int i =ilow ; i <iupper ; i +=8)
-{
-
- ik = 0; // Restart key index.
- r = 8; // Eight rounds of processing.
-
- // Load eight plain1 bytes as four 16-bit "unsigned" integers.
- // Masking with 0xff prevents sign extension with cast to int.
-
- x1 = text1[i1++] & 0xff; // Build 16-bit x1 from 2 bytes,
- x1 |= (text1[i1++] & 0xff) << 8; // assuming low-order byte first.
- x2 = text1[i1++] & 0xff;
- x2 |= (text1[i1++] & 0xff) << 8;
- x3 = text1[i1++] & 0xff;
- x3 |= (text1[i1++] & 0xff) << 8;
- x4 = text1[i1++] & 0xff;
- x4 |= (text1[i1++] & 0xff) << 8;
-
- do {
- // 1) Multiply (modulo 0x10001), 1st text sub-block
- // with 1st key sub-block.
-
- x1 = (int) ((long) x1 * key[ik++] % 0x10001L & 0xffff);
-
- // 2) Add (modulo 0x10000), 2nd text sub-block
- // with 2nd key sub-block.
-
- x2 = x2 + key[ik++] & 0xffff;
-
- // 3) Add (modulo 0x10000), 3rd text sub-block
- // with 3rd key sub-block.
-
- x3 = x3 + key[ik++] & 0xffff;
-
- // 4) Multiply (modulo 0x10001), 4th text sub-block
- // with 4th key sub-block.
-
- x4 = (int) ((long) x4 * key[ik++] % 0x10001L & 0xffff);
-
- // 5) XOR results from steps 1 and 3.
-
- t2 = x1 ^ x3;
-
- // 6) XOR results from steps 2 and 4.
- // Included in step 8.
-
- // 7) Multiply (modulo 0x10001), result of step 5
- // with 5th key sub-block.
-
- t2 = (int) ((long) t2 * key[ik++] % 0x10001L & 0xffff);
-
- // 8) Add (modulo 0x10000), results of steps 6 and 7.
-
- t1 = t2 + (x2 ^ x4) & 0xffff;
-
- // 9) Multiply (modulo 0x10001), result of step 8
- // with 6th key sub-block.
-
- t1 = (int) ((long) t1 * key[ik++] % 0x10001L & 0xffff);
-
- // 10) Add (modulo 0x10000), results of steps 7 and 9.
-
- t2 = t1 + t2 & 0xffff;
-
- // 11) XOR results from steps 1 and 9.
-
- x1 ^= t1;
-
- // 14) XOR results from steps 4 and 10. (Out of order).
-
- x4 ^= t2;
-
- // 13) XOR results from steps 2 and 10. (Out of order).
-
- t2 ^= x2;
-
- // 12) XOR results from steps 3 and 9. (Out of order).
-
- x2 = x3 ^ t1;
-
- x3 = t2; // Results of x2 and x3 now swapped.
-
- } while(--r != 0); // Repeats seven more rounds.
-
- // Final output transform (4 steps).
-
- // 1) Multiply (modulo 0x10001), 1st text-block
- // with 1st key sub-block.
-
- x1 = (int) ((long) x1 * key[ik++] % 0x10001L & 0xffff);
-
- // 2) Add (modulo 0x10000), 2nd text sub-block
- // with 2nd key sub-block. It says x3, but that is to undo swap
- // of subblocks 2 and 3 in 8th processing round.
-
- x3 = x3 + key[ik++] & 0xffff;
-
- // 3) Add (modulo 0x10000), 3rd text sub-block
- // with 3rd key sub-block. It says x2, but that is to undo swap
- // of subblocks 2 and 3 in 8th processing round.
-
- x2 = x2 + key[ik++] & 0xffff;
-
- // 4) Multiply (modulo 0x10001), 4th text-block
- // with 4th key sub-block.
-
- x4 = (int) ((long) x4 * key[ik++] % 0x10001L & 0xffff);
-
- // Repackage from 16-bit sub-blocks to 8-bit byte array text2.
-
- text2[i2++] = (byte) x1;
- text2[i2++] = (byte) (x1 >>> 8);
- text2[i2++] = (byte) x3; // x3 and x2 are switched
- text2[i2++] = (byte) (x3 >>> 8); // only in name.
- text2[i2++] = (byte) x2;
- text2[i2++] = (byte) (x2 >>> 8);
- text2[i2++] = (byte) x4;
- text2[i2++] = (byte) (x4 >>> 8);
-
-} // End for loop.
-
- } // End routine.
-
-} // End of class
-
-
-
-
-
-
-
-
-
+++ /dev/null
-/**************************************************************************
-* *
-* Java Grande Forum Benchmark Suite - Thread Version 1.0 *
-* *
-* produced by *
-* *
-* Java Grande Benchmarking Project *
-* *
-* at *
-* *
-* Edinburgh Parallel Computing Centre *
-* *
-* email: epcc-javagrande@epcc.ed.ac.uk *
-* *
-* *
-* This version copyright (c) The University of Edinburgh, 2001. *
-* All rights reserved. *
-* *
-**************************************************************************/
-/**************************************************************************
-* Ported for DSTM Benchmark *
-**************************************************************************/
-
-
-package crypt;
-import jgfutil.*;
-
-
-public class JGFCryptBench extends IDEATest {
-
- private int size;
- private int datasizes[];
- public int nthreads;
- global JGFInstrumentor instr;
-
- public JGFCryptBench(int nthreads, JGFInstrumentor instr)
- {
- this.nthreads = nthreads;
- this.instr = instr;
- datasizes = new int[3];
- datasizes[0] = 3000000;
- datasizes[1] = 20000000;
- datasizes[2] = 50000000;
- }
-
-
- public void JGFsetsize(int size){
- this.size = size;
- }
-
- public void JGFinitialise(){
- array_rows = datasizes[size];
- buildTestData();
- }
-
- public void JGFkernel(){
- Do();
- }
-
- public void JGFvalidate(){
- boolean error;
-
- error = false;
- for (int i = 0; i < array_rows; i++){
- error = (plain1 [i] != plain2 [i]);
- if (error){
- System.printString("Validation failed");
- System.printString("Original Byte " + i + " = " + plain1[i]);
- System.printString("Encrypted Byte " + i + " = " + crypt1[i]);
- System.printString("Decrypted Byte " + i + " = " + plain2[i]);
- //break;
- }
- }
- }
-
-
- public void JGFtidyup(){
- freeTestData();
- }
-
-
-
- public void JGFrun(int size){
-
-
- instr.addTimer("Section2:Crypt:Kernel", "Kbyte",size);
-
- JGFsetsize(size);
- JGFinitialise();
- JGFkernel();
- JGFvalidate();
- JGFtidyup();
-
-
- instr.addOpsToTimer("Section2:Crypt:Kernel", (2*array_rows)/1000.);
- instr.printTimer("Section2:Crypt:Kernel");
- }
-}
+++ /dev/null
-/**************************************************************************
-* *
-* Java Grande Forum Benchmark Suite - Thread Version 1.0 *
-* *
-* produced by *
-* *
-* Java Grande Benchmarking Project *
-* *
-* at *
-* *
-* Edinburgh Parallel Computing Centre *
-* *
-* email: epcc-javagrande@epcc.ed.ac.uk *
-* *
-* *
-* This version copyright (c) The University of Edinburgh, 1999. *
-* All rights reserved. *
-* *
-**************************************************************************/
-/**************************************************************************
-* Ported for DSTM Benchmark *
-**************************************************************************/
-
-
-package jgfutil;
-
-import java.util.*;
-
-public class JGFInstrumentor{
-
- private HashMap timers;
- private HashMap data;
-
- public JGFIntrumentor()
- {
- timers = new HashMap();
- data = new HashMap();
- }
-
- public void addTimer (String name){
-
- if (timers.containsKey(name)) {
- System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists");
- }
- else {
- timers.put(name, new JGFTimer(name));
- }
- }
-
- public void addTimer (String name, String opname){
-
- if (timers.containsKey(name)) {
- System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists");
- }
- else {
- timers.put(name, new JGFTimer(name,opname));
- }
-
- }
-
- public void addTimer (String name, String opname, int size){
-
- if (timers.containsKey(name)) {
- System.printString("JGFInstrumentor.addTimer: warning - timer " + name +
- " already exists");
- }
- else {
- timers.put(name, new JGFTimer(name,opname,size));
- }
-
- }
-
- public void startTimer(String name){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).start();
- }
- else {
- System.printString("JGFInstrumentor.startTimer: failed - timer " + name +
- " does not exist");
- }
-
- }
-
- public void stopTimer(String name){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).stop();
- }
- else {
- System.printString("JGFInstrumentor.stopTimer: failed - timer " + name +
- " does not exist");
- }
- }
-
- public void addOpsToTimer(String name, double count){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).addops(count);
- }
- else {
- System.printString("JGFInstrumentor.addOpsToTimer: failed - timer " + name +
- " does not exist");
- }
- }
-
- public void addTimeToTimer(String name, double added_time){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).addtime(added_time);
- }
- else {
- System.printString("JGFInstrumentor.addTimeToTimer: failed - timer " + name +
- " does not exist");
- }
-
-
-
- }
-
- public double readTimer(String name){
- double time;
- if (timers.containsKey(name)) {
- time = ((JGFTimer) timers.get(name)).time;
- }
- else {
- System.printString("JGFInstrumentor.readTimer: failed - timer " + name +
- " does not exist");
- time = 0.0;
- }
- return time;
- }
-
- public void resetTimer(String name){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).reset();
- }
- else {
- System.printString("JGFInstrumentor.resetTimer: failed - timer " + name +
- " does not exist");
- }
- }
-
- public void printTimer(String name){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).print();
- }
- else {
- System.printString("JGFInstrumentor.printTimer: failed - timer " + name +
- " does not exist");
- }
- }
-
- public void printperfTimer(String name){
- if (timers.containsKey(name)) {
- ((JGFTimer) timers.get(name)).printperf();
- }
- else {
- System.printString("JGFInstrumentor.printTimer: failed - timer " + name +
- " does not exist");
- }
- }
-
- public void storeData(String name, Object obj){
- data.put(name,obj);
- }
-
- public void retrieveData(String name, Object obj){
- obj = data.get(name);
- }
-
- public static void printHeader(int section, int size,int nthreads) {
-
- String header, base;
-
- header = "";
- base = "Java Grande Forum Thread Benchmark Suite - Version 1.0 - Section ";
-
- if (section == 1)
- {
- header = base + "1";
- }
- else if (section == 2)
- {
- if (size == 0)
- header = base + "2 - Size A";
- else if (size == 1)
- header = base + "2 - Size B";
- else if (size == 2)
- header = base + "2 - Size C";
- }
- else if (section == 3)
- {
- if (size == 0)
- header = base + "3 - Size A";
- else if (size == 1)
- header = base + "3 - Size B";
- }
-
- System.printString(header);
-
- if (nthreads == 1) {
- System.printString("Executing on " + nthreads + " thread");
- }
- else {
- System.printString("Executing on " + nthreads + " threads");
- }
-
- System.printString("");
-
- }
-
-}
+++ /dev/null
-/**************************************************************************
-* *
-* Java Grande Forum Benchmark Suite - Thread Version 1.0 *
-* *
-* produced by *
-* *
-* Java Grande Benchmarking Project *
-* *
-* at *
-* *
-* Edinburgh Parallel Computing Centre *
-* *
-* email: epcc-javagrande@epcc.ed.ac.uk *
-* *
-* *
-* This version copyright (c) The University of Edinburgh, 1999. *
-* All rights reserved. *
-* *
-**************************************************************************/
-/**************************************************************************
-* Ported for DSTM Benchmark *
-**************************************************************************/
-
-
-package jgfutil;
-
-public class JGFTimer {
-
- public String name;
- public String opname;
- public double time;
- public double opcount;
- public long calls;
- public int size = -1;
-
- private long start_time;
- private boolean on;
-
- public JGFTimer(String name, String opname){
- this.name = name;
- this.opname = opname;
- reset();
- }
-
- public JGFTimer(String name, String opname, int size){
- this.name = name;
- this.opname = opname;
- this.size = size;
- reset();
- }
-
- public JGFTimer(String name){
- this.name = name;
- this.opname = "";
- reset();
- }
-
-
-
- public void start(){
- if (on) System.printString("Warning timer " + name + " was already turned on");
- on = true;
- start_time = System.currentTimeMillis();
- }
-
-
- public void stop(){
- time += (double) (System.currentTimeMillis()-start_time) / 1000.;
- if (!on) System.printString("Warning timer " + name + " wasn't turned on");
- calls++;
- on = false;
- }
-
- public void addops(double count){
- opcount += count;
- }
-
- public void addtime(double added_time){
- time += added_time;
- }
-
- public void reset(){
- time = 0.0;
- calls = 0;
- opcount = 0;
- on = false;
- }
-
- public double perf(){
- return opcount / time;
- }
-
- public void longprint(){
- System.printString("Timer Calls Time(s) Performance("+opname+"/s)");
- System.printString(name + " " + calls + " " + time + " " + this.perf());
- }
-
- public void print(){
- if (opname.equals(""))
- {
- System.printString(name + " " + time + " (s)");
- }
- else
- {
- if(size == 0)
- System.printString(name + ":SizeA" + "\t" + time + " (s) \t " + (float)this.perf() + "\t" + " ("+opname+"/s)");
- else if (size == 1)
- System.printString(name + ":SizeB" + "\t" + time + " (s) \t " + (float)this.perf() + "\t" + " ("+opname+"/s)");
- else if (size == 2)
- System.printString(name + ":SizeC" + "\t" + time + " (s) \t " + (float)this.perf() + "\t" + " ("+opname+"/s)");
- else
- System.printString(name + "\t" + time + " (s) \t " + (float)this.perf() + "\t" + " ("+opname+"/s)");
- }
- }
-
-
- public void printperf(){
-
- String name;
- name = this.name;
-
- // pad name to 40 characters
- while ( name.length() < 40 ) name = name + " ";
-
- System.printString(name + "\t" + (float)this.perf() + "\t"
- + " ("+opname+"/s)");
- }
-
-}
+++ /dev/null
-MAINCLASS=JGFCryptBenchSizeA
-SRC=${MAINCLASS}.java \
-jgfutil/JGFInstrumentor.java \
-jgfutil/JGFTimer.java \
-crypt/IDEATest.java \
-crypt/JGFCryptBench.java
-FLAGS=-dsm -prefetch -nooptimize -debug -mainclass ${MAINCLASS} -o ${MAINCLASS}
-
-default:
- ../../../../buildscript ${FLAGS} ${SRC}
-