Drop protobuf dependencies

This commit is contained in:
Dennis Klein 2018-08-03 01:45:05 +02:00 committed by Dennis Klein
parent fc778ab3b8
commit 03912e86f8
6 changed files with 77 additions and 89 deletions

View File

@ -227,7 +227,7 @@ if(BUILD_NANOMSG_TRANSPORT)
set(NANOMSG_DEPS nanomsg msgpackc-cxx) set(NANOMSG_DEPS nanomsg msgpackc-cxx)
endif() endif()
if(BUILD_OFI_TRANSPORT) if(BUILD_OFI_TRANSPORT)
set(OFI_DEPS asiofi::asiofi msgpackc) set(OFI_DEPS asiofi::asiofi msgpack::msgpack)
endif() endif()
set(optional_deps ${NANOMSG_DEPS} ${OFI_DEPS}) set(optional_deps ${NANOMSG_DEPS} ${OFI_DEPS})
if(optional_deps) if(optional_deps)

View File

@ -13,7 +13,6 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <boost/version.hpp> #include <boost/version.hpp>
#include <cstring> #include <cstring>
#include <google/protobuf/stubs/common.h>
#include <memory> #include <memory>
#include <netinet/in.h> #include <netinet/in.h>
#include <rdma/fabric.h> #include <rdma/fabric.h>
@ -47,8 +46,6 @@ Context::Context(int numberIoThreads)
if (!fZmqContext) if (!fZmqContext)
throw ContextError{tools::ToString("Failed creating zmq context, reason: ", zmq_strerror(errno))}; throw ContextError{tools::ToString("Failed creating zmq context, reason: ", zmq_strerror(errno))};
GOOGLE_PROTOBUF_VERIFY_VERSION;
InitThreadPool(numberIoThreads); InitThreadPool(numberIoThreads);
} }
@ -114,11 +111,6 @@ auto Context::GetOfiApiVersion() const -> string
return "unknown"; return "unknown";
} }
auto Context::GetPbVersion() const -> string
{
return google::protobuf::internal::VersionString(GOOGLE_PROTOBUF_VERSION);
}
auto Context::GetBoostVersion() const -> std::string auto Context::GetBoostVersion() const -> std::string
{ {
return tools::ToString(BOOST_VERSION / 100000, ".", BOOST_VERSION / 100 % 1000, ".", BOOST_VERSION % 100); return tools::ToString(BOOST_VERSION / 100000, ".", BOOST_VERSION / 100 % 1000, ".", BOOST_VERSION % 100);

View File

@ -45,7 +45,6 @@ class Context
auto CreateOfiCompletionQueue(Direction dir) -> fid_cq*; auto CreateOfiCompletionQueue(Direction dir) -> fid_cq*;
auto GetZmqVersion() const -> std::string; auto GetZmqVersion() const -> std::string;
auto GetOfiApiVersion() const -> std::string; auto GetOfiApiVersion() const -> std::string;
auto GetPbVersion() const -> std::string;
auto GetBoostVersion() const -> std::string; auto GetBoostVersion() const -> std::string;
auto GetZmqContext() const -> void* { return fZmqContext; } auto GetZmqContext() const -> void* { return fZmqContext; }
auto GetIoContext() -> boost::asio::io_service& { return fIoContext; } auto GetIoContext() -> boost::asio::io_service& { return fIoContext; }

View File

@ -136,19 +136,19 @@ auto Socket::ConnectControlSocket(Context::Address address) -> void
throw SocketError(tools::ToString("Failed connecting control socket ", fId, ", reason: ", zmq_strerror(errno))); throw SocketError(tools::ToString("Failed connecting control socket ", fId, ", reason: ", zmq_strerror(errno)));
} }
auto Socket::ProcessDataAddressAnnouncement(std::unique_ptr<ControlMessage> ctrl) -> void // auto Socket::ProcessDataAddressAnnouncement(std::unique_ptr<ControlMessage> ctrl) -> void
{ // {
assert(ctrl->has_data_address_announcement()); // assert(ctrl->has_data_address_announcement());
auto daa = ctrl->data_address_announcement(); // auto daa = ctrl->data_address_announcement();
//
sockaddr_in remoteAddr; // sockaddr_in remoteAddr;
remoteAddr.sin_family = AF_INET; // remoteAddr.sin_family = AF_INET;
remoteAddr.sin_port = daa.port(); // remoteAddr.sin_port = daa.port();
remoteAddr.sin_addr.s_addr = daa.ipv4(); // remoteAddr.sin_addr.s_addr = daa.ipv4();
//
LOG(debug) << "Data address announcement of remote ofi endpoint received: " << Context::ConvertAddress(remoteAddr); // LOG(debug) << "Data address announcement of remote ofi endpoint received: " << Context::ConvertAddress(remoteAddr);
fRemoteDataAddr = fContext.InsertAddressVector(remoteAddr); // fRemoteDataAddr = fContext.InsertAddressVector(remoteAddr);
} // }
auto Socket::InitDataEndpoint() -> void auto Socket::InitDataEndpoint() -> void
{ {
@ -184,8 +184,6 @@ void free_string(void* /*data*/, void* hint)
auto Socket::AnnounceDataAddress() -> void auto Socket::AnnounceDataAddress() -> void
try { try {
using namespace google::protobuf;
size_t addrlen = sizeof(sockaddr_in); size_t addrlen = sizeof(sockaddr_in);
auto ret = fi_getname(&fDataEndpoint->fid, &fLocalDataAddr, &addrlen); auto ret = fi_getname(&fDataEndpoint->fid, &fLocalDataAddr, &addrlen);
if (ret != FI_SUCCESS) if (ret != FI_SUCCESS)
@ -195,62 +193,62 @@ try {
LOG(debug) << "Address of local ofi endpoint in socket " << fId << ": " << Context::ConvertAddress(fLocalDataAddr); LOG(debug) << "Address of local ofi endpoint in socket " << fId << ": " << Context::ConvertAddress(fLocalDataAddr);
// Create new control message // Create new control message
auto ctrl = tools::make_unique<ControlMessage>(); // auto ctrl = tools::make_unique<ControlMessage>();
auto daa = tools::make_unique<DataAddressAnnouncement>(); // auto daa = tools::make_unique<DataAddressAnnouncement>();
// Fill data address announcement // Fill data address announcement
daa->set_ipv4(fLocalDataAddr.sin_addr.s_addr); // daa->set_ipv4(fLocalDataAddr.sin_addr.s_addr);
daa->set_port(fLocalDataAddr.sin_port); // daa->set_port(fLocalDataAddr.sin_port);
// Fill control message // Fill control message
ctrl->set_allocated_data_address_announcement(daa.release()); // ctrl->set_allocated_data_address_announcement(daa.release());
assert(ctrl->IsInitialized()); // assert(ctrl->IsInitialized());
SendControlMessage(move(ctrl)); // SendControlMessage(move(ctrl));
} catch (const SocketError& e) { } catch (const SocketError& e) {
throw SocketError(tools::ToString("Failed to announce data address, reason: ", e.what())); throw SocketError(tools::ToString("Failed to announce data address, reason: ", e.what()));
} }
auto Socket::SendControlMessage(unique_ptr<ControlMessage> ctrl) -> void // auto Socket::SendControlMessage(unique_ptr<ControlMessage> ctrl) -> void
{ // {
assert(fControlSocket); // assert(fControlSocket);
// LOG(debug) << "About to send control message: " << ctrl->DebugString(); // LOG(debug) << "About to send control message: " << ctrl->DebugString();
//
// Serialize // Serialize
string* str = new string(); // string* str = new string();
ctrl->SerializeToString(str); // ctrl->SerializeToString(str);
zmq_msg_t msg; // zmq_msg_t msg;
auto ret = zmq_msg_init_data(&msg, const_cast<char*>(str->c_str()), str->length(), free_string, str); // auto ret = zmq_msg_init_data(&msg, const_cast<char*>(str->c_str()), str->length(), free_string, str);
assert(ret == 0); // assert(ret == 0);
//
// Send // Send
if (zmq_msg_send(&msg, fControlSocket, 0) == -1) { // if (zmq_msg_send(&msg, fControlSocket, 0) == -1) {
zmq_msg_close(&msg); // zmq_msg_close(&msg);
throw SocketError(tools::ToString("Failed to send control message, reason: ", zmq_strerror(errno))); // throw SocketError(tools::ToString("Failed to send control message, reason: ", zmq_strerror(errno)));
} // }
} // }
//
auto Socket::ReceiveControlMessage() -> unique_ptr<ControlMessage> // auto Socket::ReceiveControlMessage() -> unique_ptr<ControlMessage>
{ // {
assert(fControlSocket); // assert(fControlSocket);
//
// Receive // Receive
zmq_msg_t msg; // zmq_msg_t msg;
auto ret = zmq_msg_init(&msg); // auto ret = zmq_msg_init(&msg);
assert(ret == 0); // assert(ret == 0);
if (zmq_msg_recv(&msg, fControlSocket, 0) == -1) { // if (zmq_msg_recv(&msg, fControlSocket, 0) == -1) {
zmq_msg_close(&msg); // zmq_msg_close(&msg);
throw SocketError(tools::ToString("Failed to receive control message, reason: ", zmq_strerror(errno))); // throw SocketError(tools::ToString("Failed to receive control message, reason: ", zmq_strerror(errno)));
} // }
//
// Deserialize // Deserialize
auto ctrl = tools::make_unique<ControlMessage>(); // auto ctrl = tools::make_unique<ControlMessage>();
ctrl->ParseFromArray(zmq_msg_data(&msg), zmq_msg_size(&msg)); // ctrl->ParseFromArray(zmq_msg_data(&msg), zmq_msg_size(&msg));
//
zmq_msg_close(&msg); // zmq_msg_close(&msg);
// LOG(debug) << "Received control message: " << ctrl->DebugString(); // LOG(debug) << "Received control message: " << ctrl->DebugString();
return ctrl; // return ctrl;
} // }
auto Socket::WaitForControlPeer() -> void auto Socket::WaitForControlPeer() -> void
{ {
@ -305,18 +303,18 @@ try {
if (fWaitingForControlPeer) { if (fWaitingForControlPeer) {
WaitForControlPeer(); WaitForControlPeer();
AnnounceDataAddress(); AnnounceDataAddress();
ProcessDataAddressAnnouncement(ReceiveControlMessage()); // ProcessDataAddressAnnouncement(ReceiveControlMessage());
} }
auto size = msg->GetSize(); auto size = msg->GetSize();
// Create and send control message // Create and send control message
auto ctrl = tools::make_unique<ControlMessage>(); // auto ctrl = tools::make_unique<ControlMessage>();
auto buf = tools::make_unique<PostBuffer>(); // auto buf = tools::make_unique<PostBuffer>();
buf->set_size(size); // buf->set_size(size);
ctrl->set_allocated_post_buffer(buf.release()); // ctrl->set_allocated_post_buffer(buf.release());
assert(ctrl->IsInitialized()); // assert(ctrl->IsInitialized());
SendControlMessage(move(ctrl)); // SendControlMessage(move(ctrl));
if (size) { if (size) {
// Receive and process control message // Receive and process control message
@ -359,19 +357,19 @@ try {
if (fWaitingForControlPeer) { if (fWaitingForControlPeer) {
WaitForControlPeer(); WaitForControlPeer();
AnnounceDataAddress(); AnnounceDataAddress();
ProcessDataAddressAnnouncement(ReceiveControlMessage()); // ProcessDataAddressAnnouncement(ReceiveControlMessage());
} }
// Receive and process control message // Receive and process control message
auto ctrl = ReceiveControlMessage(); // auto ctrl = ReceiveControlMessage();
assert(ctrl->has_post_buffer()); // assert(ctrl->has_post_buffer());
auto postBuffer = ctrl->post_buffer(); // auto postBuffer = ctrl->post_buffer();
auto size = postBuffer.size(); // auto size = postBuffer.size();
// Receive data // Receive data
if (size) { // if (size) {
fi_context ctx; fi_context ctx;
msg->Rebuild(size); // msg->Rebuild(size);
auto buf = msg->GetData(); auto buf = msg->GetData();
auto size2 = msg->GetSize(); auto size2 = msg->GetSize();
auto ret = fi_recv(fDataEndpoint, buf, size2, nullptr, fRemoteDataAddr, &ctx); auto ret = fi_recv(fDataEndpoint, buf, size2, nullptr, fRemoteDataAddr, &ctx);
@ -392,12 +390,13 @@ try {
throw SocketError(tools::ToString("Failed reading ofi rx completion queue event, reason: ", fi_strerror(ret))); throw SocketError(tools::ToString("Failed reading ofi rx completion queue event, reason: ", fi_strerror(ret)));
assert(cqEntry.len == size2); assert(cqEntry.len == size2);
assert(cqEntry.buf == buf); assert(cqEntry.buf == buf);
} // }
fBytesRx += size; // fBytesRx += size;
fMessagesRx++; fMessagesRx++;
return size; // return size;
return 0;
} }
catch (const SilentSocketError& e) catch (const SilentSocketError& e)
{ {

View File

@ -12,7 +12,6 @@
#include <FairMQSocket.h> #include <FairMQSocket.h>
#include <FairMQMessage.h> #include <FairMQMessage.h>
#include <fairmq/ofi/Context.h> #include <fairmq/ofi/Context.h>
#include <fairmq/ofi/Control.pb.h>
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <memory> // unique_ptr #include <memory> // unique_ptr
@ -110,9 +109,9 @@ class Socket final : public fair::mq::Socket
auto InitDataEndpoint() -> void; auto InitDataEndpoint() -> void;
auto WaitForControlPeer() -> void; auto WaitForControlPeer() -> void;
auto AnnounceDataAddress() -> void; auto AnnounceDataAddress() -> void;
auto SendControlMessage(std::unique_ptr<ControlMessage> ctrl) -> void; // auto SendControlMessage(std::unique_ptr<ControlMessage> ctrl) -> void;
auto ReceiveControlMessage() -> std::unique_ptr<ControlMessage>; // auto ReceiveControlMessage() -> std::unique_ptr<ControlMessage>;
auto ProcessDataAddressAnnouncement(std::unique_ptr<ControlMessage> ctrl) -> void; // auto ProcessDataAddressAnnouncement(std::unique_ptr<ControlMessage> ctrl) -> void;
auto ConnectControlSocket(Context::Address address) -> void; auto ConnectControlSocket(Context::Address address) -> void;
auto BindControlSocket(Context::Address address) -> void; auto BindControlSocket(Context::Address address) -> void;
}; /* class Socket */ }; /* class Socket */

View File

@ -28,7 +28,6 @@ try : FairMQTransportFactory{id}
{ {
LOG(debug) << "Transport: Using ZeroMQ (" << fContext.GetZmqVersion() << ") & " LOG(debug) << "Transport: Using ZeroMQ (" << fContext.GetZmqVersion() << ") & "
<< "OFI libfabric (API " << fContext.GetOfiApiVersion() << ") & " << "OFI libfabric (API " << fContext.GetOfiApiVersion() << ") & "
<< "Google Protobuf (" << fContext.GetPbVersion() << ") & "
<< "Boost.Asio (" << fContext.GetBoostVersion() << ")"; << "Boost.Asio (" << fContext.GetBoostVersion() << ")";
} }
catch (ContextError& e) catch (ContextError& e)