Browse Source

Adds more iterations to have more accurate measure

master
Joshua Moerman 11 years ago
parent
commit
ffcfab9c6f
  1. 9
      wavelet/mockup.cpp

9
wavelet/mockup.cpp

@ -12,6 +12,7 @@
const unsigned int P = 2; const unsigned int P = 2;
const unsigned int N = 1 << NEXP; const unsigned int N = 1 << NEXP;
const unsigned int ITERS = 5;
// Static vectors for correctness checking // Static vectors for correctness checking
static std::vector<double> par_result(N); static std::vector<double> par_result(N);
@ -101,8 +102,10 @@ static void par_wavelet(){
double time1 = bsp::time(); double time1 = bsp::time();
for(int i = 0; i < ITERS; ++i){
par_wavelet_base(d, x.data(), next.data(), proczero.data()); par_wavelet_base(d, x.data(), next.data(), proczero.data());
bsp::sync(); bsp::sync();
}
double time2 = bsp::time(); double time2 = bsp::time();
if(d.s==0) printf("parallel version\t%f\n", time2 - time1); if(d.s==0) printf("parallel version\t%f\n", time2 - time1);
@ -130,7 +133,9 @@ static void seq_wavelet(){
for(unsigned int i = 0; i < N; ++i) v[i] = data(i); for(unsigned int i = 0; i < N; ++i) v[i] = data(i);
{ auto time1 = timer::clock::now(); { auto time1 = timer::clock::now();
for(int i = 0; i < ITERS; ++i){
wvlt::wavelet(v.data(), v.size()); wvlt::wavelet(v.data(), v.size());
}
auto time2 = timer::clock::now(); auto time2 = timer::clock::now();
printf("sequential version\t%f\n", timer::from_dur(time2 - time1)); printf("sequential version\t%f\n", timer::from_dur(time2 - time1));
} }
@ -160,7 +165,9 @@ static void check_equality(double threshold){
// Checks whether inverse gives us the data back // Checks whether inverse gives us the data back
// NOTE: modifies the global seq_result // NOTE: modifies the global seq_result
static void check_inverse(double threshold){ static void check_inverse(double threshold){
for(int i = 0; i < ITERS; ++i){
wvlt::unwavelet(seq_result.data(), seq_result.size()); wvlt::unwavelet(seq_result.data(), seq_result.size());
}
bool same = true; bool same = true;
for(unsigned int i = 0; i < N; ++i){ for(unsigned int i = 0; i < N; ++i){
if(data(i) != seq_result[i]) same = false; if(data(i) != seq_result[i]) same = false;
@ -172,7 +179,7 @@ static void check_inverse(double threshold){
std::cout << colors::green("SUCCES:") << " Inverse is bitwise correct" << std::endl; std::cout << colors::green("SUCCES:") << " Inverse is bitwise correct" << std::endl;
} else { } else {
if(rmse <= threshold){ if(rmse <= threshold){
std::cout << colors::green("SUCCES:") << " Inverse are almost correct: rmse = " << rmse << std::endl; std::cout << colors::green("SUCCES:") << " Inverse is almost correct: rmse = " << rmse << std::endl;
} else { } else {
std::cout << colors::red("FAIL:") << " Inverse seems wrong: rmse = " << rmse << std::endl; std::cout << colors::red("FAIL:") << " Inverse seems wrong: rmse = " << rmse << std::endl;
} }