DiffEq - Modern C++ ODE Integration Library 1.0.0
High-performance C++ library for solving ODEs with async signal processing
Loading...
Searching...
No Matches
diffeq::core::composable::ParallelDecorator< S > Class Template Reference

Parallel execution decorator - adds batch processing to any integrator. More...

#include <parallel_decorator.hpp>

Inheritance diagram for diffeq::core::composable::ParallelDecorator< S >:
Collaboration diagram for diffeq::core::composable::ParallelDecorator< S >:

Public Member Functions

 ParallelDecorator (std::unique_ptr< AbstractIntegrator< S > > integrator, ParallelConfig config={})
 Construct parallel decorator.
 
template<typename StateRange >
void integrate_batch (StateRange &&states, typename IntegratorDecorator< S >::time_type dt, typename IntegratorDecorator< S >::time_type end_time)
 Integrate multiple states in parallel.
 
template<typename Generator , typename Processor >
auto integrate_monte_carlo (size_t num_simulations, Generator &&generator, Processor &&processor, typename IntegratorDecorator< S >::time_type dt, typename IntegratorDecorator< S >::time_type end_time)
 Monte Carlo integration with parallel execution.
 
template<typename StateRange >
void integrate_batch_chunked (StateRange &&states, typename IntegratorDecorator< S >::time_type dt, typename IntegratorDecorator< S >::time_type end_time)
 Chunked parallel processing with load balancing.
 
ParallelConfigconfig ()
 Access and modify parallel configuration.
 
const ParallelConfigconfig () const
 
void update_config (ParallelConfig new_config)
 Update parallel configuration with validation.
 
size_t get_optimal_thread_count () const
 Get optimal number of threads for current configuration.
 
- Public Member Functions inherited from diffeq::core::composable::IntegratorDecorator< S >
 IntegratorDecorator (std::unique_ptr< base_type > integrator)
 Construct decorator wrapping another integrator.
 
virtual ~IntegratorDecorator ()=default
 Virtual destructor for proper cleanup.
 
void step (state_type &state, time_type dt) override
 
void integrate (state_type &state, time_type dt, time_type end_time) override
 
time_type current_time () const override
 
void set_time (time_type t) override
 
void set_system (system_function sys) override
 
base_typewrapped ()
 Access to wrapped integrator for advanced use.
 
const base_typewrapped () const
 
bool has_wrapped_integrator () const
 Check if wrapped integrator exists.
 
- Public Member Functions inherited from diffeq::core::AbstractIntegrator< S >
 AbstractIntegrator (system_function sys)
 
time_type current_time () const
 
void set_time (time_type t)
 
void set_system (system_function sys)
 

Additional Inherited Members

- Public Types inherited from diffeq::core::composable::IntegratorDecorator< S >
using base_type = AbstractIntegrator< S >
 
using state_type = typename base_type::state_type
 
using time_type = typename base_type::time_type
 
using system_function = typename base_type::system_function
 
- Public Types inherited from diffeq::core::AbstractIntegrator< S >
using state_type = S
 
using time_type = typename S::value_type
 
using value_type = typename S::value_type
 
using system_function = std::function< void(time_type, const state_type &, state_type &)>
 
- Protected Member Functions inherited from diffeq::core::AbstractIntegrator< S >
void advance_time (time_type dt)
 
- Protected Attributes inherited from diffeq::core::composable::IntegratorDecorator< S >
std::unique_ptr< base_typewrapped_integrator_
 
- Protected Attributes inherited from diffeq::core::AbstractIntegrator< S >
system_function sys_
 
time_type current_time_
 

Detailed Description

template<system_state S>
class diffeq::core::composable::ParallelDecorator< S >

Parallel execution decorator - adds batch processing to any integrator.

This decorator provides parallel execution capabilities with the following features:

  • Batch processing of multiple states
  • Monte Carlo simulation support
  • Automatic load balancing and chunking
  • Thread-safe execution with proper resource management

Key Design Principles:

  • Single Responsibility: ONLY handles parallel execution
  • No Dependencies: Works with any integrator type
  • Scalable: Automatic hardware utilization
  • Safe: Thread-safe with proper error handling

Note: This decorator requires integrator factory support for thread-local copies.

Definition at line 75 of file parallel_decorator.hpp.

Constructor & Destructor Documentation

◆ ParallelDecorator()

template<system_state S>
diffeq::core::composable::ParallelDecorator< S >::ParallelDecorator ( std::unique_ptr< AbstractIntegrator< S > >  integrator,
ParallelConfig  config = {} 
)
inlineexplicit

Construct parallel decorator.

Parameters
integratorThe integrator to wrap
configParallel configuration (validated on construction)
Exceptions
std::invalid_argumentif config is invalid

Definition at line 86 of file parallel_decorator.hpp.

Member Function Documentation

◆ config() [1/2]

Access and modify parallel configuration.

Definition at line 267 of file parallel_decorator.hpp.

◆ config() [2/2]

template<system_state S>
const ParallelConfig & diffeq::core::composable::ParallelDecorator< S >::config ( ) const
inline

Definition at line 268 of file parallel_decorator.hpp.

◆ get_optimal_thread_count()

template<system_state S>
size_t diffeq::core::composable::ParallelDecorator< S >::get_optimal_thread_count ( ) const
inline

Get optimal number of threads for current configuration.

Definition at line 283 of file parallel_decorator.hpp.

◆ integrate_batch()

template<system_state S>
template<typename StateRange >
void diffeq::core::composable::ParallelDecorator< S >::integrate_batch ( StateRange &&  states,
typename IntegratorDecorator< S >::time_type  dt,
typename IntegratorDecorator< S >::time_type  end_time 
)
inline

Integrate multiple states in parallel.

Template Parameters
StateRangeRange type containing states to integrate
Parameters
statesRange of states to integrate
dtTime step
end_timeFinal integration time
Exceptions
std::runtime_errorif integrator copying is not implemented

Definition at line 110 of file parallel_decorator.hpp.

Here is the caller graph for this function:

◆ integrate_batch_chunked()

template<system_state S>
template<typename StateRange >
void diffeq::core::composable::ParallelDecorator< S >::integrate_batch_chunked ( StateRange &&  states,
typename IntegratorDecorator< S >::time_type  dt,
typename IntegratorDecorator< S >::time_type  end_time 
)
inline

Chunked parallel processing with load balancing.

Template Parameters
StateRangeRange type containing states
Parameters
statesRange of states to integrate
dtTime step
end_timeFinal integration time

Definition at line 223 of file parallel_decorator.hpp.

Here is the call graph for this function:

◆ integrate_monte_carlo()

template<system_state S>
template<typename Generator , typename Processor >
auto diffeq::core::composable::ParallelDecorator< S >::integrate_monte_carlo ( size_t  num_simulations,
Generator &&  generator,
Processor &&  processor,
typename IntegratorDecorator< S >::time_type  dt,
typename IntegratorDecorator< S >::time_type  end_time 
)
inline

Monte Carlo integration with parallel execution.

Template Parameters
GeneratorFunction that generates initial states: state_type(size_t)
ProcessorFunction that processes final states: result_type(const state_type&)
Parameters
num_simulationsNumber of Monte Carlo simulations
generatorFunction to generate initial states
processorFunction to process final states
dtTime step
end_timeFinal integration time
Returns
Vector of processed results
Exceptions
std::runtime_errorif integrator copying is not implemented

Definition at line 163 of file parallel_decorator.hpp.

◆ update_config()

template<system_state S>
void diffeq::core::composable::ParallelDecorator< S >::update_config ( ParallelConfig  new_config)
inline

Update parallel configuration with validation.

Parameters
new_configNew configuration
Exceptions
std::invalid_argumentif new config is invalid

Definition at line 275 of file parallel_decorator.hpp.

Here is the call graph for this function:

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