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

RAIII wrapper around a libfabric fabric object (fid_fabric). More...

#include <Fabric.hpp>

Public Member Functions

 Fabric (Fabric &&) noexcept
 Fabric (Fabric const &)=delete
FabricInfoView info () const noexcept
 Get a view on the libfabric info used to open this fabric.
Fabric & operator= (Fabric &&)
void operator= (Fabric const &)=delete
::fid_fabric const * raw () const noexcept
 Immutable accessor for the underlying raw libfabric fabric object.
::fid_fabric * raw () noexcept
 Mutable accessor for the underlying raw libfabric fabric object.
 ~Fabric ()

Static Public Member Functions

static std::shared_ptr< Fabric > open (FabricInfoView info)
 Open a fabric object based on the provided FabricInfoView.

Private Member Functions

void close ()
 Close the underlying fabric object.
 Fabric (::fid_fabric *raw, FabricInfoView info)

Private Attributes

FabricInfo _info
::fid_fabric * _raw

Detailed Description

RAIII wrapper around a libfabric fabric object (fid_fabric).

Definition at line 16 of file Fabric.hpp.

Constructor & Destructor Documentation

◆ ~Fabric()

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

Definition at line 37 of file Fabric.cpp.

38 {
39 catchAndLogFabricError([this]() { close(); }, "Failed to close fabrics");
40 }
void close()
Close the underlying fabric object.
Definition Fabric.cpp:75
void catchAndLogFabricError(F &&fun, std::string_view msg)

◆ Fabric() [1/3]

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

◆ Fabric() [2/3]

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

Definition at line 42 of file Fabric.cpp.

43 : _raw(other._raw)
44 , _info(other._info)
45 {
46 other._raw = nullptr;
47 }

◆ Fabric() [3/3]

mxl::lib::fabrics::ofi::Fabric::Fabric ( ::fid_fabric * raw,
FabricInfoView info )
private

Definition at line 32 of file Fabric.cpp.

33 : _raw(raw)
34 , _info(info.owned())
35 {}
::fid_fabric * raw() noexcept
Mutable accessor for the underlying raw libfabric fabric object.
Definition Fabric.cpp:60
FabricInfoView info() const noexcept
Get a view on the libfabric info used to open this fabric.
Definition Fabric.cpp:70

Member Function Documentation

◆ close()

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

Close the underlying fabric object.

Definition at line 75 of file Fabric.cpp.

76 {
77 if (_raw != nullptr)
78 {
79 fiCall(::fi_close, "failed to close fabric", &_raw->fid);
80 }
81 }
int fiCall(F &&fun, std::string_view msg, T &&... args)
Call a libfabric function and check its return code.

◆ info()

FabricInfoView mxl::lib::fabrics::ofi::Fabric::info ( ) const
nodiscardnoexcept

Get a view on the libfabric info used to open this fabric.

Definition at line 70 of file Fabric.cpp.

71 {
72 return _info.view();
73 }

◆ open()

std::shared_ptr< Fabric > mxl::lib::fabrics::ofi::Fabric::open ( FabricInfoView info)
static

Open a fabric object based on the provided FabricInfoView.

Parameters
infoThe fabric info to use when opening the fabric.
Returns
A shared pointer to the opened Fabric object.

Definition at line 15 of file Fabric.cpp.

16 {
17 ::fid_fabric* fid;
18
19 fiCall(::fi_fabric2, "Failed to open fabric", info.raw(), &fid, 0, nullptr);
20
21 // expose the private constructor to std::make_shared inside this function
22 struct MakeSharedEnabler : public Fabric
23 {
24 MakeSharedEnabler(::fid_fabric* raw, FabricInfoView info)
25 : Fabric(raw, info)
26 {}
27 };
28
29 return std::make_shared<MakeSharedEnabler>(fid, info);
30 }
Fabric(Fabric const &)=delete
::fi_info * raw() noexcept
Returns the raw fi_info object managed by this FabricInfo instance.

◆ operator=() [1/2]

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

Definition at line 49 of file Fabric.cpp.

50 {
51 close();
52
53 _raw = other._raw;
54 _info = other._info;
55 other._raw = nullptr;
56
57 return *this;
58 }

◆ operator=() [2/2]

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

◆ raw() [1/2]

fid_fabric const * mxl::lib::fabrics::ofi::Fabric::raw ( ) const
nodiscardnoexcept

Immutable accessor for the underlying raw libfabric fabric object.

Definition at line 65 of file Fabric.cpp.

66 {
67 return _raw;
68 }

◆ raw() [2/2]

fid_fabric * mxl::lib::fabrics::ofi::Fabric::raw ( )
nodiscardnoexcept

Mutable accessor for the underlying raw libfabric fabric object.

Definition at line 60 of file Fabric.cpp.

61 {
62 return _raw;
63 }

Member Data Documentation

◆ _info

FabricInfo mxl::lib::fabrics::ofi::Fabric::_info
private

Definition at line 57 of file Fabric.hpp.

◆ _raw

::fid_fabric* mxl::lib::fabrics::ofi::Fabric::_raw
private

Definition at line 56 of file Fabric.hpp.


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