tinydaxpy.cpp | tinydaxpy.cpp | |||
---|---|---|---|---|
// TinyVector<T,N> DAXPY benchmark | // TinyVector<T,N> DAXPY benchmark | |||
#define BZ_DISABLE_KCC_COPY_PROPAGATION_KLUDGE | //#define BZ_DISABLE_KCC_COPY_PROPAGATION_KLUDGE | |||
#include <blitz/tinyvec-et.h> | #include <blitz/array.h> | |||
#include <blitz/timer.h> | #include <blitz/timer.h> | |||
#include <blitz/rand-uniform.h> | #include <random/uniform.h> | |||
BZ_USING_NAMESPACE(blitz) | BZ_USING_NAMESPACE(blitz) | |||
Random<Uniform> rnd(1.0, 2.0); | ranlib::Uniform<double> rnd; | |||
template<class T> | template<class T> | |||
void optimizationSink(T&); | void optimizationSink(T&); | |||
template<int N_rank> | template<int N_rank> | |||
void tinyDAXPYBenchmark(TinyVector<double,N_rank>, int iters, double a) | void tinyDAXPYBenchmark(TinyVector<double,N_rank>, int iters, double a) | |||
{ | { | |||
Timer timer; | Timer timer; | |||
TinyVector<double,N_rank> ta, tb, tc, td, te, tf, tg, th, ti, tj; | TinyVector<double,N_rank> ta, tb, tc, td, te, tf, tg, th, ti, tj; | |||
for (int i=0; i < N_rank; ++i) | for (int i=0; i < N_rank; ++i) | |||
{ | { | |||
ta[i] = rnd.random(); | ta[i] = rnd.random()+1; | |||
tb[i] = rnd.random(); | tb[i] = rnd.random()+1; | |||
tc[i] = rnd.random(); | tc[i] = rnd.random()+1; | |||
td[i] = rnd.random(); | td[i] = rnd.random()+1; | |||
te[i] = rnd.random(); | te[i] = rnd.random()+1; | |||
tf[i] = rnd.random(); | tf[i] = rnd.random()+1; | |||
tg[i] = rnd.random(); | tg[i] = rnd.random()+1; | |||
th[i] = rnd.random(); | th[i] = rnd.random()+1; | |||
ti[i] = rnd.random(); | ti[i] = rnd.random()+1; | |||
tj[i] = rnd.random(); | tj[i] = rnd.random()+1; | |||
} | } | |||
double b = -a; | double b = -a; | |||
double numFlops = 0; | double numFlops = 0; | |||
if (N_rank < 20) | if (N_rank < 20) | |||
{ | { | |||
timer.start(); | timer.start(); | |||
for (int i=0; i < iters; ++i) | for (int i=0; i < iters; ++i) | |||
skipping to change at line 92 | skipping to change at line 92 | |||
optimizationSink(tc); | optimizationSink(tc); | |||
optimizationSink(td); | optimizationSink(td); | |||
optimizationSink(te); | optimizationSink(te); | |||
optimizationSink(tf); | optimizationSink(tf); | |||
optimizationSink(tg); | optimizationSink(tg); | |||
optimizationSink(th); | optimizationSink(th); | |||
optimizationSink(ti); | optimizationSink(ti); | |||
optimizationSink(tj); | optimizationSink(tj); | |||
timer.stop(); | timer.stop(); | |||
float Mflops = numFlops / (1.0e+6) / timer.elapsedSeconds(); | float Gflops = numFlops / (1e9*timer.elapsed()); | |||
if (iters > 1) | if (iters > 1) | |||
{ | { | |||
cout << setw(5) << N_rank << '\t' << Mflops << endl; | cout << setw(5) << N_rank << '\t' << Gflops << endl; | |||
} | } | |||
} | } | |||
double a = 0.3429843; | double a = 0.3429843; | |||
template<class T> | template<class T> | |||
void optimizationSink(T&) | void optimizationSink(T&) | |||
{ | { | |||
} | } | |||
int main() | int main() | |||
{ | { | |||
cout << "TinyVector<double,N> DAXPY benchmark" << endl | cout << "TinyVector<double,N> DAXPY benchmark" << endl | |||
<< setw(5) << "N" << '\t' << "Mflops/s" << endl; | << setw(5) << "N" << '\t' << "Gflops/" << Timer::indep_var() << en dl; | |||
tinyDAXPYBenchmark(TinyVector<double,1>(), 800000, a); | tinyDAXPYBenchmark(TinyVector<double,1>(), 800000, a); | |||
tinyDAXPYBenchmark(TinyVector<double,2>(), 800000, a); | tinyDAXPYBenchmark(TinyVector<double,2>(), 800000, a); | |||
tinyDAXPYBenchmark(TinyVector<double,3>(), 800000, a); | tinyDAXPYBenchmark(TinyVector<double,3>(), 800000, a); | |||
tinyDAXPYBenchmark(TinyVector<double,4>(), 700000, a); | tinyDAXPYBenchmark(TinyVector<double,4>(), 700000, a); | |||
tinyDAXPYBenchmark(TinyVector<double,5>(), 600000, a); | tinyDAXPYBenchmark(TinyVector<double,5>(), 600000, a); | |||
tinyDAXPYBenchmark(TinyVector<double,6>(), 500000, a); | tinyDAXPYBenchmark(TinyVector<double,6>(), 500000, a); | |||
tinyDAXPYBenchmark(TinyVector<double,7>(), 500000, a); | tinyDAXPYBenchmark(TinyVector<double,7>(), 500000, a); | |||
tinyDAXPYBenchmark(TinyVector<double,8>(), 500000, a); | tinyDAXPYBenchmark(TinyVector<double,8>(), 500000, a); | |||
tinyDAXPYBenchmark(TinyVector<double,9>(), 500000, a); | tinyDAXPYBenchmark(TinyVector<double,9>(), 500000, a); | |||
tinyDAXPYBenchmark(TinyVector<double,10>(), 500000, a); | tinyDAXPYBenchmark(TinyVector<double,10>(), 500000, a); | |||
End of changes. 8 change blocks. | ||||
17 lines changed or deleted | 17 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/ |