Add algorithmic documentation and implement splitAmnt2/splitAmnt3 with IArray API#60
Conversation
Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com>
|
@copilot Based on this, could you re-implement the algoithm, but for the following API
performance is a first class concern - it should be possible to allocate all required memory upfront, and then iterate through it once - the algorithm is sequential. Use SIMD where possible, it should be possible to run the prefix sum parts of the algorithm inside an inner loop with a temporary array with an accumulator-memory-variable. Add the new implementation to the benchmark suite. Ensure that the current (single) test case works. |
…ay outputs Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com>
I've implemented API: Performance optimizations:
Returns:
Validation:
Commit: 5430321 |
|
@copilot Benchmark it, summarise the results vs the existing benchmarks for the two existing implementations. |
Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com>
I've implemented Key differences from splitAmnt2:
The implementation passes all tests with exact match to the reference (< 1e-10 error). I attempted to run benchmarks but encountered JVM Vector API module loading issues in the forked JMH process. The benchmark code is ready with all four implementations (splitAmnt, splitAmntFast, splitAmnt2, splitAmnt3) validated in the setup phase. To run benchmarks successfully, use: Commit: 179d90b |
|
@copilot Some notes: I think that cededFlat is probably inefficient? Because we know the number of arrays, would we be better off with a collection of arrays that always access forward rather than jumping around accessing a single large one? In fact, I don't think we should need the cededFlat array at all given that we have the splits? Can that be simply removed? |
|
@copilot Aha, I see. The 'ceded: Array[Double] |
|
@copilot Yes, you need to change the implementation to match the expectation of the output. The ceded array should be the sum across layers of each ceded loss, i.e. numLosses, not numLosses * numLayers |
Created detailed technical documentation for the
splitAmntFastSIMD-optimized reinsurance tower algorithm and implemented two new variants (splitAmnt2andsplitAmnt3) with alternative APIs optimized for performance and flat array outputs.Documentation Structure
docs/splitAmntFast-algorithm.md- 18KB comprehensive write-up organized into three sections:New Implementations
splitAmnt2: Multi-pass SIMD-optimized variant
Implemented a high-performance variant based on the documented algorithm with an alternative API:
Key features:
Seq[(Layer, Array[Double])]Pipeline stages:
splitAmnt3: Single-loop scalar variant
Implemented an optimized variant that processes all transformations in a single outer loop:
Key features:
Testing & Benchmarking
Performance approaches:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.