Skip to content

Allocate the per-cell material law parameters from an arena - #5288

Draft
hnil wants to merge 1 commit into
OPM:masterfrom
hnil:pr-pool-material-params
Draft

Allocate the per-cell material law parameters from an arena#5288
hnil wants to merge 1 commit into
OPM:masterfrom
hnil:pr-pool-material-params

Conversation

@hnil

@hnil hnil commented Aug 12, 2026

Copy link
Copy Markdown
Member

Each cell's nested material-law parameter object is a separate new behind its own shared_ptr control block. On Norne that is 44927 allocations of 304 B spread over 105.7 MB of address space for 13.7 MB of data. This adds makeArena()/arenaSlot() and a setApproach() overload taking externally owned storage, so the manager hands out aliasing pointers into one vector per parameter array — one allocation, one control block, fixed 304 B stride.

Draft because it is not a measured speedup. Norne relperm+pc, best of 5 alternating runs: 91.5 → 91.3 ns/cell in cell order, 112.4 → 111.7 shuffled. The allocator already returns long contiguous runs when the objects are built back to back, so only the allocation count and the address span change. Posting it because the layout is a precondition for anything that wants these objects as an array (SoA/GPU), not because it makes Norne faster today.

What does move the number on Norne is the size of these objects: padding them from 304 B to 1440 B — the size they reach once EHYSTR is active — costs +45 ns/cell in the same loop. That suggests splitting the Killough/WAG scalars out of EclHysteresisTwoPhaseLawParams is the change worth making; happy to drop this one if you would rather see only that.

All 228 opm-common tests pass.

EclMultiplexerMaterialParams::setApproach() allocates the nested parameter
object with a bare new, so a grid costs one allocation and one shared_ptr
control block per cell. On Norne that is 44927 allocations of 304 B spread
over 105.7 MB of address space for 13.7 MB of data.

Add makeArena()/arenaSlot() and a setApproach() overload taking externally
owned storage, and have the manager hand out aliasing pointers into one
vector per parameter array. The aliasing constructor shares the arena's
single control block, so the per-cell overhead drops to the pointer itself
and the objects land at a fixed 304 B stride.

This is not a measured speedup: on Norne the relperm+pc evaluation loop is
unchanged in cell order (91.5 -> 91.3 ns/cell, best of 5 alternating runs)
and at best 2-3% in shuffled order, which is inside the noise. The allocator
already hands out long contiguous runs when the objects are built back to
back. What changes is the allocation count and the address span.

All 228 opm-common tests pass.
@hnil hnil added the manual:enhancement This is an enhancement/improvent that needs to be documented in the manual label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:enhancement This is an enhancement/improvent that needs to be documented in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant