mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
FairMQ: Setup ofi objects
FI_MSG API FI_EP_RDM, reliable datagram message (unconnected)
This commit is contained in:
committed by
Mohammad Al-Turany
parent
4250e3d45b
commit
630a1dbbce
@@ -12,10 +12,7 @@
|
||||
#include <fairmq/ofi/TransportFactory.h>
|
||||
#include <fairmq/Tools.h>
|
||||
|
||||
#include <rdma/fabric.h> // OFI libfabric
|
||||
#include <rdma/fi_errno.h>
|
||||
#include <stdexcept>
|
||||
#include <zmq.h>
|
||||
|
||||
namespace fair
|
||||
{
|
||||
@@ -27,41 +24,12 @@ namespace ofi
|
||||
using namespace std;
|
||||
|
||||
TransportFactory::TransportFactory(const string& id, const FairMQProgOptions* config)
|
||||
: FairMQTransportFactory{id}
|
||||
, fZmqContext{zmq_ctx_new()}
|
||||
try : FairMQTransportFactory{id}
|
||||
{
|
||||
if (!fZmqContext)
|
||||
{
|
||||
throw TransportFactoryError{tools::ToString("Failed creating zmq context, reason: ", zmq_strerror(errno))};
|
||||
}
|
||||
|
||||
auto ofi_hints = fi_allocinfo();
|
||||
ofi_hints->caps = FI_MSG | FI_RMA;
|
||||
ofi_hints->mode = FI_ASYNC_IOV;
|
||||
ofi_hints->addr_format = FI_SOCKADDR_IN;
|
||||
auto ofi_info = fi_allocinfo();
|
||||
if (ofi_hints == nullptr || ofi_info == nullptr)
|
||||
{
|
||||
throw TransportFactoryError{"Failed allocating fi_info structs"};
|
||||
}
|
||||
auto res = fi_getinfo(FI_VERSION(1, 5), nullptr, nullptr, 0, ofi_hints, &ofi_info);
|
||||
if (res != 0)
|
||||
{
|
||||
throw TransportFactoryError{tools::ToString("Failed querying fi_getinfo, reason: ", fi_strerror(res))};
|
||||
}
|
||||
for(auto cursor{ofi_info}; cursor->next != nullptr; cursor = cursor->next)
|
||||
{
|
||||
// LOG(debug) << fi_tostr(cursor, FI_TYPE_INFO);
|
||||
}
|
||||
fi_freeinfo(ofi_hints);
|
||||
fi_freeinfo(ofi_info);
|
||||
|
||||
int major, minor, patch;
|
||||
zmq_version(&major, &minor, &patch);
|
||||
auto ofi_version{fi_version()};
|
||||
LOG(debug) << "Transport: Using ZeroMQ (" << major << "." << minor << "." << patch << ") & "
|
||||
<< "OFI libfabric (API " << FI_MAJOR(ofi_version) << "." << FI_MINOR(ofi_version) << ")";
|
||||
LOG(debug) << "Transport: Using ZeroMQ (" << fContext.GetZmqVersion() << ") & "
|
||||
<< "OFI libfabric (API " << fContext.GetOfiApiVersion() << ")";
|
||||
}
|
||||
catch (ContextError& e) { throw TransportFactoryError{e.what()}; }
|
||||
|
||||
auto TransportFactory::CreateMessage() const -> MessagePtr
|
||||
{
|
||||
@@ -85,8 +53,7 @@ auto TransportFactory::CreateMessage(UnmanagedRegionPtr& region, void* data, con
|
||||
|
||||
auto TransportFactory::CreateSocket(const string& type, const string& name) const -> SocketPtr
|
||||
{
|
||||
assert(fZmqContext);
|
||||
return SocketPtr{new Socket(*this, type, name, GetId())};
|
||||
return SocketPtr{new Socket(fContext, type, name, GetId())};
|
||||
}
|
||||
|
||||
auto TransportFactory::CreatePoller(const vector<FairMQChannel>& channels) const -> PollerPtr
|
||||
@@ -119,13 +86,6 @@ auto TransportFactory::GetType() const -> Transport
|
||||
return Transport::OFI;
|
||||
}
|
||||
|
||||
TransportFactory::~TransportFactory() noexcept(false)
|
||||
{
|
||||
if (zmq_ctx_term(fZmqContext) != 0) {
|
||||
throw TransportFactoryError{tools::ToString("Failed closing zmq context, reason: ", zmq_strerror(errno))};
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace ofi */
|
||||
} /* namespace mq */
|
||||
} /* namespace fair */
|
||||
|
Reference in New Issue
Block a user