diff --git a/src/core/timing/Timer.h b/src/core/timing/Timer.h index d3c72dfe05fc095791f0ee4b8b1a65c4126c9a60..0352ebf59f4fe8ff625ddc39afc022456a0809de 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 43d1533b576f4294c407e70ff10a49b759c80b4c..5e8fd71049bb268317d7f84fc4ec47fb6e9ed750 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 + //====================================================================================================================== //