48 bool isIdle()
const noexcept;
75 void activate(std::shared_ptr<CompletionQueue>
const& cq, std::shared_ptr<EventQueue>
const& eq);
87 void transferGrain(std::uint64_t localIndex, std::uint64_t remoteIndex, std::uint64_t remotePayloadOffset,
SliceRange const& sliceRange);
167 using State = std::variant<Idle, Connecting, Connected, Flushing, Disconnected, Done>;
219 virtual void transferGrain(std::uint64_t grainIndex, std::uint16_t startSlice, std::uint16_t endSlice)
final;
224 std::uint16_t startSlice, std::uint16_t endSlice)
final;
273 RCInitiator(std::shared_ptr<Domain> domain, std::shared_ptr<CompletionQueue> cq, std::shared_ptr<EventQueue> eq,
274 std::unique_ptr<EgressProtocolTemplate> proto);
307 std::shared_ptr<CompletionQueue>
_cq;
308 std::shared_ptr<EventQueue>
_eq;
309 std::unique_ptr<EgressProtocolTemplate>
_proto;
311 std::map<Completion::Token, RCInitiatorEndpoint>
_targets{};
Type to represent a completion entry from a CompletionQueue.
RAII Wrapper around a libfabric endpoint (fi_ep).
std::uintptr_t Id
An id type that can be used to reference this endpoint from completions and events.
Type to represent an event entry from an EventQueue.
Non-owning view of a FabricInfo. Returned when iterating over a FabricInfoList.
Abstract base class for Initiator implementations.
std::variant< Ready, NotReady, Interrupted > MakeProgressResult
A single endpoint connected to a target that will be created when the user adds a target to an initia...
std::variant< Idle, Connecting, Connected, Flushing, Disconnected, Done > State
The various states that the endpoint can be in are stored inside a variant that we move from and then...
void transferGrain(std::uint64_t localIndex, std::uint64_t remoteIndex, std::uint64_t remotePayloadOffset, SliceRange const &sliceRange)
Post a data transfer request to this endpoint.
void shutdown()
Initiate a shutdown process.
RCInitiatorEndpoint(Endpoint, std::unique_ptr< EgressProtocol > proto, TargetInfo info)
Construct a new RCInitiatorEndpoint object.
AfterFlush
The state that the endpoint goes to when a flush is complete.
static constexpr auto FlushTimeout
Upper bound for the flushing state. Some providers do not report a local shutdown event,...
void consume(Event event)
Consume an event that was posted to the associated event queue.
static Flushing startFlush(Endpoint ep, std::size_t pending, bool shutdownReceived, AfterFlush next)
Create a flushing state that waits for the given number of outstanding operations.
Idle restart(Endpoint const &endpoint)
Restarts the endpoint. Produces a new Idle state from any previous state.
void transferSamples(std::uint64_t headIndex, std::size_t count)
Post a data transfer request to this endpoint.
TargetInfo const & info() const noexcept
Get the target info of the remote endpoint.
void finishFlush()
Move the endpoint out of the flushing state when the flush is complete.
bool isIdle() const noexcept
Returns true if the endpoint is idle and could be actived.
void activate(std::shared_ptr< CompletionQueue > const &cq, std::shared_ptr< EventQueue > const &eq)
Try to activate the endpoint.
std::unique_ptr< EgressProtocol > _proto
bool canEvict() const noexcept
Returns true if the endpoint was shut down and can be evicted from the initiator.
bool hasPendingWork() const noexcept
Returns true if there is any pending events that the endpoint is waiting for, and for which the queue...
std::shared_ptr< EventQueue > _eq
void activateIfIdle(RCInitiatorEndpoint &target)
Try to activate the endpoint if it is idle. Called before a transfer is posted to the endpoint.
void evictDeadEndpoints()
Evict any dead endpoints that are no longer used.
std::unique_ptr< EgressProtocolTemplate > _proto
virtual void transferSamples(std::uint64_t headIndex, std::size_t count) final
Transfer samples to all targets.
RCInitiator(std::shared_ptr< Domain > domain, std::shared_ptr< CompletionQueue > cq, std::shared_ptr< EventQueue > eq, std::unique_ptr< EgressProtocolTemplate > proto)
Initiator::MakeProgressResult afterProgressResult() const noexcept
Returns true if any of the endpoints contained in this initiator have pending work.
virtual void addTarget(TargetInfo const &targetInfo) final
Add a target to the initiator.
virtual Initiator::MakeProgressResult makeProgressBlocking(std::chrono::steady_clock::duration) final
Attempts to progress execution, including connection management and data operations.
Initiator::MakeProgressResult blockOnCQ(std::chrono::steady_clock::duration timeout)
Block on the completion queue with a timeout.
static constexpr auto EQPollInterval
When making progress and using blocking queue reads, this is the minimum interval at which the event ...
static constexpr auto ShutdownPollInterval
Sleep time between two queue reads in shutdown().
virtual void shutdown() final
Shut down the initiator gracefully.
void activateIdleEndpoints()
Try to activate any idle endpoints.
virtual Initiator::MakeProgressResult makeProgress() final
Attempts to progress execution, including connection management and data operations.
void finishFlushingEndpoints()
Move endpoints that have finished flushing to the done state.
std::shared_ptr< CompletionQueue > _cq
virtual void transferGrain(std::uint64_t grainIndex, std::uint16_t startSlice, std::uint16_t endSlice) final
Transfer a grain to all targets.
std::map< Completion::Token, RCInitiatorEndpoint > _targets
void pollEQ()
Poll the event queue and process the returned events until the queue is empty.
std::shared_ptr< Domain > _domain
bool hasTarget() const noexcept
Returns true if the initiator has at least 1 target added no matter what the state is.
static std::unique_ptr< RCInitiator > setup(mxlFabricsInitiatorConfig const &config, FabricInfoView info, InitiatorSetupOptions const &options={})
Set up a fresh initiator without any targets assigned to it.
virtual void transferGrainToTarget(Endpoint::Id targetId, std::uint64_t localIndex, std::uint64_t remoteIndex, std::uint64_t payloadOffset, std::uint16_t startSlice, std::uint16_t endSlice) final
Transfer a grain to a specific target.
static constexpr auto ShutdownTimeout
Upper bound for shutdown(). It is longer than RCInitiatorEndpoint::FlushTimeout, so that each flush e...
virtual void removeTarget(TargetInfo const &targetInfo) final
Remove a target from the initiator.
void pollCQ()
Poll the completion queue and process the events until the queue is empty.
A SliceRange represents a range of slices within a grain.
struct mxlFabricsInitiatorConfig_t mxlFabricsInitiatorConfig
std::size_t count(uuids::uuid id) const noexcept
Returns the number of writers registered for flow id 'id'.
Provider-independent tuning options for initiator setup.
The endpoint is done and can be evicted from the initiator.
std::chrono::steady_clock::time_point deadline
std::chrono::steady_clock::time_point idleSince
TargetInfo contains all the information required by an initiator to operate transfers to the given ta...