Skip to content

Threading of post pre - #7201

Draft
hnil wants to merge 2 commits into
OPM:masterfrom
hnil:thread_post_pre
Draft

Threading of post pre#7201
hnil wants to merge 2 commits into
OPM:masterfrom
hnil:thread_post_pre

Conversation

@hnil

@hnil hnil commented Jun 24, 2026

Copy link
Copy Markdown
Member

This should thread the post pre at least to 2x. In norne it fixes a scaling problem + give better small serial improvement due to better tracer assembly.

hnil and others added 2 commits June 24, 2026 13:09
prepareLocalCellData's per-cell extractor walk is now parallelised over
ElementChunks with a per-thread ElementContext; the block-data extractors write
through pre-allocated per-cell slots so the walk stays race-free and
bit-identical. The region-average density extractor mutates shared
region-indexed storage, so it falls back to a single (serial) chunk via
GenericOutputBlackoilModule::requiresSerialExtraction().

calc_inplace's region sums now compute the independent per-quantity rank-local
sweeps in parallel (new regionSumLocal), keeping the MPI reduction and the
Inplace updates serial so the result is bit-identical across thread counts.

Verified bit-identical UNRST/INIT on spe9 and norne across 1/4/8 threads.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The ElementContext tracer assembly recomputes intensive/extensive quantities
per element; that recompute heap-allocates and serialises on the allocator under
threading, so it anti-scales (norne: 6.6 -> 12.4 s from 1 -> 8 threads) while the
matrix writes stay flat. assembleTracerEquationsTpfa_ instead reuses cached
intensive quantities plus the linearizer's neighbour/transmissibility table and
the ElementContext-free LocalResidual::computeFlux, mirroring the reservoir tpfa
assembly, and drops updateAllIntensive/ExtensiveQuantities().

Selected by --tracer-tpfa-assembly (default true); the ElementContext assembly
is kept and used automatically when the linearizer has no getNeighborInfo().

norne pre/post 15.2 -> 18.4 s (old, anti-scaling) becomes 12.9 -> 5.9 s (new).
Bit-identical UNRST on norne (standard + MSW); matches to last mantissa bits on
the vaporized-oil tracer decks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hnil hnil added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Jun 24, 2026
@hnil
hnil requested review from bska and totto82 June 24, 2026 11:39
@hnil
hnil marked this pull request as draft June 24, 2026 11:39
@totto82

totto82 commented Jun 24, 2026

Copy link
Copy Markdown
Member

Thanks. Speeding up is always good.

in norne it fixes a scaling problem

Can you explain? I didn't see that from the code

tracer assembly.

Why do you want to keep the old implementation and add a parameter?

@hnil

hnil commented Jun 25, 2026

Copy link
Copy Markdown
Member Author

At least on mac the was an anti calling with threading of the tracer code i.e. the code slowed down with opm process. I kept the old code since it may at some point or for some model be need to use the elemtctx (I do not have the full overview). It also in principle is more genneral.

@hnil

hnil commented Jun 25, 2026

Copy link
Copy Markdown
Member Author

Combing this with the linear solver part give. This the missing part is threading of amg. amgcl threads but is about the same final speed since original code is slower pga more iterations.
Screenshot 2026-06-25 at 13 44 39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants