63 std::function<void(uint32_t, uint32_t,
void*)>
pc_updater;
133 std::shared_ptr<std::thread> thread_pool =
nullptr;
146 std::chrono::milliseconds timeout { 0 };
197 template <
typename T>
200 execution_metadata[std::move(key)] = std::forward<T>(
value);
214 template <
typename T>
215 CastResult<T>
get(
const std::string& key)
const
217 auto it = execution_metadata.find(key);
219 if (it == execution_metadata.end()) {
220 CastResult<T> result;
221 result.error =
"ExecutionContext missing key: " + key;
225 return safe_any_cast<T>(it->second);
236 template <
typename T>
237 T
get_or(
const std::string& key,
const T& default_value)
const
239 auto it = execution_metadata.find(key);
241 if (it == execution_metadata.end())
242 return default_value;
244 return safe_any_cast<T>(it->second).value_or(default_value);
258 template <
typename T>
261 auto it = execution_metadata.find(key);
263 if (it == execution_metadata.end())
264 error<std::runtime_error>(Journal::Component::Yantra, Journal::Context::Runtime, std::source_location::current(),
"ExecutionContext missing key: {}", key);
266 return safe_any_cast_or_throw<T>(it->second);
277 return execution_metadata.contains(key);
290 template <
typename T>
293 dependencies.emplace_back(
typeid(T));
309 pre_execution_hook = std::move(cb);
321 post_execution_hook = std::move(cb);
333 reconstruction_callback = std::move(cb);
@ CUSTOM
User-defined analysis types.
std::function< void(std::any &)> OperationHookCallback
Callback type for pre/post operation hooks.
std::variant< std::monostate, ChainedParams, ChainedIndirectParams, DependencyParams > ExecutionParams
OperationType
Operation categories for organization and discovery.
ExecutionMode
Execution paradigms for operations.
@ SYNC
Synchronous execution.
@ CHAINED
Part of a sequential chain.
@ DEPENDENCY
Part of dependency graph.
@ CHAINED_INDIRECT
Chained dispatch where a GPU-written indirect buffer gates each pass's workgroup count.
@ ASYNC
Asynchronous execution.
@ PARALLEL
Parallel with other operations.
std::function< std::any(std::vector< std::vector< double > > &, std::any &)> ReconstructionCallback
Callback type for custom reconstruction logic.
std::optional< uint32_t > passes_per_batch
std::function< void(uint32_t, uint32_t, void *)> pc_updater
Parameters for ExecutionMode::CHAINED_INDIRECT.
std::function< void(uint32_t, void *)> pc_updater
std::optional< uint32_t > passes_per_batch
Parameters for ExecutionMode::CHAINED.
DependencyParams(const DependencyParams &)
std::vector< DependencyStage > stages
DependencyParams(DependencyParams &&) noexcept
Parameters for ExecutionMode::DEPENDENCY.
ExecutionContext & on_reconstruct(ReconstructionCallback cb)
Set reconstruction callback.
std::vector< std::type_index > dependencies
Operation dependencies required before execution.
CastResult< T > get(const std::string &key) const
Retrieve metadata value using safe casting.
ExecutionContext & on_pre(OperationHookCallback cb)
Set pre-execution hook.
ExecutionContext & set_mode(ExecutionMode m)
Set execution mode.
ExecutionContext & with_timeout(std::chrono::milliseconds duration)
Set execution timeout.
bool contains(const std::string &key) const
Check whether a metadata key exists.
ExecutionParams parameters
Optional parameters specific to the execution mode.
T get_or_throw(const std::string &key) const
Retrieve metadata value or throw if unavailable.
std::unordered_map< std::string, std::any > execution_metadata
Arbitrary metadata parameters used by operations.
ExecutionContext & on_post(OperationHookCallback cb)
Set post-execution hook.
T get_or(const std::string &key, const T &default_value) const
Retrieve metadata value or return a default.
ExecutionContext & depends_on()
Register dependency on a specific operation type.
ExecutionContext & set(std::string key, T &&value)
Insert or update metadata value.
Context information controlling how a compute operation executes.