10#include <rdma/fabric.h>
11#include <rdma/fi_domain.h>
12#include <rdma/fi_errno.h>
26 attr.type = FI_AV_TABLE;
30 attr.map_addr =
nullptr;
39 auto fiAttr = attr.
toRaw();
41 fiCall(::fi_av_open,
"Failed to open address vector", domain->raw(), &fiAttr, &
raw,
nullptr);
46 MakeSharedEnabler(fid_av*
raw, std::shared_ptr<Domain> domain)
51 return std::make_shared<MakeSharedEnabler>(
raw, domain);
56 ::fi_addr_t fiAddr{FI_ADDR_UNSPEC};
58 if (
auto ret = ::fi_av_insert(
_raw, addr.
raw(), 1, &fiAddr, 0,
nullptr); ret != 1)
60 throw Exception::internal(
"Failed to insert address into the address vector. {}", ::fi_strerror(ret));
69 fiCall(::fi_av_remove,
"Failed to remove address from address vector",
_raw, &addr, 1, 0);
77 ::fi_av_straddr(
_raw, addr.
raw(),
nullptr, &len);
80 auto ret = ::fi_av_straddr(
_raw, addr.
raw(), s.data(), &len);
101 ,
_domain(std::move(other._domain))
103 other._raw =
nullptr;
111 other._raw =
nullptr;
112 _domain = std::move(other._domain);
123 fiCall(::fi_close,
"Failed to close address vector", &
_raw->fid);
::fi_addr_t insert(RawFabricAddress const &addr)
Insert an address into the address vector. User of this API are responsible for keeping track of inse...
AddressVector(AddressVector const &)=delete
static std::shared_ptr< AddressVector > open(std::shared_ptr< Domain > domain, Attributes attr=Attributes::defaults())
Create an AddressVector.
std::shared_ptr< Domain > _domain
void remove(::fi_addr_t addr) noexcept
Remove an address of the address vector.
std::string addrToString(RawFabricAddress const &addr) const
Convert a libfabric endpoint address into a human-readable string.
void close()
Close the address vector and release all resources. Called from the destructor and the move assignmen...
::fid_av * raw() noexcept
Mutable accessor of the underlying fi_av instance.
void operator=(AddressVector const &)=delete
static Exception internal(fmt::format_string< T... > fmt, T &&... args)
Make an MXL_ERR_INTERNAL exception.
Wrapper around a libfabric endpoint address.
void * raw() noexcept
Pointer to the raw address data.
::fi_info * raw() noexcept
Returns the raw fi_info object managed by this FabricInfo instance.
void catchAndLogFabricError(F &&fun, std::string_view msg)
int fiCall(F &&fun, std::string_view msg, T &&... args)
Call a libfabric function and check its return code.
std::filesystem::path _domain
The monitored domain.
Configuration attributes of the AddressVector.
::fi_av_attr toRaw() const noexcept
Convert to libfabric fi_av_attr object.
static Attributes defaults() noexcept
Get default attributes.