9 #ifndef FAIR_MQ_OFI_SOCKET_H 10 #define FAIR_MQ_OFI_SOCKET_H 12 #include <FairMQSocket.h> 13 #include <FairMQMessage.h> 14 #include <fairmq/ofi/Context.h> 15 #include <fairmq/ofi/Control.pb.h> 17 #include <boost/asio.hpp> 19 #include <netinet/in.h> 20 #include <rdma/fabric.h> 38 Socket(
Context& factory,
const std::string& type,
const std::string& name,
const std::string&
id =
"");
42 auto GetId() -> std::string {
return fId; }
44 auto Bind(
const std::string& address) ->
bool override;
45 auto Connect(
const std::string& address) ->
void override;
47 auto Send(MessagePtr& msg,
int timeout = 0) ->
int override;
48 auto Receive(MessagePtr& msg,
int timeout = 0) ->
int override;
49 auto Send(std::vector<MessagePtr>& msgVec,
int timeout = 0) -> int64_t
override;
50 auto Receive(std::vector<MessagePtr>& msgVec,
int timeout = 0) -> int64_t
override;
52 auto TrySend(MessagePtr& msg) ->
int override;
53 auto TryReceive(MessagePtr& msg) ->
int override;
54 auto TrySend(std::vector<MessagePtr>& msgVec) -> int64_t
override;
55 auto TryReceive(std::vector<MessagePtr>& msgVec) -> int64_t
override;
57 auto GetSocket()
const ->
void*
override {
return fControlSocket; }
58 auto GetSocket(
int nothing)
const ->
int override {
return -1; }
60 auto Close() ->
void override;
62 auto SetOption(
const std::string& option,
const void* value,
size_t valueSize) ->
void override;
63 auto GetOption(
const std::string& option,
void* value,
size_t* valueSize) ->
void override;
65 auto GetBytesTx()
const ->
unsigned long override {
return fBytesTx; }
66 auto GetBytesRx()
const ->
unsigned long override {
return fBytesRx; }
67 auto GetMessagesTx()
const ->
unsigned long override {
return fMessagesTx; }
68 auto GetMessagesRx()
const ->
unsigned long override {
return fMessagesRx; }
70 auto SetSendTimeout(
const int timeout,
const std::string& address,
const std::string& method) ->
bool override;
71 auto GetSendTimeout()
const ->
int override;
72 auto SetReceiveTimeout(
const int timeout,
const std::string& address,
const std::string& method) ->
bool override;
73 auto GetReceiveTimeout()
const ->
int override;
75 static auto GetConstant(
const std::string& constant) -> int;
82 fid_ep* fDataEndpoint;
83 fid_cq* fDataCompletionQueueTx;
84 fid_cq* fDataCompletionQueueRx;
86 std::atomic<unsigned long> fBytesTx;
87 std::atomic<unsigned long> fBytesRx;
88 std::atomic<unsigned long> fMessagesTx;
89 std::atomic<unsigned long> fMessagesRx;
91 fi_addr_t fRemoteDataAddr;
92 sockaddr_in fLocalDataAddr;
93 bool fWaitingForControlPeer;
94 boost::asio::io_service::strand fIoStrand;
99 auto SendImpl(MessagePtr& msg,
const int flags,
const int timeout) -> int;
100 auto ReceiveImpl(MessagePtr& msg,
const int flags,
const int timeout) -> int;
101 auto SendImpl(std::vector<MessagePtr>& msgVec,
const int flags,
const int timeout) -> int64_t;
102 auto ReceiveImpl(std::vector<MessagePtr>& msgVec,
const int flags,
const int timeout) -> int64_t;
104 auto InitDataEndpoint() -> void;
105 auto WaitForControlPeer() -> void;
106 auto AnnounceDataAddress() -> void;
107 auto SendControlMessage(std::unique_ptr<ControlMessage> ctrl) -> void;
108 auto ReceiveControlMessage() -> std::unique_ptr<ControlMessage>;
109 auto ProcessDataAddressAnnouncement(std::unique_ptr<ControlMessage> ctrl) -> void;
115 void free_string(
void* ,
void* hint);
Transport-wide context.
Definition: Context.h:38
Definition: FairMQSocket.h:68
Definition: FairMQSocket.h:18
Definition: DeviceRunner.h:23