RAII Wrapper around a libfabric completion queue (fi_cq).
More...
#include <CompletionQueue.hpp>
|
| struct | Attributes |
| | A collection of attributes that can be used to configure the operation of newly created completion queues. More...
|
|
| void | close () |
| | Releases all underlying resources. This is called from the destructor and the move-assignment operator.
|
| | CompletionQueue (::fid_cq *raw, std::shared_ptr< Domain > domain) |
| | The completion queue can only exists behind a shared_ptr.
|
| std::optional< Completion > | handleReadResult (ssize_t ret, ::fi_cq_data_entry const &entry) |
| | Handle the result of a blocking or non-blocking read.
|
RAII Wrapper around a libfabric completion queue (fi_cq).
Definition at line 19 of file CompletionQueue.hpp.
◆ ~CompletionQueue()
| mxl::lib::fabrics::ofi::CompletionQueue::~CompletionQueue |
( |
| ) |
|
Definition at line 96 of file CompletionQueue.cpp.
97 {
99 }
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)
◆ CompletionQueue() [1/3]
| mxl::lib::fabrics::ofi::CompletionQueue::CompletionQueue |
( |
CompletionQueue const & | | ) |
|
|
delete |
◆ CompletionQueue() [2/3]
| mxl::lib::fabrics::ofi::CompletionQueue::CompletionQueue |
( |
CompletionQueue && | | ) |
|
|
delete |
◆ CompletionQueue() [3/3]
| mxl::lib::fabrics::ofi::CompletionQueue::CompletionQueue |
( |
::fid_cq * | raw, |
|
|
std::shared_ptr< Domain > | domain ) |
|
private |
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 being released before all these events have be released, they own a shared_ptr to the queue they have originated from.
Definition at line 91 of file CompletionQueue.cpp.
94 {}
::fid_cq * raw() noexcept
Mutable accessor of the underlying fi_cq instance.
std::shared_ptr< Domain > _domain
◆ close()
| void mxl::lib::fabrics::ofi::CompletionQueue::close |
( |
| ) |
|
|
private |
Releases all underlying resources. This is called from the destructor and the move-assignment operator.
Definition at line 111 of file CompletionQueue.cpp.
112 {
114 {
116
117 fiCall(::fi_close,
"Failed to close completion queue", &
_raw->fid);
119 }
120 }
int fiCall(F &&fun, std::string_view msg, T &&... args)
Call a libfabric function and check its return code.
◆ handleReadResult()
| std::optional< Completion > mxl::lib::fabrics::ofi::CompletionQueue::handleReadResult |
( |
ssize_t | ret, |
|
|
::fi_cq_data_entry const & | entry ) |
|
private |
Handle the result of a blocking or non-blocking read.
This takes a raw completion entry and generate a Completion instance.
Definition at line 122 of file CompletionQueue.cpp.
123 {
124 if (ret == -FI_EAGAIN)
125 {
126
127 return std::nullopt;
128 }
129
130 if (ret == -FI_EAVAIL)
131 {
132
133
134 ::fi_cq_err_entry err{};
135 if (
auto const rc = ::fi_cq_readerr(
_raw, &err, 0); rc < 0)
136 {
137 if (rc == -FI_EAGAIN)
138 {
139 return std::nullopt;
140 }
141 throw FabricException::make(
static_cast<int>(rc),
"Failed to read completion error: {}", ::fi_strerror(
static_cast<int>(-rc)));
142 }
143
144 return Completion{
145 Completion::Error{err, this->shared_from_this()}
146 };
147 }
148
149 if (ret < 0)
150 {
152 }
153
154 return Completion{Completion::Data{entry}};
155 }
static FabricException make(int fiErrno, fmt::format_string< T... > fmt, T &&... args)
Create a new exception object.
◆ isWaitObjectSupportedForEFA()
| bool mxl::lib::fabrics::ofi::CompletionQueue::isWaitObjectSupportedForEFA |
( |
| ) |
|
|
staticnoexcept |
Check if wait any wait object type supported by the EFA provider for this libfabric version.
Definition at line 42 of file CompletionQueue.cpp.
43 {
45
46
48 }
std::uint32_t fiVersion() noexcept
Returns the libfabric version this library was compiled with.
◆ open()
Create a new completion queue in the specified domain.
Definition at line 50 of file CompletionQueue.cpp.
51 {
52 ::fid_cq* cq;
53 auto cq_attr = attr.raw();
54
55 fiCall(::fi_cq_open,
"Failed to open completion queue", domain->raw(), &cq_attr, &cq,
nullptr);
56
57
59 {
60 MakeSharedEnabler(::fid_cq* raw, std::shared_ptr<Domain> domain)
61 : CompletionQueue(
raw, domain)
62 {}
63 };
64
65 return std::make_shared<MakeSharedEnabler>(cq, domain);
66 }
CompletionQueue(CompletionQueue 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::CompletionQueue::operator= |
( |
CompletionQueue const & | | ) |
|
|
delete |
◆ raw() [1/2]
| fid_cq const * mxl::lib::fabrics::ofi::CompletionQueue::raw |
( |
| ) |
const |
|
nodiscardnoexcept |
◆ raw() [2/2]
| fid_cq * mxl::lib::fabrics::ofi::CompletionQueue::raw |
( |
| ) |
|
|
noexcept |
◆ read()
| std::optional< Completion > mxl::lib::fabrics::ofi::CompletionQueue::read |
( |
| ) |
|
Perform a non-blocking read on the completion queue.
If no completion event is available in the queue returns std::nullopt
Definition at line 68 of file CompletionQueue.cpp.
69 {
70 fi_cq_data_entry entry;
71
72 ssize_t ret = fi_cq_read(
_raw, &entry, 1);
73
75 }
std::optional< Completion > handleReadResult(ssize_t ret, ::fi_cq_data_entry const &entry)
Handle the result of a blocking or non-blocking read.
◆ readBlocking()
| std::optional< Completion > mxl::lib::fabrics::ofi::CompletionQueue::readBlocking |
( |
std::chrono::steady_clock::duration | timeout | ) |
|
Perform a blocking read on the completion queue.
This function will block until the specified timeout has elapsed, the process is signaled, or a completion is available on the queue. If no event was available after the timeout, the function returns std::nullopt. If the process is signaled while blocking on this functions, an exception will be thrown.
Definition at line 77 of file CompletionQueue.cpp.
78 {
79 auto timeoutMs = std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count();
80 if (timeoutMs == 0)
81 {
83 }
84
85 fi_cq_data_entry entry;
86
87 ssize_t ret = fi_cq_sread(
_raw, &entry, 1,
nullptr, timeoutMs);
89 }
std::optional< Completion > read()
Perform a non-blocking read on the completion queue.
◆ _domain
| std::shared_ptr<Domain> mxl::lib::fabrics::ofi::CompletionQueue::_domain |
|
private |
◆ _raw
| ::fid_cq* mxl::lib::fabrics::ofi::CompletionQueue::_raw |
|
private |
The documentation for this class was generated from the following files: