cubie.integrators.algorithms.genericIntegratorAlgorithm
Base class for integration algorithm implementations.
This module provides the GenericIntegratorAlgorithm class, which serves as the base class for all ODE integration algorithms. It handles building and caching of algorithm functions that are incorporated into CUDA kernels, and provides the interface that specific algorithms must implement.
Classes
|
Base class for the inner "loop" algorithm for ODE solving algorithms. |
- class cubie.integrators.algorithms.genericIntegratorAlgorithm.GenericIntegratorAlgorithm(precision, dxdt_function, buffer_sizes, loop_step_config, save_state_func, update_summaries_func, save_summaries_func, compile_flags)[source]
Bases:
CUDAFactory
Base class for the inner “loop” algorithm for ODE solving algorithms.
This class handles building and caching of the algorithm function, which is incorporated into a CUDA kernel for GPU execution. All integration algorithms (e.g. Euler, Runge-Kutta) should subclass this class and override specific attributes and methods.
- Parameters:
precision (type) – Numerical precision type for computations.
dxdt_function (CUDA device function) – Function that computes time derivatives of the state.
buffer_sizes (LoopBufferSizes) – Configuration object specifying buffer sizes.
loop_step_config (LoopStepConfig) – Configuration object for loop step parameters.
save_state_func (CUDA device function) – Function for saving state values during integration.
update_summaries_func (CUDA device function) – Function for updating summary statistics.
save_summaries_func (CUDA device function) – Function for saving summary statistics.
compile_flags (OutputCompileFlags) – Compilation flags for device function generation.
Notes
Subclasses must override:
_threads_per_loop : Number of threads the algorithm uses
build_loop() : Factory method that builds the CUDA device function
shared_memory_required : Amount of shared memory the device allocates
Data used in compiling and controlling the loop is handled by the IntegratorLoopSettings class. This class presents relevant attributes of the data class to higher-level components as properties.
See also
IntegratorLoopSettings
Configuration data for loop compilation
CUDAFactory
Base factory class for CUDA device functions
- build()[source]
Build the integrator loop, unpacking config for local scope.
- Returns:
The compiled integrator loop device function.
- Return type:
callable
- build_loop(precision, dxdt_function, save_state_func, update_summaries_func, save_summaries_func)[source]
Build the CUDA device function for the integration loop.
This is a template method that provides a dummy implementation. Subclasses should override this method to implement specific integration algorithms.
- Parameters:
precision (type) – Numerical precision type for the integration.
dxdt_function (callable) – Function that computes time derivatives.
save_state_func (callable) – Function for saving state values.
update_summaries_func (callable) – Function for updating summary statistics.
save_summaries_func (callable) – Function for saving summary statistics.
- Returns:
Compiled CUDA device function implementing the integration algorithm.
- Return type:
callable
Notes
This base implementation provides a dummy loop that can be used for testing but does not perform actual integration. Real algorithms should override this method with their specific implementation.
- property fixed_step_size
Get the fixed step size used in the integration loop.
- Returns:
The fixed step size from the compile settings.
- Return type:
- classmethod from_single_integrator_run(run_object)[source]
Create an instance of the integrator algorithm from a SingleIntegratorRun object.
- Parameters:
run_object (SingleIntegratorRun) – The SingleIntegratorRun object containing configuration parameters.
- Returns:
New instance of the integrator algorithm configured with parameters from the run object.
- Return type:
Calculate shared memory requirements for the integration algorithm.
This is a dummy implementation that returns 0. Subclasses should override this method to calculate the actual shared memory requirements based on their specific algorithm needs.
- Returns:
Number of shared memory elements required (dummy implementation returns 0).
- Return type:
- property threads_per_loop
Get the number of threads required by loop algorithm.
- Returns:
Number of threads required per integration loop.
- Return type:
- update(updates_dict=None, silent=False, **kwargs)[source]
Pass updates to compile settings through the CUDAFactory interface.
This method will invalidate the cache if an update is successful. Use silent=True when doing bulk updates with other component parameters to suppress warnings about unrecognized keys.
- Parameters:
- Returns:
Set of parameter names that were recognized and updated.
- Return type: