diff --git a/Grid/util/FlightRecorder.cc b/Grid/util/FlightRecorder.cc new file mode 100644 index 00000000..4b8e0346 --- /dev/null +++ b/Grid/util/FlightRecorder.cc @@ -0,0 +1,339 @@ +/************************************************************************************* + + Grid physics library, www.github.com/paboyle/Grid + + Source file: ./lib/Init.cc + + Copyright (C) 2015 + +Author: Azusa Yamaguchi +Author: Peter Boyle +Author: Peter Boyle +Author: paboyle + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + See the full license in the file "LICENSE" in the top level distribution directory +*************************************************************************************/ +/* END LEGAL */ +#include + +NAMESPACE_BEGIN(Grid); +/////////////////////////////////////////////////////// +// Grid Norm logging for repro testing +/////////////////////////////////////////////////////// +int FlightRecorder::PrintEntireLog; +int FlightRecorder::ContinueOnFail; +int FlightRecorder::LoggingMode; +int FlightRecorder::ChecksumComms; +int FlightRecorder::ChecksumCommsSend; +int32_t FlightRecorder::XmitLoggingCounter; +int32_t FlightRecorder::RecvLoggingCounter; +int32_t FlightRecorder::CsumLoggingCounter; +int32_t FlightRecorder::NormLoggingCounter; +int32_t FlightRecorder::ReductionLoggingCounter; +uint64_t FlightRecorder::ErrorCounter; +std::vector FlightRecorder::NormLogVector; +std::vector FlightRecorder::ReductionLogVector; +std::vector FlightRecorder::CsumLogVector; +std::vector FlightRecorder::XmitLogVector; +std::vector FlightRecorder::RecvLogVector; + +void FlightRecorder::ResetCounters(void) +{ + XmitLoggingCounter=0; + RecvLoggingCounter=0; + CsumLoggingCounter=0; + NormLoggingCounter=0; + ReductionLoggingCounter=0; +} +void FlightRecorder::Truncate(void) +{ + ResetCounters(); + XmitLogVector.resize(0); + RecvLogVector.resize(0); + NormLogVector.resize(0); + CsumLogVector.resize(0); + ReductionLogVector.resize(0); +} +void FlightRecorder::SetLoggingMode(FlightRecorder::LoggingMode_t mode) +{ + switch ( mode ) { + case LoggingModePrint: + SetLoggingModePrint(); + break; + case LoggingModeRecord: + SetLoggingModeRecord(); + break; + case LoggingModeVerify: + SetLoggingModeVerify(); + break; + case LoggingModeNone: + LoggingMode = mode; + Truncate(); + break; + default: + assert(0); + } +} + +void FlightRecorder::SetLoggingModePrint(void) +{ + std::cout << " FlightRecorder: set to print output " < " < " < "<< global < dev(1); + acceleratorCopyToDevice(&word,&dev[0],sizeof(uint64_t)); + acceleratorCopySynchronise(); + MPI_Barrier(MPI_COMM_WORLD); + } +} +void FlightRecorder::recvLog(void *buf,uint64_t bytes,int rank) +{ + if ( ChecksumComms ){ + uint64_t *ubuf = (uint64_t *)buf; + if(LoggingMode == LoggingModeNone) return; +#ifdef GRID_SYCL + uint64_t _xor = svm_xor(ubuf,bytes/sizeof(uint64_t)); + if(LoggingMode == LoggingModePrint) { + std::cerr<<"FlightRecorder::recvLog : "<< RecvLoggingCounter <<" "<< std::hex << _xor <