diff --git a/lib/Bitwise.cc b/lib/Bitwise.cc index a33b1792..ba630653 100644 --- a/lib/Bitwise.cc +++ b/lib/Bitwise.cc @@ -26,9 +26,6 @@ See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ -#ifndef GRID_BITWISE_H -#define GRID_BITWISE_H - #include #include #include @@ -39,10 +36,14 @@ namespace Grid { void show_binaryrep(const unsigned char* a, size_t size) { const unsigned char* beg = a; const unsigned char* end = a + size; - while (beg != end) std::cout << std::bitset(*beg++) << ' '; + unsigned int ctr = 0; + while (beg != end) { + std::cout << std::bitset(*beg++) << ' '; + ctr++; + if (ctr % GRID_REAL_BYTES == 0) std::cout << '\n'; + } std::cout << '\n'; } } // namespace -#endif diff --git a/lib/Bitwise.h b/lib/Bitwise.h index 6661d528..9dca2171 100644 --- a/lib/Bitwise.h +++ b/lib/Bitwise.h @@ -29,8 +29,18 @@ directory #ifndef GRID_BITWISE_H #define GRID_BITWISE_H +#include #include #include +#include + +#ifdef GRID_DEFAULT_PRECISION_SINGLE +#define GRID_REAL_BYTES 4 +#endif +#ifdef GRID_DEFAULT_PRECISION_DOUBLE +#define GRID_REAL_BYTES 8 +#endif + namespace Grid { @@ -40,7 +50,12 @@ template void show_binaryrep(const T& a) { const char* beg = reinterpret_cast(&a); const char* end = beg + sizeof(a); - while (beg != end) std::cout << std::bitset(*beg++) << ' '; + unsigned int ctr = 0; + while (beg != end) { + std::cout << std::bitset(*beg++) << ' '; + ctr++; + if (ctr % GRID_REAL_BYTES == 0) std::cout << '\n'; + } std::cout << '\n'; } @@ -56,4 +71,5 @@ void bitwise_xor(T& l, T& r, unsigned char* xors) { }; // namespace + #endif diff --git a/lib/algorithms/iterative/ConjugateGradient.h b/lib/algorithms/iterative/ConjugateGradient.h index 3fe0a893..f590a3c6 100644 --- a/lib/algorithms/iterative/ConjugateGradient.h +++ b/lib/algorithms/iterative/ConjugateGradient.h @@ -9,6 +9,7 @@ Copyright (C) 2015 Author: Azusa Yamaguchi Author: Peter Boyle Author: paboyle +Author: Guido Cossu This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -158,7 +159,7 @@ class ConjugateGradient : public OperatorFunction { axpy(r, -a, mmp, r);// new residual r = r_old - a * Ap - cp = norm2(r, ReprTest);// + cp = norm2(r, ReprTest); // if (ReproTest && !CGState.do_repro) { CGState.residuals.push_back(cp); // save residuals state std::cout << GridLogIterative << "ReproTest: Saving state" << std::endl; @@ -171,7 +172,7 @@ class ConjugateGradient : public OperatorFunction { std::cout << GridLogMessage << " at k=" << k << std::endl; std::cout << GridLogMessage << "saved residual = " << CGState.residuals[k-1] << " cp = " << cp << std::endl; - exit(-1); + //exit(-1); do not stop, report all the failures } } b = cp / c; diff --git a/lib/lattice/Lattice_reduction.h b/lib/lattice/Lattice_reduction.h index befa470f..5afa985a 100644 --- a/lib/lattice/Lattice_reduction.h +++ b/lib/lattice/Lattice_reduction.h @@ -118,22 +118,21 @@ class ReproducibilityState { int words = sizeof(sumarray[thread])/sizeof(unsigned char); unsigned char xors[words]; bitwise_xor(sumarray[thread], repr.th_states[repr.n_call][thread],xors); - // XOR all words + // OR all words unsigned char res = 0; - for (int w = 0; w < words; w++) res = res ^ xors[w]; + for (int w = 0; w < words; w++) res = res | xors[w]; if ( res ) { std::cout << GridLogMessage << "Reproducibility failure report" << std::endl; grid->PrintRankInfo(); - std::cout << GridLogMessage << "Call: "<< repr.n_call << " Thread: " << thread << std::endl; - std::cout << GridLogMessage << "Size of states: " << repr.th_states.size() << std::endl; - std::cout << GridLogMessage << "Current partial sum: " << sumarray[thread] << std::endl; - std::cout << GridLogMessage << "Saved partial sum : " << repr.th_states[repr.n_call][thread] << std::endl; - std::cout << GridLogMessage << "Saved state " << std::endl; - show_binaryrep(repr.th_states[repr.n_call][thread]); - std::cout << GridLogMessage << "Current state" << std::endl; - show_binaryrep(sumarray[thread]); - std::cout << GridLogMessage << "Xor result" << std::endl; - show_binaryrep(xors, words); + std::cout << "Call: "<< repr.n_call << " Thread: " << thread << std::endl; + std::cout << "Size of states: " << repr.th_states.size() << std::endl; + std::cout << std::setprecision(15) << std::scientific; + std::cout << "Saved partial sum : " << repr.th_states[repr.n_call][thread] << std::endl; + std::cout << "Current partial sum: " << sumarray[thread] << std::endl; + std::cout << "Saved state " << std::endl; show_binaryrep(repr.th_states[repr.n_call][thread]); + std::cout << "Current state" << std::endl; show_binaryrep(sumarray[thread]); + std::cout << "XOR result" << std::endl; show_binaryrep(xors, words); + std::cout << std::defaultfloat; repr.success = false; } }