rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
Loading...
Searching...
No Matches
Public Member Functions | List of all members
rexlib::execution_context Class Reference

Pairs the hardware resources and the dispatch strategy used to run operations. More...

#include <rexlib/core/dispatch/execution_context.hpp>

Public Member Functions

 execution_context () noexcept
 Construct an empty execution context.
 
 execution_context (device_context device_context, std::shared_ptr< dispatcher > dispatcher)
 Construct an execution context with an explicit dispatcher.
 
 execution_context (const execution_context &other)
 
 execution_context (execution_context &&other) noexcept
 
execution_context & operator= (const execution_context &other)
 
execution_context & operator= (execution_context &&other) noexcept
 
const device_context & get_device_context () const noexcept
 Retrieve the device context describing where operations execute.
 
const std::shared_ptr< dispatcher > & get_dispatcher () const noexcept
 Retrieve the dispatcher used to execute operations.
 
execution_context with_device_context (device_context device_context) const
 Derive an execution context with a different device context.
 
execution_context with_dispatcher (std::shared_ptr< dispatcher > dispatcher) const
 Derive an execution context with a different dispatcher.
 

Detailed Description

Pairs the hardware resources and the dispatch strategy used to run operations.

An execution_context bundles the two pieces of state that every operation needs in order to run: a device_context describing where the work executes (the device, its active command_queue and its memory_allocator slots), and a dispatcher describing how operations are turned into device work.

Like device_context, the execution context is a lightweight, copyable value with functional-update semantics: with_device_context and with_dispatcher do not mutate the receiver, they return a modified copy. This makes an execution context cheap to share (the device context and the dispatcher are both held by shared pointer) while letting callers derive scoped variants, e.g. to run a single operation on a different queue without disturbing any other user of the original execution context.

Empty state
A default-constructed or moved-from execution context is empty: its device context is empty (see device_context) and its dispatcher is null. Querying it is well defined; the accessors simply return an empty device context and a null dispatcher.

Constructor & Destructor Documentation

◆ execution_context() [1/2]

rexlib::execution_context::execution_context ( )
noexcept

Construct an empty execution context.

The resulting execution context holds an empty device_context and a null dispatcher.

◆ execution_context() [2/2]

rexlib::execution_context::execution_context ( device_context  device_context,
std::shared_ptr< dispatcher >  dispatcher 
)

Construct an execution context with an explicit dispatcher.

Parameters
device_contextThe hardware resources on which operations execute.
dispatcherThe dispatcher used to turn operations into device work.

Member Function Documentation

◆ get_device_context()

const device_context & rexlib::execution_context::get_device_context ( ) const
noexcept

Retrieve the device context describing where operations execute.

Returns
A reference to the wrapped device context.

◆ get_dispatcher()

const std::shared_ptr< dispatcher > & rexlib::execution_context::get_dispatcher ( ) const
noexcept

Retrieve the dispatcher used to execute operations.

Returns
A reference to the dispatcher, or to a null pointer when this execution context is empty.

◆ with_device_context()

execution_context rexlib::execution_context::with_device_context ( device_context  device_context) const

Derive an execution context with a different device context.

Replaces the hardware resources describing where operations execute while preserving the dispatcher. Per-use derivations such as switching queue or overriding an allocator are expressed on the device_context itself, e.g. ctx.with_device_context(ctx.get_device_context().on_queue(queue));

Parameters
device_contextThe device context of the returned execution context.
Returns
A copy of this execution context with device_context as its device context and the same dispatcher.

◆ with_dispatcher()

execution_context rexlib::execution_context::with_dispatcher ( std::shared_ptr< dispatcher >  dispatcher) const

Derive an execution context with a different dispatcher.

Parameters
dispatcherThe dispatcher of the returned execution context.
Returns
A copy of this execution context with dispatcher as its dispatcher and the same device context.

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