/************************************************************************************* 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; const char * FlightRecorder::StepName; int32_t FlightRecorder::StepLoggingCounter; 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; StepName = "No steps started"; StepLoggingCounter=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: GRID_ASSERT(0); } } bool FlightRecorder::StepLog(const char *name) { StepName = name; StepLoggingCounter ++; return true; } void FlightRecorder::SetLoggingModePrint(void) { std::cout << " FlightRecorder: set to print output " < " < " < "<< global < ViewLogger::LogVector; void ViewLogger::Begin() { Enabled = true; LogVector.resize(0); } void ViewLogger::End() { Enabled = false; } #ifdef GRID_LOG_VIEWS_FENCEPOST void ViewLogger::LogOpen(const char* filename, int line, int index, int mode, void* data, uint64_t bytes) { ViewLogger::LogClose(filename,line,index,mode,data,bytes); } void ViewLogger::LogClose(const char* filename, int line, int index, int mode, void* data, uint64_t bytes) { if (!Enabled) return; size_t i = LogVector.size(); LogVector.resize(i + 1); auto & n = LogVector[i]; n.filename = filename; n.line = line; n.index = index; if (bytes < sizeof(uint64_t)) { n.head = n.tail = 0; } else { switch (mode) { case AcceleratorRead: case AcceleratorWrite: case AcceleratorWriteDiscard: acceleratorCopyFromDevice((char*)data, &n.head, sizeof(uint64_t)); acceleratorCopyFromDevice((char*)data + bytes - sizeof(uint64_t), &n.tail, sizeof(uint64_t)); break; case CpuRead: case CpuWrite: //case CpuWriteDiscard: n.head = *(uint64_t*)data; n.tail = *(uint64_t*)((char*)data + bytes - sizeof(uint64_t)); break; } } } #else void ViewLogger::LogOpen(const char* filename, int line, int index, int mode, void* data, uint64_t bytes){ } void ViewLogger::LogClose(const char* filename, int line, int index, int mode, void* data, uint64_t bytes) { if (!Enabled) return; if (bytes < sizeof(uint64_t)) return; #ifdef GRID_SYCL uint64_t *u_data = (uint64_t *)data; switch (mode) { case AcceleratorWrite: case AcceleratorWriteDiscard: uint64_t csum = checksum_gpu(u_data,bytes/sizeof(uint64_t)); FlightRecorder::CsumLog(csum); break; } #endif } #endif #endif NAMESPACE_END(Grid);