/** The x10 version of the original code (Stream) described in the following. The HPCC source code can be downloaded at http://icl.cs.utk.edu/hpcc/software/index.html (C) Copyright IBM Corp. 2006 Modified by S. Poole @ ORNL to be enable Integer variables. 2007. It is called IStream. This is the "quick-and-dirty" conversion. There will be another which is more optimized wrt to X10 capabilities. This can also be done with fewer arrays and better distributions. I will also change long to unsigned long. Later. **/ /*-----------------------------------------------------------------------*/ /* Program: Stream */ /* Revision: $Id: stream.x10,v 1.3 2007/04/10 20:32:11 ipeshansky Exp $ */ /* Original code developed by John D. McCalpin */ /* Programmers: John D. McCalpin */ /* Joe R. Zagar */ /* */ /* This program measures memory transfer rates in MB/s for simple */ /* computational kernels coded in C. */ /*-----------------------------------------------------------------------*/ /* Copyright 1991-2005: John D. McCalpin */ /*-----------------------------------------------------------------------*/ /* License: */ /* 1. You are free to use this program and/or to redistribute */ /* this program. */ /* 2. You are free to modify this program for your own use, */ /* including commercial use, subject to the publication */ /* restrictions in item 3. */ /* 3. You are free to publish results obtained from running this */ /* program, or from works that you derive from this program, */ /* with the following limitations: */ /* 3a. In order to be referred to as "STREAM benchmark results", */ /* published results must be in conformance to the STREAM */ /* Run Rules, (briefly reviewed below) published at */ /* http://www.cs.virginia.edu/stream/ref.html */ /* and incorporated herein by reference. */ /* As the copyright holder, John McCalpin retains the */ /* right to determine conformity with the Run Rules. */ /* 3b. Results based on modified source code or on runs not in */ /* accordance with the STREAM Run Rules must be clearly */ /* labelled whenever they are published. Examples of */ /* proper labelling include: */ /* "tuned STREAM benchmark results" */ /* "based on a variant of the STREAM benchmark code" */ /* Other comparable, clear and reasonable labelling is */ /* acceptable. */ /* 3c. Submission of results to the STREAM benchmark web site */ /* is encouraged, but not required. */ /* 4. Use of this program or creation of derived works based on this */ /* program constitutes acceptance of these licensing restrictions. */ /* 5. Absolutely no warranty is expressed or implied. */ /*-----------------------------------------------------------------------*/ /* INSTRUCTIONS: * * 1) Stream requires a good bit of memory to run. Adjust the * value of 'N' (below) to give a 'timing calibration' of * at least 20 clock-ticks. This will provide rate estimates * that should be good to about 5% precision. */ class istream { // public final static int N = (1 << 26); public final static int N = 200000; public final static int NTIMES = 10; /* * 3) Compile the code with full optimization. Many compilers * generate unreasonably bad code before the optimizer tightens * things up. If the results are unreasonably good, on the * other hand, the optimizer might be too smart for me! * * Try compiling with: * cc -O istream_omp.c -o istream_omp * * This is known to work on Cray, SGI, IBM, and Sun machines. * * * 4) Mail the results to mccalpin@cs.virginia.edu * Be sure to include: * a) computer hardware model number and software revision * b) the compiler flags * c) all of the output from the test case. * Thanks! * */ private static final String HLINE = "-------------------------------------------------------------"; static final region R = [0:N-1]; static final dist D = dist.factory.block(R); // static final double[:self.rect && self.zeroBased && self.rank==1] a = (double[:self.rect && self.zeroBased && self.rank==1]) new double[D]; // static final double[:self.rect && self.zeroBased && self.rank==1] b = (double[:self.rect && self.zeroBased && self.rank==1]) new double[D]; // static final double[:self.rect && self.zeroBased && self.rank==1] c = (double[:self.rect && self.zeroBased && self.rank==1]) new double[D]; // // For the Integer work. Quick and dirty. // static final long[:self.rect && self.zeroBased && self.rank==1] a = (long[:self.rect && self.zeroBased && self.rank==1]) new long[D]; static final long[:self.rect && self.zeroBased && self.rank==1] b = (long[:self.rect && self.zeroBased && self.rank==1]) new long[D]; static final long[:self.rect && self.zeroBased && self.rank==1] c = (long[:self.rect && self.zeroBased && self.rank==1]) new long[D]; static final long[:self.rect && self.zeroBased && self.rank==1] d = (long[:self.rect && self.zeroBased && self.rank==1]) new long[D]; static final long[:self.rect && self.zeroBased && self.rank==1] e = (long[:self.rect && self.zeroBased && self.rank==1]) new long[D]; static final double[] avgtime = new double[5]; static final double[] maxtime = new double[5]; static final double[] mintime = new double[5]; static { for (int i = 0; i < mintime.length; ++i) { mintime[i] = java.lang.Float.MAX_VALUE; } } static final String[] label = { "Copy: ", "Scale: ", "Add: ", "Triad: ", "SScale: "}; private static final int sizeOfDouble = 8; private static final int sizeOfLong = 8; private static final int sizeOfFloat = 4; private static final int sizeOfInt = 4; static final double bytes[] = new double[5]; static { for (int i = 0; i < bytes.length; ++i) { if (i < 2) { bytes[i] = 2 * sizeOfLong * N; } else if (i==3) { bytes[i] = 3 * sizeOfLong * N; } else { bytes[i] = 2 * sizeOfLong * N; } } }; public static void main(String[] args) { int quantum; int BytesPerWord; double t; final long scalar = 3; double times[][] = new double[5][NTIMES]; /* --- SETUP --- determine precision and check timing --- */ System.out.println(HLINE); System.out.println("ISTREAM version $Revision: 1.0 $"); System.out.println(HLINE); BytesPerWord = sizeOfLong; System.out.println("This system uses " + BytesPerWord + "bytes per LONG word."); System.out.println(HLINE); System.out.println("Array size = "+N); System.out.println("Total memory required = " + (3.0 * BytesPerWord) * ( (double) N / 1048576.0) + " MB."); System.out.println("Each test is run " + NTIMES + " times, but only"); System.out.println("the *best* time for each is used."); System.out.println(HLINE); /* Get initial value for system clock. */ for (int j=0; j= 1) System.out.println("Your clock granularity/precision appears to be " + quantum + " microseconds."); else System.out.println("Your clock granularity appears to be " + "less than one microsecond."); t = mysecond(); for (int j = 0; j < N; j++) a[j] = 2 * a[j]; t = 1.0E6 * (mysecond() - t); System.out.println("Each test below will take on the order" + " of " + t + " microseconds."); System.out.println(" (= "+(t/quantum)+" clock ticks)"); System.out.println("Increase the size of the arrays if this shows that"); System.out.println("you are not getting at least 20 clock ticks per test."); System.out.println(HLINE); System.out.println("WARNING -- The above is only a rough guideline."); System.out.println("For best results, please be sure you know the"); System.out.println("precision of your system timer."); System.out.println(HLINE); /* --- MAIN LOOP --- repeat test cases NTIMES times --- */ for (int k=0; k epsilon) { System.out.println ("Failed Validation on array a[]"); System.out.println (" Expected : " +aj); System.out.println (" Observed : " +asum); } else if (java.lang.Math.abs(bj-bsum)/bsum > epsilon) { System.out.println ("Failed Validation on array b[]"); System.out.println (" Expected : " + bj); System.out.println (" Observed : " + bsum); } else if (java.lang.Math.abs(cj-csum)/csum > epsilon) { System.out.println ("Failed Validation on array c[]"); System.out.println (" Expected : " + cj); System.out.println (" Observed : " + csum); } else { System.out.println ("Solution Validates"); } } }