00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef SST_SYNC_H
00014 #define SST_SYNC_H
00015
00016 #include <sst/core/sst.h>
00017 #include <sst/core/component.h>
00018 #include <sst/core/syncEvent.h>
00019 #include <boost/mpi.hpp>
00020 #include <sst/core/compEvent.h>
00021
00022 namespace SST {
00023
00024 #define _SYNC_DBG( fmt, args...) __DBG( DBG_SYNC, Sync, fmt, ## args )
00025
00026 class Sync {
00027 private:
00028
00029 struct linkInfo {
00030 Link* link;
00031 int rank;
00032 };
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 struct rankInfo {
00043 CompEventQueue_t* sendQ;
00044 CompEventQueue_t* recvQ;
00045 boost::mpi::request mpiRecvReq;
00046 boost::mpi::request mpiSendReq;
00047 };
00048
00049 public:
00050 Sync( TimeConverter* period );
00051
00052
00053
00054
00055
00056 int registerLink( std::string linkName, Link* link,
00057 int farRank, Cycle_t lat );
00058
00059 int exchangeFunctors();
00060
00061 private:
00062 Sync( const Sync& c );
00063 Sync() {}
00064
00065 bool handler( Event* event );
00066
00067 private:
00068
00069 EventHandler< Sync, bool, Event* >* m_functor;
00070
00071 TimeConverter* m_period;
00072 SyncEvent* m_event;
00073
00074
00075 std::map< std::string, linkInfo > m_linkMap;
00076
00077
00078 std::map< int, rankInfo > m_rankMap;
00079
00080 friend class boost::serialization::access;
00081 template<class Archive>
00082 void serialize(Archive & ar, const unsigned int )
00083 {
00084 ar & BOOST_SERIALIZATION_NVP( m_functor );
00085 ar & BOOST_SERIALIZATION_NVP( m_period );
00086 ar & BOOST_SERIALIZATION_NVP( m_event );
00087
00088
00089
00090 }
00091
00092 template<class Archive>
00093 void save_construct_data
00094 (Archive & ar, const Sync * t, const unsigned int )
00095 {
00096 TimeConverter* period = t->m_period;
00097 ar << BOOST_SERIALIZATION_NVP( period );
00098 }
00099
00100 template<class Archive>
00101 void load_construct_data
00102 (Archive & ar, Sync * t, const unsigned int )
00103 {
00104 TimeConverter* period;
00105 ar >> BOOST_SERIALIZATION_NVP( period );
00106 ::new(t)Sync(period);
00107 }
00108 };
00109
00110
00111 }
00112
00113 #endif // SST_SYNC_H