Thrill
0.1
|
A Connection represents a link to another peer in a network group.
The link need not be an actual stateful TCP connection, but may be reliable and stateless.
The Connection class is abstract, and subclasses must exist for every network implementation.
Definition at line 49 of file connection.hpp.
#include <connection.hpp>
Public Types | |
enum | Flags : size_t { NoFlags = 0, MsgMore = 1 } |
Additional flags for sending or receiving. More... | |
Public Member Functions | |
Base Status Functions | |
virtual bool | IsValid () const =0 |
check whether the connection is (still) valid. More... | |
virtual std::string | ToString () const =0 |
return a string representation of this connection, for user output. More... | |
virtual std::ostream & | OutputOstream (std::ostream &os) const =0 |
virtual method to output to a std::ostream More... | |
Send Functions | |
virtual void | SyncSend (const void *data, size_t size, Flags flags=NoFlags)=0 |
virtual ssize_t | SendOne (const void *data, size_t size, Flags flags=NoFlags)=0 |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | Send (const T &value) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | Send (const T &value) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | Send (const T &value) |
Receive Functions | |
virtual void | SyncRecv (void *out_data, size_t size)=0 |
virtual ssize_t | RecvOne (void *out_data, size_t size)=0 |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | Receive (T *out_value) |
Receive any serializable POD item T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | Receive (T *out_value) |
Receive any serializable non-POD fixed-length item T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | Receive (T *out_value) |
Receive any serializable non-POD fixed-length item T. More... | |
Paired SendReceive Methods | |
virtual void | SyncSendRecv (const void *send_data, size_t send_size, void *recv_data, size_t recv_size)=0 |
virtual void | SyncRecvSend (const void *send_data, size_t send_size, void *recv_data, size_t recv_size)=0 |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | SendReceive (const T *value, T *out_value, size_t n=1) |
SendReceive any serializable POD item T. More... | |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | ReceiveSend (const T &value, T *out_value) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | SendReceive (const T *value, T *out_value, size_t n=1) |
SendReceive any serializable non-POD fixed-length item T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | ReceiveSend (const T &value, T *out_value) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | SendReceive (const T *value, T *out_value, size_t n=1) |
SendReceive any serializable non-POD fixed-length item T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | ReceiveSend (const T &value, T *out_value) |
SendN Functions | |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | SendN (const T *value, size_t n) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | SendN (const T *value, size_t n) |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | SendN (const T *value, size_t n) |
ReceiveN Functions | |
template<typename T > | |
std::enable_if< std::is_pod< T >::value, void >::type | ReceiveN (T *out_value, size_t n) |
Receive an array of serializable POD items T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | ReceiveN (T *out_value, size_t n) |
Receive an array of serializable non-POD fixed-length items T. More... | |
template<typename T > | |
std::enable_if< !std::is_pod< T >::value &&!data::Serialization< BufferBuilder, T >::is_fixed_size, void >::type | ReceiveN (T *out_value, size_t n) |
Receive an array of serializable non-POD fixed-length items T. More... | |
Public Attributes | |
bool | is_loopback_ = false |
Sequence Numbers | |
std::atomic< uint32_t > | tx_seq_ { 0 } |
send sequence More... | |
std::atomic< uint32_t > | rx_seq_ { 0 } |
receive sequence More... | |
Static Public Attributes | |
static constexpr bool | self_verify_ = common::g_self_verify |
Friends | |
Flags | operator| (const Flags &a, const Flags &b) |
operator to combine flags More... | |
Statistics | |
std::atomic< size_t > | tx_bytes_ { 0 } |
sent bytes More... | |
std::atomic< size_t > | rx_bytes_ = { 0 } |
received bytes More... | |
size_t | prev_tx_bytes_ = 0 |
previous read of sent bytes More... | |
size_t | prev_rx_bytes_ = 0 |
previous read of received bytes More... | |
std::atomic< size_t > | tx_active_ { 0 } |
active send requests More... | |
std::atomic< size_t > | rx_active_ = { 0 } |
active recv requests More... | |
std::ostream & | operator<< (std::ostream &os, const Connection &c) |
} More... | |
enum Flags : size_t |
Additional flags for sending or receiving.
Enumerator | |
---|---|
NoFlags | |
MsgMore | indicate that more data is coming, hence, sending a packet may be delayed. currently only applies to TCP. |
Definition at line 61 of file connection.hpp.
|
pure virtual |
check whether the connection is (still) valid.
Implemented in Connection, Connection, and Connection.
Referenced by Dispatcher::AsyncRead(), and Dispatcher::AsyncWrite().
|
pure virtual |
virtual method to output to a std::ostream
Implemented in Connection, Connection, and Connection.
Receive any serializable POD item T.
Definition at line 184 of file connection.hpp.
References Connection::SyncRecv(), and gen_data::value.
Referenced by Group::ReceiveFrom().
|
inline |
Receive any serializable non-POD fixed-length item T.
Definition at line 204 of file connection.hpp.
References Buffer::data(), Buffer::size(), Connection::SyncRecv(), and gen_data::value.
|
inline |
Receive any serializable non-POD fixed-length item T.
Definition at line 239 of file connection.hpp.
References Buffer::data(), Connection::SyncRecv(), Connection::SyncRecvSend(), Connection::SyncSendRecv(), and gen_data::value.
Receive an array of serializable POD items T.
Definition at line 524 of file connection.hpp.
References Connection::SyncRecv(), and gen_data::value.
Referenced by Group::AllGatherBruck().
|
inline |
Receive an array of serializable non-POD fixed-length items T.
Definition at line 544 of file connection.hpp.
References Buffer::data(), Buffer::size(), Connection::SyncRecv(), and gen_data::value.
|
inline |
Receive an array of serializable non-POD fixed-length items T.
Definition at line 569 of file connection.hpp.
References Buffer::data(), and Connection::SyncRecv().
|
inline |
Definition at line 296 of file connection.hpp.
References Connection::SyncRecvSend(), and gen_data::value.
Referenced by Group::AllReduceHypercube(), and Group::SendReceiveReduce().
|
inline |
Definition at line 348 of file connection.hpp.
References Buffer::data(), BufferBuilder::data(), Buffer::size(), BufferBuilder::size(), Connection::SyncRecvSend(), and gen_data::value.
|
inline |
Definition at line 427 of file connection.hpp.
References Buffer::data(), BufferBuilder::data(), BufferBuilder::size(), Connection::SyncRecvSend(), and gen_data::value.
|
pure virtual |
Non-blocking receive of at most size data. returns number of bytes actually received. check errno for errors.
Implemented in Connection, Connection, and Connection.
Referenced by AsyncReadBuffer::operator()(), AsyncReadByteBlock::operator()(), and Connection::Send().
Send any serializable POD item T. if sending fails, a net::Exception is thrown.
Definition at line 105 of file connection.hpp.
References Connection::SyncSend(), and gen_data::value.
Referenced by Group::SendTo().
|
inline |
Send any serializable non-POD fixed-length item T. if sending fails, a net::Exception is thrown.
Definition at line 121 of file connection.hpp.
References BufferBuilder::data(), BufferBuilder::size(), Connection::SyncSend(), and gen_data::value.
|
inline |
Send any serializable non-POD variable-length item T. if sending fails, a net::Exception is thrown.
Definition at line 152 of file connection.hpp.
References BufferBuilder::data(), Connection::MsgMore, Connection::RecvOne(), BufferBuilder::size(), Connection::SyncRecv(), Connection::SyncSend(), and gen_data::value.
Send an array of serializable POD items T. if sending fails, a net::Exception is thrown.
Definition at line 462 of file connection.hpp.
References Connection::SyncSend(), and gen_data::value.
Referenced by Group::AllGatherBruck().
|
inline |
Send an array of serializable non-POD fixed-length items T. if sending fails, a net::Exception is thrown.
Definition at line 478 of file connection.hpp.
References BufferBuilder::data(), BufferBuilder::size(), Connection::SyncSend(), and gen_data::value.
|
inline |
Send an array of serializable non-POD variable-length items T. if sending fails, a net::Exception is thrown.
Definition at line 500 of file connection.hpp.
References BufferBuilder::data(), Connection::MsgMore, BufferBuilder::size(), Connection::SyncSend(), and gen_data::value.
Non-blocking send of a (data,size) message. returns number of bytes possible to send. check errno for errors.
Implemented in Connection, Connection, and Connection.
Referenced by AsyncWriteBuffer::operator()(), and AsyncWriteBlock::operator()().
|
inline |
SendReceive any serializable POD item T.
Definition at line 277 of file connection.hpp.
References Connection::SyncSendRecv(), and gen_data::value.
Referenced by Group::AllGatherRecursiveDoublingPowerOfTwo(), Group::AllReduceHypercube(), and Group::SendReceiveReduce().
|
inline |
SendReceive any serializable non-POD fixed-length item T.
Definition at line 317 of file connection.hpp.
References Buffer::data(), BufferBuilder::data(), Buffer::size(), BufferBuilder::size(), Connection::SyncSendRecv(), and gen_data::value.
|
inline |
SendReceive any serializable non-POD fixed-length item T.
Definition at line 393 of file connection.hpp.
References Buffer::data(), BufferBuilder::data(), BufferBuilder::size(), Connection::SyncSendRecv(), and gen_data::value.
|
pure virtual |
Synchronous blocking receive a message of given size. The size must match the SyncSend size for some network layers may only support matching messages (read: RDMA!, but also true for the mock net). Throws a net::Exception on errors.
Implemented in Connection, Connection, and Connection.
Referenced by Connection::Receive(), Connection::ReceiveN(), and Connection::Send().
|
pure virtual |
Implemented in Connection, Connection, and Connection.
Referenced by Connection::Receive(), and Connection::ReceiveSend().
Synchronous blocking send of the (data,size) packet. if sending fails, a net::Exception is thrown.
Implemented in Connection, Connection, and Connection.
Referenced by Connection::Send(), and Connection::SendN().
|
pure virtual |
Synchronous blocking sending and receive a message of given size. The size must match the SyncSendRecv size for some network layers may only support matching messages (read: RDMA!, but also true for the mock net). Throws a net::Exception on errors.
Implemented in Connection, Connection, and Connection.
Referenced by Connection::Receive(), and Connection::SendReceive().
|
pure virtual |
return a string representation of this connection, for user output.
Implemented in Connection, Connection, and Connection.
Referenced by Dispatcher::ExceptionCallback(), and AsyncReadBuffer::operator()().
|
friend |
operator to combine flags
Definition at line 69 of file connection.hpp.
bool is_loopback_ = false |
typeid().hash_code() is only guaranteed to be equal for the same program run, hence, we can only use it on loopback networks.
Definition at line 58 of file connection.hpp.
Referenced by Connection::Initialize().
size_t prev_rx_bytes_ = 0 |
previous read of received bytes
Definition at line 618 of file connection.hpp.
Referenced by Manager::RunTask().
size_t prev_tx_bytes_ = 0 |
previous read of sent bytes
Definition at line 615 of file connection.hpp.
Referenced by Manager::RunTask().
std::atomic<size_t> rx_active_ = { 0 } |
active recv requests
Definition at line 624 of file connection.hpp.
Referenced by AsyncReadBuffer::AsyncReadBuffer(), AsyncReadByteBlock::AsyncReadByteBlock(), AsyncReadBuffer::operator()(), AsyncReadByteBlock::operator()(), and Manager::RunTask().
std::atomic<size_t> rx_bytes_ = { 0 } |
received bytes
Definition at line 612 of file connection.hpp.
Referenced by Dispatcher::IRecv(), Connection::RecvNext(), Connection::RecvOne(), Manager::RunTask(), Connection::SyncRecv(), and Manager::Traffic().
std::atomic<uint32_t> rx_seq_ { 0 } |
receive sequence
Definition at line 601 of file connection.hpp.
Referenced by Multiplexer::AsyncReadMultiplexerHeader().
|
static |
flag which enables transmission of verification bytes for debugging, this increases network volume.
Definition at line 54 of file connection.hpp.
std::atomic<size_t> tx_active_ { 0 } |
active send requests
Definition at line 621 of file connection.hpp.
Referenced by AsyncWriteBlock::AsyncWriteBlock(), AsyncWriteBuffer::AsyncWriteBuffer(), AsyncWriteBuffer::operator()(), AsyncWriteBlock::operator()(), and Manager::RunTask().
std::atomic<size_t> tx_bytes_ { 0 } |
sent bytes
Definition at line 609 of file connection.hpp.
Referenced by Dispatcher::ISend(), Manager::RunTask(), Connection::SendOne(), Connection::SyncSend(), and Manager::Traffic().
std::atomic<uint32_t> tx_seq_ { 0 } |
send sequence
Definition at line 598 of file connection.hpp.
Referenced by StreamSink::AppendPinnedBlock().