GridFire v0.7.6rc4.0
General Purpose Nuclear Network
Loading...
Searching...
No Matches
blob.h File Reference

Container class for managing multiple scratchpad instances. More...

#include "gridfire/engine/scratchpads/scratchpad_abstract.h"
#include "gridfire/engine/scratchpads/types.h"
#include "gridfire/exceptions/error_scratchpad.h"
#include <unordered_map>
#include <memory>
#include <expected>
#include <unordered_set>
Include dependency graph for blob.h:
This graph shows which files directly or indirectly include this file:

Classes

class  gridfire::engine::scratch::StateBlob
 Container for managing a collection of typed scratchpad instances. More...
 

Namespaces

namespace  gridfire
 
namespace  gridfire::engine
 
namespace  gridfire::engine::scratch
 Scratchpad memory management for computational engines.
 

Concepts

concept  gridfire::engine::scratch::IsScratchPad
 Concept that constrains types to valid scratchpad implementations.
 

Detailed Description

Container class for managing multiple scratchpad instances.

This header defines the StateBlob class, which serves as a centralized registry for managing multiple scratchpad instances used by computational engines. It provides type-safe enrollment, retrieval, and cloning of scratchpads using compile-time type checking via C++20 concepts.

Purpose
The StateBlob provides:
  • A fixed-size array of scratchpad slots indexed by ScratchPadType
  • Type-safe enrollment ensuring one instance per scratchpad type
  • Compile-time verified retrieval with optional initialization checks
  • Deep cloning of all enrolled scratchpads for parallel execution
  • Status tracking for each scratchpad slot
Examples
using namespace gridfire::engine::scratch;
// Create a StateBlob and enroll scratchpads
StateBlob blob;
// Retrieve a scratchpad (returns std::expected)
auto result = blob.get<GraphEngineScratchPad>();
if (result.has_value()) {
GraphEngineScratchPad* scratch = result.value();
scratch->initialize(engine);
}
// Retrieve with initialization check
auto checked = blob.get<GraphEngineScratchPad, true>();
if (!checked.has_value()) {
// Handle uninitialized scratchpad
}
}
// Clone for parallel execution
auto worker_blob = blob.clone_structure();
Container class for managing multiple scratchpad instances.
Container for managing a collection of typed scratchpad instances.
Definition blob.h:114
@ SCRATCHPAD_NOT_INITIALIZED
Scratchpad exists but is not initialized.
Definition blob.h:122
void enroll()
Enroll a new scratchpad type into the blob.
Definition blob.h:196
std::unique_ptr< StateBlob > clone_structure() const
Create a deep copy of this blob with all enrolled scratchpads.
Definition blob.h:361
std::expected< CTX *, Error > get() const
Retrieve a scratchpad by type.
Definition blob.h:230
Scratchpad implementation for the GraphEngine using CppAD automatic differentiation.
Scratchpad memory management for computational engines.
Definition blob.h:69
Definition dynamic_engine_diagnostics.h:39
Scratchpad for storing CppAD automatic differentiation state for GraphEngine.
Definition engine_graph_scratchpad.h:83
Thread Safety
The StateBlob class is not thread-safe. Each thread should have its own StateBlob instance. Use clone_structure() to create independent copies for parallel workers. The cloned blob contains deep copies of all enrolled scratchpads.
See also
AbstractScratchPad
ScratchPadType