mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-16 14:57:05 +01:00
Cleaning up output of CG repro
This commit is contained in:
@ -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 <iostream>
|
||||
#include <Bitwise.h>
|
||||
#include <bitset>
|
||||
@ -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<CHAR_BIT>(*beg++) << ' ';
|
||||
unsigned int ctr = 0;
|
||||
while (beg != end) {
|
||||
std::cout << std::bitset<CHAR_BIT>(*beg++) << ' ';
|
||||
ctr++;
|
||||
if (ctr % GRID_REAL_BYTES == 0) std::cout << '\n';
|
||||
}
|
||||
std::cout << '\n';
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
@ -29,8 +29,18 @@ directory
|
||||
#ifndef GRID_BITWISE_H
|
||||
#define GRID_BITWISE_H
|
||||
|
||||
#include <cassert>
|
||||
#include <bitset>
|
||||
#include <climits>
|
||||
#include <Config.h>
|
||||
|
||||
#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 <typename T>
|
||||
void show_binaryrep(const T& a) {
|
||||
const char* beg = reinterpret_cast<const char*>(&a);
|
||||
const char* end = beg + sizeof(a);
|
||||
while (beg != end) std::cout << std::bitset<CHAR_BIT>(*beg++) << ' ';
|
||||
unsigned int ctr = 0;
|
||||
while (beg != end) {
|
||||
std::cout << std::bitset<CHAR_BIT>(*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
|
||||
|
@ -9,6 +9,7 @@ Copyright (C) 2015
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
||||
|
||||
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
|
||||
@ -171,7 +172,7 @@ class ConjugateGradient : public OperatorFunction<Field> {
|
||||
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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user