From 6d720b5c9267c89a48b334d04f6c263f7d6cef35 Mon Sep 17 00:00:00 2001 From: Sebastian Eibl <sebastian.eibl@fau.de> Date: Mon, 3 Jun 2019 10:52:57 +0200 Subject: [PATCH] added pack and unpack functions for Timer and TimingPool --- src/core/timing/Timer.h | 53 ++++++++++++++++++++++++++++++++++-- src/core/timing/TimingPool.h | 42 ++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/src/core/timing/Timer.h b/src/core/timing/Timer.h index d3c72dfe..0352ebf5 100644 --- a/src/core/timing/Timer.h +++ b/src/core/timing/Timer.h @@ -28,6 +28,9 @@ #include "WcPolicy.h" #include "core/DataTypes.h" +#include "core/mpi/RecvBuffer.h" +#include "core/mpi/SendBuffer.h" + #include <iomanip> #include <iostream> #include <limits> @@ -90,7 +93,15 @@ namespace timing { template< typename TP > // Timing policy class Timer { - public: + template< typename T, // Element type of SendBuffer + typename G, // Growth policy of SendBuffer + typename TP2 > // Element type of vector + friend mpi::GenericSendBuffer<T,G>& operator<<( mpi::GenericSendBuffer<T,G> & buf, const Timer<TP2> & t ); + + template< typename T, // Element type of RecvBuffer + typename TP2 > // Element type of vector + friend mpi::GenericRecvBuffer<T>& operator>>( mpi::GenericRecvBuffer<T> & buf, Timer<TP2> & t ); +public: //**Type definitions************************************************************************************************* typedef TP TimingPolicy; //!< Timing policy of the Timer. //******************************************************************************************************************* @@ -461,8 +472,46 @@ std::ostream & operator<< ( std::ostream & os, const Timer<TP> & timer ) return os; } +//====================================================================================================================== +// +// Send/Recv Buffer Serialization Specialization +// +//====================================================================================================================== + + template< typename T, // Element type of SendBuffer + typename G, // Growth policy of SendBuffer + typename TP > // Element type of vector + mpi::GenericSendBuffer<T,G>& operator<<( mpi::GenericSendBuffer<T,G> & buf, const Timer<TP> & t ) + { + buf.addDebugMarker( "ti" ); + buf << t.counter_; + buf << t.start_; + buf << t.end_; + buf << t.time_; + buf << t.sumOfSquares_; + buf << t.min_; + buf << t.max_; + buf << t.last_; + return buf; + } + + template< typename T, // Element type of RecvBuffer + typename TP > // Element type of vector + mpi::GenericRecvBuffer<T>& operator>>( mpi::GenericRecvBuffer<T> & buf, Timer<TP> & t ) + { + buf.readDebugMarker( "ti" ); + buf >> t.counter_; + buf >> t.start_; + buf >> t.end_; + buf >> t.time_; + buf >> t.sumOfSquares_; + buf >> t.min_; + buf >> t.max_; + buf >> t.last_; + return buf; + } -} // namespace timing +} //namespace timing typedef timing::Timer<timing::CpuPolicy> CpuTimer; typedef timing::Timer<timing::WcPolicy> WcTimer; diff --git a/src/core/timing/TimingPool.h b/src/core/timing/TimingPool.h index 43d1533b..5e8fd710 100644 --- a/src/core/timing/TimingPool.h +++ b/src/core/timing/TimingPool.h @@ -24,6 +24,9 @@ #include "Timer.h" #include "ReduceType.h" +#include "core/mpi/RecvBuffer.h" +#include "core/mpi/SendBuffer.h" + #include <iostream> #include <map> #include <stdexcept> @@ -47,6 +50,14 @@ class ScopeTimer; template< typename TP > // Timing policy class TimingPool { + template< typename T, // Element type of SendBuffer + typename G, // Growth policy of SendBuffer + typename TP2 > // Element type of vector + friend mpi::GenericSendBuffer<T,G>& operator<<( mpi::GenericSendBuffer<T,G> & buf, const TimingPool<TP2> & tp ); + + template< typename T, // Element type of RecvBuffer + typename TP2 > // Element type of vector + friend mpi::GenericRecvBuffer<T>& operator>>( mpi::GenericRecvBuffer<T> & buf, TimingPool<TP2> & tp ); public: //**Construction & Destruction*************************************************************************************** @@ -198,6 +209,37 @@ std::ostream & operator<< ( std::ostream & os, const TimingPool<TP> & tp ) { } // namespace timing } // namespace walberla +//====================================================================================================================== +// +// Send/Recv Buffer Serialization Specialization +// +//====================================================================================================================== + +namespace walberla { +namespace timing { + + template< typename T, // Element type of SendBuffer + typename G, // Growth policy of SendBuffer + typename TP > // Element type of vector + mpi::GenericSendBuffer<T,G>& operator<<( mpi::GenericSendBuffer<T,G> & buf, const timing::TimingPool<TP> & tp ) + { + buf.addDebugMarker( "tp" ); + buf << tp.timerMap_; + return buf; + } + + template< typename T, // Element type of RecvBuffer + typename TP > // Element type of vector + mpi::GenericRecvBuffer<T>& operator>>( mpi::GenericRecvBuffer<T> & buf, timing::TimingPool<TP> & tp ) + { + buf.readDebugMarker( "tp" ); + buf >> tp.timerMap_; + return buf; + } + +} //namespace timing +} //namespace walberla + //====================================================================================================================== // -- GitLab