MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
mxl::lib::fabrics::ofi::Domain Class Reference

RAII Wrapper around a libfabric domain (fi_domain). More...

#include <Domain.hpp>

Public Member Functions

 Domain (Domain &&) noexcept
 Domain (Domain const &)=delete
std::shared_ptr< Fabric > fabric () const noexcept
 Accessor for the fabric associated with this domain.
std::vector< LocalRegion > localRegions () const noexcept
 Get the local regions associated to the registered regions to this domain.
Domain & operator= (Domain &&)
void operator= (Domain const &)=delete
::fid_domain const * raw () const noexcept
 Accessor for the underlying fi_domain instance.
::fid_domain * raw () noexcept
 Accessor for the underlying fi_domain instance.
void registerRegion (Region const &region, std::uint64_t access)
 Register a single memory region to this domain.
void registerRegions (std::vector< Region > const &regions, std::uint64_t access)
 Register a list of memory regions to this domain.
std::vector< RemoteRegion > remoteRegions () const noexcept
 Get the remote regions associated to the registered regions to this domain.
bool usingRecvBufForCqData () const noexcept
 When this returns true, it means the target must post a fi_recv in order to receive immediate data.
bool usingVirtualAddresses () const noexcept
 When this returns true, a user should use virtual addresses instead of 0 based addresses when refering a remote address registered with this domain.
 ~Domain ()

Static Public Member Functions

static std::shared_ptr< Domain > open (std::shared_ptr< Fabric > fabric)
 Open a new domain associated with the specified fabric.

Private Member Functions

void close ()
 Close this domain and release all associated resources.
 Domain (::fid_domain *, std::shared_ptr< Fabric >, std::vector< RegisteredRegion >)
RegisteredRegion registerRegionImpl (Region const &region, std::uint64_t access)
 Register a single memory region to this domain.

Private Attributes

std::shared_ptr< Fabric > _fabric
::fid_domain * _raw
std::vector< RegisteredRegion > _registeredRegions

Detailed Description

RAII Wrapper around a libfabric domain (fi_domain).

Definition at line 23 of file Domain.hpp.

Constructor & Destructor Documentation

◆ ~Domain()

mxl::lib::fabrics::ofi::Domain::~Domain ( )

Definition at line 25 of file Domain.cpp.

26 {
27 catchAndLogFabricError([this]() { close(); }, "Failed to close domain");
28 }
void close()
Close this domain and release all associated resources.
Definition Domain.cpp:87
void catchAndLogFabricError(F &&fun, std::string_view msg)

◆ Domain() [1/3]

mxl::lib::fabrics::ofi::Domain::Domain ( Domain const & )
delete

◆ Domain() [2/3]

mxl::lib::fabrics::ofi::Domain::Domain ( Domain && other)
noexcept

Definition at line 98 of file Domain.cpp.

99 : _raw(other._raw)
100 , _fabric(std::move(other._fabric))
101 , _registeredRegions(std::move(other._registeredRegions))
102 {
103 other._raw = nullptr;
104 }
std::shared_ptr< Fabric > _fabric
Definition Domain.hpp:107
std::vector< RegisteredRegion > _registeredRegions
Definition Domain.hpp:109

◆ Domain() [3/3]

mxl::lib::fabrics::ofi::Domain::Domain ( ::fid_domain * raw,
std::shared_ptr< Fabric > fabric,
std::vector< RegisteredRegion > registeredRegions )
private

Definition at line 19 of file Domain.cpp.

20 : _raw(raw)
21 , _fabric(std::move(fabric))
22 , _registeredRegions(std::move(registeredRegions))
23 {}
std::shared_ptr< Fabric > fabric() const noexcept
Accessor for the fabric associated with this domain.
Definition Domain.cpp:77
::fid_domain * raw() noexcept
Accessor for the underlying fi_domain instance.
Definition Domain.cpp:119

Member Function Documentation

◆ close()

void mxl::lib::fabrics::ofi::Domain::close ( )
private

Close this domain and release all associated resources.

Definition at line 87 of file Domain.cpp.

88 {
89 _registeredRegions.clear();
90
91 if (_raw != nullptr)
92 {
93 fiCall(::fi_close, "Failed to close domain", &_raw->fid);
94 _raw = nullptr;
95 }
96 }
int fiCall(F &&fun, std::string_view msg, T &&... args)
Call a libfabric function and check its return code.

◆ fabric()

std::shared_ptr< Fabric > mxl::lib::fabrics::ofi::Domain::fabric ( ) const
nodiscardnoexcept

Accessor for the fabric associated with this domain.

Definition at line 77 of file Domain.cpp.

78 {
79 return _fabric;
80 }

◆ localRegions()

std::vector< LocalRegion > mxl::lib::fabrics::ofi::Domain::localRegions ( ) const
nodiscardnoexcept

Get the local regions associated to the registered regions to this domain.

If no regions was registered previously, this will return an empty vector.

Definition at line 57 of file Domain.cpp.

58 {
60 }
std::vector< LocalRegion > toLocal(std::vector< RegisteredRegion > const &groups) noexcept

◆ open()

std::shared_ptr< Domain > mxl::lib::fabrics::ofi::Domain::open ( std::shared_ptr< Fabric > fabric)
static

Open a new domain associated with the specified fabric.

Definition at line 30 of file Domain.cpp.

31 {
32 ::fid_domain* domain;
33
34 fiCall(::fi_domain2, "Failed to open domain", fabric->raw(), fabric->info().raw(), &domain, 0, nullptr);
35
36 struct MakeSharedEnabler : public Domain
37 {
38 MakeSharedEnabler(::fid_domain* domain, std::shared_ptr<Fabric> fabric, std::vector<RegisteredRegion> registerRegions)
39 : Domain(domain, std::move(fabric), std::move(registerRegions))
40 {}
41 };
42
43 return std::make_shared<MakeSharedEnabler>(domain, std::move(fabric), std::vector<RegisteredRegion>{});
44 }
Domain(Domain const &)=delete

◆ operator=() [1/2]

Domain & mxl::lib::fabrics::ofi::Domain::operator= ( Domain && other)

Definition at line 106 of file Domain.cpp.

107 {
108 close();
109
110 _raw = other._raw;
111 other._raw = nullptr;
112
113 _fabric = std::move(other._fabric);
114 _registeredRegions = std::move(other._registeredRegions);
115
116 return *this;
117 }

◆ operator=() [2/2]

void mxl::lib::fabrics::ofi::Domain::operator= ( Domain const & )
delete

◆ raw() [1/2]

fid_domain const * mxl::lib::fabrics::ofi::Domain::raw ( ) const
nodiscardnoexcept

Accessor for the underlying fi_domain instance.

Definition at line 124 of file Domain.cpp.

125 {
126 return _raw;
127 }

◆ raw() [2/2]

fid_domain * mxl::lib::fabrics::ofi::Domain::raw ( )
noexcept

Accessor for the underlying fi_domain instance.

Definition at line 119 of file Domain.cpp.

120 {
121 return _raw;
122 }

◆ registerRegion()

void mxl::lib::fabrics::ofi::Domain::registerRegion ( Region const & region,
std::uint64_t access )

Register a single memory region to this domain.

The domain will own its own version of the registered memory region.

Definition at line 52 of file Domain.cpp.

53 {
54 _registeredRegions.push_back(registerRegionImpl(region, access));
55 }
RegisteredRegion registerRegionImpl(Region const &region, std::uint64_t access)
Register a single memory region to this domain.
Definition Domain.cpp:82

◆ registerRegionImpl()

RegisteredRegion mxl::lib::fabrics::ofi::Domain::registerRegionImpl ( Region const & region,
std::uint64_t access )
nodiscardprivate

Register a single memory region to this domain.

The domain will own its own version of the registered memory region.

Definition at line 82 of file Domain.cpp.

83 {
84 return RegisteredRegion{MemoryRegion::reg(*this, region, access), region};
85 }
static MemoryRegion reg(Domain &domain, Region const &region, std::uint64_t access)
Register a memory region with a specified domain and access permissions.

◆ registerRegions()

void mxl::lib::fabrics::ofi::Domain::registerRegions ( std::vector< Region > const & regions,
std::uint64_t access )

Register a list of memory regions to this domain.

The domain will own its own version of the registered memory regions. A user can retrieve associated local and remote regions using localRegions() and remoteRegions() respectively.

Definition at line 46 of file Domain.cpp.

47 {
48 std::ranges::transform(
49 regions, std::back_inserter(_registeredRegions), [&](auto const& region) { return registerRegionImpl(region, access); });
50 }

◆ remoteRegions()

std::vector< RemoteRegion > mxl::lib::fabrics::ofi::Domain::remoteRegions ( ) const
nodiscardnoexcept

Get the remote regions associated to the registered regions to this domain.

If no regions was registered previously, this will return an empty vector.

Definition at line 62 of file Domain.cpp.

63 {
65 }
bool usingVirtualAddresses() const noexcept
When this returns true, a user should use virtual addresses instead of 0 based addresses when referin...
Definition Domain.cpp:67
std::vector< RemoteRegion > toRemote(std::vector< RegisteredRegion > const &groups, bool useVirtualAddress) noexcept

◆ usingRecvBufForCqData()

bool mxl::lib::fabrics::ofi::Domain::usingRecvBufForCqData ( ) const
nodiscardnoexcept

When this returns true, it means the target must post a fi_recv in order to receive immediate data.

Definition at line 72 of file Domain.cpp.

73 {
74 return (_fabric->info().raw()->rx_attr->mode & FI_RX_CQ_DATA) != 0;
75 }

◆ usingVirtualAddresses()

bool mxl::lib::fabrics::ofi::Domain::usingVirtualAddresses ( ) const
nodiscardnoexcept

When this returns true, a user should use virtual addresses instead of 0 based addresses when refering a remote address registered with this domain.

Definition at line 67 of file Domain.cpp.

68 {
69 return (_fabric->info().raw()->domain_attr->mr_mode & FI_MR_VIRT_ADDR) != 0;
70 }

Member Data Documentation

◆ _fabric

std::shared_ptr<Fabric> mxl::lib::fabrics::ofi::Domain::_fabric
private

Fabric associated with this domain.

Definition at line 107 of file Domain.hpp.

◆ _raw

::fid_domain* mxl::lib::fabrics::ofi::Domain::_raw
private

libfabric domain instance.

Definition at line 106 of file Domain.hpp.

◆ _registeredRegions

std::vector<RegisteredRegion> mxl::lib::fabrics::ofi::Domain::_registeredRegions
private

Registered regions associated with this domain. These are used to generate local and remote regions.

Definition at line 109 of file Domain.hpp.


The documentation for this class was generated from the following files: