RAII Wrapper around a libfabric event queue (fi_eq).
More...
#include <EventQueue.hpp>
|
| | EventQueue (EventQueue &&)=delete |
| | EventQueue (EventQueue const &)=delete |
| EventQueue & | operator= (EventQueue &&)=delete |
| void | operator= (EventQueue const &)=delete |
| ::fid_eq const * | raw () const noexcept |
| | Returns a raw handle to the event queue.
|
| ::fid_eq * | raw () noexcept |
| | Returns a raw handle to the event queue.
|
| std::optional< Event > | read () |
| | Perform a non-blocking read on the event queue. If no event is available in the queue, this function returns std::nullopt.
|
| std::optional< Event > | readBlocking (std::chrono::steady_clock::duration timeout) |
| | Perform a blocking read on the event queue.
|
| | ~EventQueue () |
|
| void | close () |
| | Releases all underlying resources. This is called from the destructor and the move-assignment operator.
|
| | EventQueue (::fid_eq *raw, std::shared_ptr< Fabric > fabric) |
| | Construct and event queue.
|
| std::optional< Event > | handleReadResult (ssize_t, std::uint32_t, ::fi_eq_entry const &) |
| | Handle the result of a blocking or non-blocking read.
|
RAII Wrapper around a libfabric event queue (fi_eq).
Definition at line 18 of file EventQueue.hpp.
◆ ~EventQueue()
| mxl::lib::fabrics::ofi::EventQueue::~EventQueue |
( |
| ) |
|
Definition at line 87 of file EventQueue.cpp.
88 {
90 }
void close()
Releases all underlying resources. This is called from the destructor and the move-assignment operato...
void catchAndLogFabricError(F &&fun, std::string_view msg)
◆ EventQueue() [1/3]
| mxl::lib::fabrics::ofi::EventQueue::EventQueue |
( |
EventQueue const & | | ) |
|
|
delete |
◆ EventQueue() [2/3]
| mxl::lib::fabrics::ofi::EventQueue::EventQueue |
( |
EventQueue && | | ) |
|
|
delete |
◆ EventQueue() [3/3]
| mxl::lib::fabrics::ofi::EventQueue::EventQueue |
( |
::fid_eq * | raw, |
|
|
std::shared_ptr< Fabric > | fabric ) |
|
private |
Construct and event queue.
The completion queue can only exists behind a shared_ptr. Some events need to carry a reference to the completion queue. To prevent the queue from beeing released before all these events have be released, they own a shared_ptr to the queue they have originated from.
Definition at line 82 of file EventQueue.cpp.
85 {}
std::shared_ptr< Fabric > _fabric
::fid_eq * raw() noexcept
Returns a raw handle to the event queue.
◆ close()
| void mxl::lib::fabrics::ofi::EventQueue::close |
( |
| ) |
|
|
private |
Releases all underlying resources. This is called from the destructor and the move-assignment operator.
Definition at line 102 of file EventQueue.cpp.
103 {
105 {
106 fiCall(::fi_close,
"Failed to close event queue", &
_raw->fid);
108 }
109 }
int fiCall(F &&fun, std::string_view msg, T &&... args)
Call a libfabric function and check its return code.
◆ handleReadResult()
| std::optional< Event > mxl::lib::fabrics::ofi::EventQueue::handleReadResult |
( |
ssize_t | ret, |
|
|
std::uint32_t | eventType, |
|
|
::fi_eq_entry const & | entry ) |
|
private |
Handle the result of a blocking or non-blocking read.
This takes a raw event queue entry and generate an Event instance.
Definition at line 111 of file EventQueue.cpp.
112 {
113 if (ret == -FI_EAGAIN)
114 {
115
116 return std::nullopt;
117 }
118
119 if (ret == -FI_EAVAIL)
120 {
121 ::fi_eq_err_entry eq_err{};
122 fi_eq_readerr(
_raw, &eq_err, 0);
123
125 }
126
127 if (ret < 0)
128 {
130 }
131
132 switch (eventType)
133 {
134 case FI_CONNECTED:
135 case FI_CONNREQ:
136 case FI_SHUTDOWN:
return Event::fromRawCMEntry(*
reinterpret_cast<fi_eq_cm_entry const*
>(&entry), eventType);
break;
137 case FI_NOTIFY:
138 case FI_MR_COMPLETE:
139 case FI_AV_COMPLETE:
141 default:
MXL_WARN(
"Unhandled event on event queue: code: {}", eventType);
return std::nullopt;
142 }
143 }
static Event fromRawCMEntry(::fi_eq_cm_entry const &raw, std::uint32_t eventType)
create an Event from a libfabric Connection Management event
static Event fromRawEntry(::fi_eq_entry const &raw, std::uint32_t eventType)
static Event fromError(std::shared_ptr< EventQueue > queue, ::fi_eq_err_entry const *raw)
create an Event from a libfabric event error entry
static FabricException make(int fiErrno, fmt::format_string< T... > fmt, T &&... args)
Create a new exception object.
◆ open()
Create a new event queue associated with the specified fabric.
Definition at line 38 of file EventQueue.cpp.
39 {
40 ::fid_eq* eq;
41 auto eq_attr = attr.raw();
42
43 fiCall(::fi_eq_open,
"Failed to open event queue", fabric->raw(), &eq_attr, &eq,
nullptr);
44
45
47 {
48 MakeSharedEnabler(::fid_eq* raw, std::shared_ptr<Fabric> fabric)
49 : EventQueue(
raw, fabric)
50 {}
51 };
52
53 return std::make_shared<MakeSharedEnabler>(eq, fabric);
54 }
EventQueue(EventQueue const &)=delete
::fi_info * raw() noexcept
Returns the raw fi_info object managed by this FabricInfo instance.
◆ operator=() [1/2]
◆ operator=() [2/2]
| void mxl::lib::fabrics::ofi::EventQueue::operator= |
( |
EventQueue const & | | ) |
|
|
delete |
◆ raw() [1/2]
| fid_eq const * mxl::lib::fabrics::ofi::EventQueue::raw |
( |
| ) |
const |
|
nodiscardnoexcept |
Returns a raw handle to the event queue.
Definition at line 97 of file EventQueue.cpp.
◆ raw() [2/2]
| fid_eq * mxl::lib::fabrics::ofi::EventQueue::raw |
( |
| ) |
|
|
noexcept |
Returns a raw handle to the event queue.
Definition at line 92 of file EventQueue.cpp.
◆ read()
| std::optional< Event > mxl::lib::fabrics::ofi::EventQueue::read |
( |
| ) |
|
Perform a non-blocking read on the event queue. If no event is available in the queue, this function returns std::nullopt.
Definition at line 56 of file EventQueue.cpp.
57 {
58 std::uint32_t eventType;
59 ::fi_eq_entry entry;
60
61 auto const ret = fi_eq_read(
_raw, &eventType, &entry,
sizeof(entry), 0);
62
64 }
std::optional< Event > handleReadResult(ssize_t, std::uint32_t, ::fi_eq_entry const &)
Handle the result of a blocking or non-blocking read.
◆ readBlocking()
| std::optional< Event > mxl::lib::fabrics::ofi::EventQueue::readBlocking |
( |
std::chrono::steady_clock::duration | timeout | ) |
|
Perform a blocking read on the event queue.
This function will block until the specified timeout has elapsed, the process is signalled, or an event is available on the queue. If no event was available after the timeout, the function returns std::nullopt. If the process is signalled while blocking on this function, an exception will be thrown.
Definition at line 66 of file EventQueue.cpp.
67 {
68 auto timeoutMs = std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count();
69 if (timeoutMs == 0)
70 {
72 }
73
74 std::uint32_t eventType;
75 ::fi_eq_entry entry;
76
77 auto const ret = fi_eq_sread(
_raw, &eventType, &entry,
sizeof(entry), timeoutMs, 0);
78
80 }
std::optional< Event > read()
Perform a non-blocking read on the event queue. If no event is available in the queue,...
◆ _fabric
| std::shared_ptr<Fabric> mxl::lib::fabrics::ofi::EventQueue::_fabric |
|
private |
Pointer to the fabric for which the event queue was created.
Definition at line 96 of file EventQueue.hpp.
◆ _raw
| ::fid_eq* mxl::lib::fabrics::ofi::EventQueue::_raw |
|
private |
The documentation for this class was generated from the following files: