mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-17 07:17:06 +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
|
directory
|
||||||
*************************************************************************************/
|
*************************************************************************************/
|
||||||
/* END LEGAL */
|
/* END LEGAL */
|
||||||
#ifndef GRID_BITWISE_H
|
|
||||||
#define GRID_BITWISE_H
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <Bitwise.h>
|
#include <Bitwise.h>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
@ -39,10 +36,14 @@ namespace Grid {
|
|||||||
void show_binaryrep(const unsigned char* a, size_t size) {
|
void show_binaryrep(const unsigned char* a, size_t size) {
|
||||||
const unsigned char* beg = a;
|
const unsigned char* beg = a;
|
||||||
const unsigned char* end = a + size;
|
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';
|
std::cout << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -29,8 +29,18 @@ directory
|
|||||||
#ifndef GRID_BITWISE_H
|
#ifndef GRID_BITWISE_H
|
||||||
#define GRID_BITWISE_H
|
#define GRID_BITWISE_H
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <climits>
|
#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 {
|
namespace Grid {
|
||||||
|
|
||||||
@ -40,7 +50,12 @@ template <typename T>
|
|||||||
void show_binaryrep(const T& a) {
|
void show_binaryrep(const T& a) {
|
||||||
const char* beg = reinterpret_cast<const char*>(&a);
|
const char* beg = reinterpret_cast<const char*>(&a);
|
||||||
const char* end = beg + sizeof(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';
|
std::cout << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,4 +71,5 @@ void bitwise_xor(T& l, T& r, unsigned char* xors) {
|
|||||||
|
|
||||||
}; // namespace
|
}; // namespace
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,6 +9,7 @@ Copyright (C) 2015
|
|||||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||||
Author: paboyle <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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -158,7 +159,7 @@ class ConjugateGradient : public OperatorFunction<Field> {
|
|||||||
|
|
||||||
|
|
||||||
axpy(r, -a, mmp, r);// new residual r = r_old - a * Ap
|
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) {
|
if (ReproTest && !CGState.do_repro) {
|
||||||
CGState.residuals.push_back(cp); // save residuals state
|
CGState.residuals.push_back(cp); // save residuals state
|
||||||
std::cout << GridLogIterative << "ReproTest: Saving state" << std::endl;
|
std::cout << GridLogIterative << "ReproTest: Saving state" << std::endl;
|
||||||
@ -171,7 +172,7 @@ class ConjugateGradient : public OperatorFunction<Field> {
|
|||||||
std::cout << GridLogMessage << " at k=" << k << std::endl;
|
std::cout << GridLogMessage << " at k=" << k << std::endl;
|
||||||
std::cout << GridLogMessage << "saved residual = " << CGState.residuals[k-1]
|
std::cout << GridLogMessage << "saved residual = " << CGState.residuals[k-1]
|
||||||
<< " cp = " << cp << std::endl;
|
<< " cp = " << cp << std::endl;
|
||||||
exit(-1);
|
//exit(-1); do not stop, report all the failures
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b = cp / c;
|
b = cp / c;
|
||||||
|
@ -118,22 +118,21 @@ class ReproducibilityState {
|
|||||||
int words = sizeof(sumarray[thread])/sizeof(unsigned char);
|
int words = sizeof(sumarray[thread])/sizeof(unsigned char);
|
||||||
unsigned char xors[words];
|
unsigned char xors[words];
|
||||||
bitwise_xor(sumarray[thread], repr.th_states[repr.n_call][thread],xors);
|
bitwise_xor(sumarray[thread], repr.th_states[repr.n_call][thread],xors);
|
||||||
// XOR all words
|
// OR all words
|
||||||
unsigned char res = 0;
|
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 ) {
|
if ( res ) {
|
||||||
std::cout << GridLogMessage << "Reproducibility failure report" << std::endl;
|
std::cout << GridLogMessage << "Reproducibility failure report" << std::endl;
|
||||||
grid->PrintRankInfo();
|
grid->PrintRankInfo();
|
||||||
std::cout << GridLogMessage << "Call: "<< repr.n_call << " Thread: " << thread << std::endl;
|
std::cout << "Call: "<< repr.n_call << " Thread: " << thread << std::endl;
|
||||||
std::cout << GridLogMessage << "Size of states: " << repr.th_states.size() << std::endl;
|
std::cout << "Size of states: " << repr.th_states.size() << std::endl;
|
||||||
std::cout << GridLogMessage << "Current partial sum: " << sumarray[thread] << std::endl;
|
std::cout << std::setprecision(15) << std::scientific;
|
||||||
std::cout << GridLogMessage << "Saved partial sum : " << repr.th_states[repr.n_call][thread] << std::endl;
|
std::cout << "Saved partial sum : " << repr.th_states[repr.n_call][thread] << std::endl;
|
||||||
std::cout << GridLogMessage << "Saved state " << std::endl;
|
std::cout << "Current partial sum: " << sumarray[thread] << std::endl;
|
||||||
show_binaryrep(repr.th_states[repr.n_call][thread]);
|
std::cout << "Saved state " << std::endl; show_binaryrep(repr.th_states[repr.n_call][thread]);
|
||||||
std::cout << GridLogMessage << "Current state" << std::endl;
|
std::cout << "Current state" << std::endl; show_binaryrep(sumarray[thread]);
|
||||||
show_binaryrep(sumarray[thread]);
|
std::cout << "XOR result" << std::endl; show_binaryrep(xors, words);
|
||||||
std::cout << GridLogMessage << "Xor result" << std::endl;
|
std::cout << std::defaultfloat;
|
||||||
show_binaryrep(xors, words);
|
|
||||||
repr.success = false;
|
repr.success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user