loop6.cpp   loop6.cpp 
// Generated code (makeloops.cpp) -- do not edit.
// In KAI C++ 3.2, restrict causes problems for copy propagation. // loop6 generated by makeloops.py Thu Jun 30 16:44:56 2011
// Temporary fix: disable restrict
#define BZ_DISABLE_RESTRICT #include <blitz/vector2.h>
#include <blitz/vector.h>
#include <blitz/array.h> #include <blitz/array.h>
#include <blitz/rand-uniform.h> #include <random/uniform.h>
#include <blitz/benchext.h> #include <blitz/benchext.h>
// Generated: makeloops.cpp Dec 11 2002
#ifdef BZ_HAVE_VALARRAY #ifdef BZ_HAVE_VALARRAY
#define BENCHMARK_VALARRAY #define BENCHMARK_VALARRAY
#endif #endif
#ifdef BENCHMARK_VALARRAY #ifdef BENCHMARK_VALARRAY
#include <valarray> #include <valarray>
#endif #endif
BZ_NAMESPACE(blitz)
extern void sink();
BZ_NAMESPACE_END
BZ_USING_NAMESPACE(blitz) BZ_USING_NAMESPACE(blitz)
BZ_USING_NAMESPACE(std)
#if defined(BZ_FORTRAN_SYMBOLS_WITH_TRAILING_UNDERSCORES) #if defined(BZ_FORTRAN_SYMBOLS_WITH_TRAILING_UNDERSCORES)
#define loop6_f77 loop6_f77_ #define loop6_f77 loop6_f77_
#define loop6_f77overhead loop6_f77overhead_ #define loop6_f77overhead loop6_f77overhead_
#define loop6_f90 loop6_f90_ #define loop6_f90 loop6_f90_
#define loop6_f90overhead loop6_f90overhead_ #define loop6_f90overhead loop6_f90overhead_
#elif defined(BZ_FORTRAN_SYMBOLS_WITH_DOUBLE_TRAILING_UNDERSCORES) #elif defined(BZ_FORTRAN_SYMBOLS_WITH_DOUBLE_TRAILING_UNDERSCORES)
#define loop6_f77 loop6_f77__ #define loop6_f77 loop6_f77__
#define loop6_f77overhead loop6_f77overhead__ #define loop6_f77overhead loop6_f77overhead__
#define loop6_f90 loop6_f90__ #define loop6_f90 loop6_f90__
#define loop6_f90overhead loop6_f90overhead__ #define loop6_f90overhead loop6_f90overhead__
#elif defined(BZ_FORTRAN_SYMBOLS_CAPS) #elif defined(BZ_FORTRAN_SYMBOLS_CAPS)
#define loop6_f77 LOOP6_F77 #define loop6_f77 LOOP6_F77
#define loop6_f77overhead LOOP6_F77OVERHEAD #define loop6_f77overhead LOOP6_F77OVERHEAD
#define loop6_f90 LOOP6_F90 #define loop6_f90 LOOP6_F90
#define loop6_f90overhead LOOP6_F90OVERHEAD #define loop6_f90overhead LOOP6_F90OVERHEAD
#endif #endif
extern "C" { extern "C" {
void loop6_f77(const int& N, double* x, double* a, double* b); void loop6_f77(const int& N, double* x, double* a, double* b);
void loop6_f77overhead(const int& N, double* x, double* a, double* b); void loop6_f77overhead(const int& N, double* x, double* a, double* b);
void loop6_f90(const int& N, double* x, double* a, double* b); void loop6_f90(const int& N, double* x, double* a, double* b);
void loop6_f90overhead(const int& N, double* x, double* a, double* b); void loop6_f90overhead(const int& N, double* x, double* a, double* b);
} }
void VectorVersion(BenchmarkExt<int>& bench); void VectorVersion(BenchmarkExt<int>& bench);
void ArrayVersion(BenchmarkExt<int>& bench); void ArrayVersion(BenchmarkExt<int>& bench);
void ArrayVersion_unaligned(BenchmarkExt<int>& bench);
void ArrayVersion_misaligned(BenchmarkExt<int>& bench);
void ArrayVersion_index(BenchmarkExt<int>& bench);
void doTinyVectorVersion(BenchmarkExt<int>& bench);
void F77Version(BenchmarkExt<int>& bench); void F77Version(BenchmarkExt<int>& bench);
#ifdef FORTRAN_90 #ifdef FORTRAN_90
void F90Version(BenchmarkExt<int>& bench); void F90Version(BenchmarkExt<int>& bench);
#endif #endif
#ifdef BENCHMARK_VALARRAY #ifdef BENCHMARK_VALARRAY
void ValarrayVersion(BenchmarkExt<int>& bench); void ValarrayVersion(BenchmarkExt<int>& bench);
#endif #endif
void sink() {} const int numSizes = 80;
const bool runvector=false; // no point as long as Vector is Array<1>
int main() int main()
{ {
int numBenchmarks = 5; int numBenchmarks = 5;
#ifndef BENCHMARK_VALARRAY if (runvector) numBenchmarks++;
numBenchmarks--; // No valarray #ifdef BENCHMARK_VALARRAY
numBenchmarks++;
#endif #endif
#ifndef FORTRAN_90 #ifdef FORTRAN_90
numBenchmarks--; // No fortran 90 numBenchmarks++;
#endif #endif
BenchmarkExt<int> bench("loop6: $x=$a*$b", numBenchmarks); BenchmarkExt<int> bench("loop6: $x = $a*$b", numBenchmarks);
const int numSizes = 23;
bench.setNumParameters(numSizes); bench.setNumParameters(numSizes);
bench.setRateDescription("Mflops/s");
Vector<int> parameters(numSizes);
Vector<long> iters(numSizes);
Vector<double> flops(numSizes);
for (int i=0; i < numSizes; ++i) Array<int,1> parameters(numSizes);
{ Array<long,1> iters(numSizes);
parameters[i] = (int)pow(10.0, (i+1)/4.0); Array<double,1> flops(numSizes);
iters[i] = 10000000L / parameters[i];
if (iters[i] < 2) parameters=pow(pow(2.,0.25),tensor::i)+tensor::i;
iters[i] = 2; flops = 1 * parameters;
flops[i] = 1 * parameters[i]; iters = 100000000L / flops;
} iters = where(iters<2, 2, iters);
cout << iters << endl;
bench.setParameterVector(parameters); bench.setParameterVector(parameters);
bench.setIterations(iters); bench.setIterations(iters);
bench.setFlopsPerIteration(flops); bench.setOpsPerIteration(flops);
bench.setDependentVariable("flops");
bench.beginBenchmarking(); bench.beginBenchmarking();
VectorVersion(bench);
ArrayVersion(bench); ArrayVersion(bench);
ArrayVersion_unaligned(bench);
ArrayVersion_misaligned(bench);
ArrayVersion_index(bench);
//doTinyVectorVersion(bench);
F77Version(bench); F77Version(bench);
#ifdef FORTRAN_90 #ifdef FORTRAN_90
F90Version(bench); F90Version(bench);
#endif #endif
#ifdef BENCHMARK_VALARRAY #ifdef BENCHMARK_VALARRAY
ValarrayVersion(bench); ValarrayVersion(bench);
#endif #endif
if(runvector)
VectorVersion(bench);
bench.endBenchmarking(); bench.endBenchmarking();
bench.saveMatlabGraph("loop6.m"); bench.saveMatlabGraph("loop6.m");
return 0; return 0;
} }
template<class T> template<class T>
void initializeRandomDouble(T data, int numElements, int stride = 1) void initializeRandomDouble(T* data, int numElements, int stride = 1)
{ {
static Random<Uniform> rnd; ranlib::Uniform<T> rnd;
for (int i=0; i < numElements; ++i) for (int i=0; i < numElements; ++i)
data[size_t(i*stride)] = rnd.random(); data[size_t(i*stride)] = rnd.random();
} }
template<class T> template<class T>
void initializeArray(T& array, int numElements) void initializeRandomDouble(valarray<T>& data, int numElements, int stride = 1)
{ {
static Random<Uniform> rnd; ranlib::Uniform<T> rnd;
for (size_t i=0; i < numElements; ++i) for (int i=0; i < numElements; ++i)
array[i] = rnd.random(); data[size_t(i*stride)] = rnd.random();
} }
void VectorVersion(BenchmarkExt<int>& bench) void VectorVersion(BenchmarkExt<int>& bench)
{ {
bench.beginImplementation("Vector<T>"); bench.beginImplementation("Vector<T>");
while (!bench.doneImplementationBenchmark()) while (!bench.doneImplementationBenchmark())
{ {
int N = bench.getParameter(); int N = bench.getParameter();
cout << "Vector<T>: N = " << N << endl;
cout.flush();
long iters = bench.getIterations(); long iters = bench.getIterations();
cout << bench.currentImplementation() << ": N = " << N << endl;
Vector<double> x(N); Vector<double> x(N);
initializeRandomDouble(x.data(), N); initializeRandomDouble(x.data(), N);
Vector<double> a(N); Vector<double> a(N);
initializeRandomDouble(a.data(), N); initializeRandomDouble(a.data(), N);
Vector<double> b(N); Vector<double> b(N);
initializeRandomDouble(b.data(), N); initializeRandomDouble(b.data(), N);
bench.start(); bench.start();
for (long i=0; i < iters; ++i) for (long i=0; i < iters; ++i)
{ {
x=a*b; x = a*b;
sink(); sink();
} }
bench.stop(); bench.stop();
bench.startOverhead(); bench.startOverhead();
for (long i=0; i < iters; ++i) for (long i=0; i < iters; ++i) {
sink(); sink();
}
bench.stopOverhead(); bench.stopOverhead();
} }
bench.endImplementation(); bench.endImplementation();
} }
void ArrayVersion(BenchmarkExt<int>& bench) void ArrayVersion(BenchmarkExt<int>& bench)
{ {
bench.beginImplementation("Array<T,1>"); bench.beginImplementation("Array<T,1>");
while (!bench.doneImplementationBenchmark()) while (!bench.doneImplementationBenchmark())
{ {
int N = bench.getParameter(); int N = bench.getParameter();
cout << "Array<T,1>: N = " << N << endl; long iters = bench.getIterations();
cout.flush();
cout << bench.currentImplementation() << ": N = " << N << endl;
Array<double,1> x(N);
initializeRandomDouble(x.dataFirst(), N);
Array<double,1> a(N);
initializeRandomDouble(a.dataFirst(), N);
Array<double,1> b(N);
initializeRandomDouble(b.dataFirst(), N);
bench.start();
for (long i=0; i < iters; ++i)
{
x = a*b;
sink();
}
bench.stop();
bench.startOverhead();
for (long i=0; i < iters; ++i) {
sink();
}
bench.stopOverhead();
}
bench.endImplementation();
}
void ArrayVersion_index(BenchmarkExt<int>& bench)
{
bench.beginImplementation("Array<T,1> (indexexpr.)");
while (!bench.doneImplementationBenchmark())
{
int N = bench.getParameter();
long iters = bench.getIterations(); long iters = bench.getIterations();
Array<double, 1> x(N); cout << bench.currentImplementation() << ": N = " << N << endl;
Array<double,1> x(N);
initializeRandomDouble(x.dataFirst(), N); initializeRandomDouble(x.dataFirst(), N);
Array<double, 1> a(N); Array<double,1> a(N);
initializeRandomDouble(a.dataFirst(), N); initializeRandomDouble(a.dataFirst(), N);
Array<double, 1> b(N); Array<double,1> b(N);
initializeRandomDouble(b.dataFirst(), N); initializeRandomDouble(b.dataFirst(), N);
bench.start(); bench.start();
for (long i=0; i < iters; ++i) for (long i=0; i < iters; ++i)
{ {
x=a*b; x = a(tensor::i)*b(tensor::i);;
sink();
}
bench.stop();
bench.startOverhead();
for (long i=0; i < iters; ++i) {
sink();
}
bench.stopOverhead();
}
bench.endImplementation();
}
void ArrayVersion_unaligned(BenchmarkExt<int>& bench)
{
bench.beginImplementation("Array<T,1> (unal.)");
while (!bench.doneImplementationBenchmark())
{
int N = bench.getParameter();
long iters = bench.getIterations();
cout << bench.currentImplementation() << ": N = " << N << endl;
Array<double,1> xfill(N+1);
Array<double,1> x(xfill(Range(1,N)));
initializeRandomDouble(x.dataFirst(), N);
Array<double,1> afill(N+1);
Array<double,1> a(afill(Range(1,N)));
initializeRandomDouble(a.dataFirst(), N);
Array<double,1> bfill(N+1);
Array<double,1> b(bfill(Range(1,N)));
initializeRandomDouble(b.dataFirst(), N);
bench.start();
for (long i=0; i < iters; ++i)
{
x = a*b;
sink(); sink();
} }
bench.stop(); bench.stop();
bench.startOverhead(); bench.startOverhead();
for (long i=0; i < iters; ++i) {
sink();
}
bench.stopOverhead();
}
bench.endImplementation();
}
void ArrayVersion_misaligned(BenchmarkExt<int>& bench)
{
bench.beginImplementation("Array<T,1> (misal.)");
while (!bench.doneImplementationBenchmark())
{
int N = bench.getParameter();
long iters = bench.getIterations();
cout << bench.currentImplementation() << ": N = " << N << endl;
Array<double,1> xfill(N+3);
Array<double,1> x(xfill(Range(0,N+0-1)));
initializeRandomDouble(x.dataFirst(), N);
Array<double,1> afill(N+3);
Array<double,1> a(afill(Range(1,N+1-1)));
initializeRandomDouble(a.dataFirst(), N);
Array<double,1> bfill(N+3);
Array<double,1> b(bfill(Range(2,N+2-1)));
initializeRandomDouble(b.dataFirst(), N);
bench.start();
for (long i=0; i < iters; ++i) for (long i=0; i < iters; ++i)
{
x = a*b;
sink();
}
bench.stop();
bench.startOverhead();
for (long i=0; i < iters; ++i) {
sink(); sink();
}
bench.stopOverhead(); bench.stopOverhead();
} }
bench.endImplementation(); bench.endImplementation();
} }
#ifdef BENCHMARK_VALARRAY #ifdef BENCHMARK_VALARRAY
void ValarrayVersion(BenchmarkExt<int>& bench) void ValarrayVersion(BenchmarkExt<int>& bench)
{ {
bench.beginImplementation("valarray<T>"); bench.beginImplementation("valarray<T>");
while (!bench.doneImplementationBenchmark()) while (!bench.doneImplementationBenchmark())
{ {
int N = bench.getParameter(); int N = bench.getParameter();
cout << "valarray<T>: N = " << N << endl; cout << bench.currentImplementation() << ": N = " << N << endl;
cout.flush();
long iters = bench.getIterations(); long iters = bench.getIterations();
valarray<double> x(N); valarray<double> x(N);
initializeArray(x, N); initializeRandomDouble(x, N);
valarray<double> a(N); valarray<double> a(N);
initializeArray(a, N); initializeRandomDouble(a, N);
valarray<double> b(N); valarray<double> b(N);
initializeArray(b, N); initializeRandomDouble(b, N);
bench.start(); bench.start();
for (long i=0; i < iters; ++i) for (long i=0; i < iters; ++i)
{ {
x=a*b; x = a*b;
sink(); sink();
} }
bench.stop(); bench.stop();
bench.startOverhead(); bench.startOverhead();
for (long i=0; i < iters; ++i) for (long i=0; i < iters; ++i) {
sink(); sink();
}
bench.stopOverhead(); bench.stopOverhead();
} }
bench.endImplementation(); bench.endImplementation();
} }
#endif #endif
void F77Version(BenchmarkExt<int>& bench) void F77Version(BenchmarkExt<int>& bench)
{ {
bench.beginImplementation("Fortran 77"); bench.beginImplementation("Fortran 77");
while (!bench.doneImplementationBenchmark()) while (!bench.doneImplementationBenchmark())
{ {
int N = bench.getParameter(); int N = bench.getParameter();
cout << bench.currentImplementation() << ": N = " << N << endl;
cout << "Fortran 77: N = " << N << endl;
cout.flush();
int iters = bench.getIterations(); int iters = bench.getIterations();
double* x = new double[N]; double* x = new double[N];
initializeRandomDouble(x, N); initializeRandomDouble(x, N);
double* a = new double[N]; double* a = new double[N];
initializeRandomDouble(a, N); initializeRandomDouble(a, N);
double* b = new double[N]; double* b = new double[N];
initializeRandomDouble(b, N); initializeRandomDouble(b, N);
bench.start(); bench.start();
for (int iter=0; iter < iters; ++iter) for (int iter=0; iter < iters; ++iter)
loop6_f77(N, x, a, b); loop6_f77(N, x, a, b);
bench.stop(); bench.stop();
bench.startOverhead(); bench.startOverhead();
for (int iter=0; iter < iters; ++iter) for (int iter=0; iter < iters; ++iter)
loop6_f77overhead(N, x, a, b); loop6_f77overhead(N, x, a, b);
bench.stopOverhead(); bench.stopOverhead();
delete [] x; delete [] x;
delete [] a; delete [] a;
delete [] b; delete [] b;
} }
bench.endImplementation(); bench.endImplementation();
} }
#ifdef FORTRAN_90 #ifdef FORTRAN_90
void F90Version(BenchmarkExt<int>& bench) void F90Version(BenchmarkExt<int>& bench)
{ {
bench.beginImplementation("Fortran 90"); bench.beginImplementation("Fortran 90");
while (!bench.doneImplementationBenchmark()) while (!bench.doneImplementationBenchmark())
{ {
int N = bench.getParameter(); int N = bench.getParameter();
cout << bench.currentImplementation() << ": N = " << N << endl;
cout << "Fortran 90: N = " << N << endl;
cout.flush();
int iters = bench.getIterations(); int iters = bench.getIterations();
double* x = new double[N]; double* x = new double[N];
initializeRandomDouble(x, N); initializeRandomDouble(x, N);
double* a = new double[N]; double* a = new double[N];
initializeRandomDouble(a, N); initializeRandomDouble(a, N);
double* b = new double[N]; double* b = new double[N];
initializeRandomDouble(b, N); initializeRandomDouble(b, N);
skipping to change at line 317 skipping to change at line 440
bench.stop(); bench.stop();
bench.startOverhead(); bench.startOverhead();
for (int iter=0; iter < iters; ++iter) for (int iter=0; iter < iters; ++iter)
loop6_f90overhead(N, x, a, b); loop6_f90overhead(N, x, a, b);
bench.stopOverhead(); bench.stopOverhead();
delete [] x; delete [] x;
delete [] a; delete [] a;
delete [] b; delete [] b;
} }
bench.endImplementation(); bench.endImplementation();
} }
#endif #endif
 End of changes. 56 change blocks. 
69 lines changed or deleted 193 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/