12#include <rdma/fi_eq.h>
13#include <rdma/fi_errno.h>
34 raw.format = FI_CQ_FORMAT_DATA;
35 raw.wait_cond = FI_CQ_COND_NONE;
36 raw.wait_set =
nullptr;
38 raw.signaling_vector = 0;
53 auto cq_attr = attr.
raw();
55 fiCall(::fi_cq_open,
"Failed to open completion queue", domain->raw(), &cq_attr, &cq,
nullptr);
60 MakeSharedEnabler(::fid_cq*
raw, std::shared_ptr<Domain> domain)
65 return std::make_shared<MakeSharedEnabler>(cq, domain);
70 fi_cq_data_entry entry;
72 ssize_t ret = fi_cq_read(
_raw, &entry, 1);
79 auto timeoutMs = std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count();
85 fi_cq_data_entry entry;
87 ssize_t ret = fi_cq_sread(
_raw, &entry, 1,
nullptr, timeoutMs);
117 fiCall(::fi_close,
"Failed to close completion queue", &
_raw->fid);
124 if (ret == -FI_EAGAIN)
130 if (ret == -FI_EAVAIL)
134 ::fi_cq_err_entry err{};
135 if (
auto const rc = ::fi_cq_readerr(
_raw, &err, 0); rc < 0)
137 if (rc == -FI_EAGAIN)
141 throw FabricException::make(
static_cast<int>(rc),
"Failed to read completion error: {}", ::fi_strerror(
static_cast<int>(-rc)));
static std::shared_ptr< CompletionQueue > open(std::shared_ptr< Domain > domain, Attributes const &attr=Attributes::defaults())
Create a new completion queue in the specified domain.
::fid_cq * raw() noexcept
Mutable accessor of the underlying fi_cq instance.
CompletionQueue(CompletionQueue const &)=delete
void close()
Releases all underlying resources. This is called from the destructor and the move-assignment operato...
static bool isWaitObjectSupportedForEFA() noexcept
Check if wait any wait object type supported by the EFA provider for this libfabric version.
std::shared_ptr< Domain > _domain
std::optional< Completion > readBlocking(std::chrono::steady_clock::duration timeout)
Perform a blocking read on the completion queue.
std::optional< Completion > handleReadResult(ssize_t ret, ::fi_cq_data_entry const &entry)
Handle the result of a blocking or non-blocking read.
std::optional< Completion > read()
Perform a non-blocking read on the completion queue.
Data variant of the completion entry instance.
Error variant of the completion entry instance.
Type to represent a completion entry from a CompletionQueue.
static FabricException make(int fiErrno, fmt::format_string< T... > fmt, T &&... args)
Create a new exception object.
std::uint32_t fiVersion() noexcept
Returns the libfabric version this library was compiled with.
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.
A collection of attributes that can be used to configure the operation of newly created completion qu...
static constexpr std::size_t DEFAULT_SIZE
The completion-queue depth used when no explicit depth is requested.
enum fi_wait_obj waitObject
::fi_cq_attr raw() const noexcept
Returns the raw libfabric version of this object.
static Attributes defaults()
Returns the a CompletionQueueAttr with all of its attributes set to reasonable defaults.