|
rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
|
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. | |
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.
|
noexcept |
Construct an empty execution context.
The resulting execution context holds an empty device_context and a null dispatcher.
| rexlib::execution_context::execution_context | ( | device_context | device_context, |
| std::shared_ptr< dispatcher > | dispatcher | ||
| ) |
Construct an execution context with an explicit dispatcher.
| device_context | The hardware resources on which operations execute. |
| dispatcher | The dispatcher used to turn operations into device work. |
|
noexcept |
Retrieve the device context describing where operations execute.
|
noexcept |
Retrieve the dispatcher used to execute operations.
| 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));
| device_context | The device context of the returned execution context. |
device_context as its device context and the same dispatcher. | execution_context rexlib::execution_context::with_dispatcher | ( | std::shared_ptr< dispatcher > | dispatcher | ) | const |
Derive an execution context with a different dispatcher.
| dispatcher | The dispatcher of the returned execution context. |
dispatcher as its dispatcher and the same device context.