11#include <rdma/fabric.h>
12#include <rdma/fi_domain.h>
26 attr.device.cuda = loc.
id();
34 case FI_HMEM_SYNAPSEAI:
return;
41 std::random_device rd;
42 std::mt19937_64 gen(rd());
43 std::uniform_int_distribution<uint64_t> dist(0, UINT64_MAX);
45 std::uint64_t
flags = 0;
55 attr.requested_key = dist(gen);
56 attr.context =
nullptr;
57 attr.auth_key_size = 0;
58 attr.auth_key =
nullptr;
60 attr.hmem_data =
nullptr;
61 attr.page_size = 4096;
62 attr.base_mr =
nullptr;
65 fiCall(fi_mr_regattr,
"Failed to register memory region", domain.
raw(), &attr,
flags, &
raw);
67 MXL_DEBUG(
"Registered memory region with address 0x{}, size {} and location {} -> key 0x{:x} desc {}",
76 MakeSharedEnabler(::fid_mr*
raw)
100 other._raw =
nullptr;
107 return fi_mr_desc(
_raw);
112 return fi_mr_key(
_raw);
124 fiCall(::fi_close,
"Failed to close memory region", &
_raw->fid);
RAII Wrapper around a libfabric domain (fi_domain).
::fid_domain * raw() noexcept
Accessor for the underlying fi_domain instance.
void operator=(MemoryRegion const &)=delete
static MemoryRegion reg(Domain &domain, Region const ®ion, std::uint64_t access)
Register a memory region with a specified domain and access permissions.
void close()
Internal method to release the memory region.
::fid_mr * raw() noexcept
Access the underlying raw fid_mr pointer.
void * desc() const noexcept
Get the descriptor associated with the memory region.
std::uint64_t rkey() const noexcept
Get the remote key (rkey) associated with the memory region.
MemoryRegion(MemoryRegion const &)=delete
Represent the location of a memory region.
std::string toString() const noexcept
Generate a string representation of the memory location.
std::uint64_t id() const noexcept
Return the device id. For host location 0 is returned.
bool isHost() const noexcept
Return true if the memory location is on host.
::fi_hmem_iface iface() const noexcept
Convert the current location to libfabric "iface" representation.
Represent a memory region (unregistered).
::iovec const * asIovec() const noexcept
Return the underlying iovec structure representing the memory region.
void setDeviceId(::fi_mr_attr &attr, Region::Location loc)
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.
gInfo flags
Mark the grain as invalid.