Skip to content

Remove allocator traffic from the hot vertex loop by computing phi via Phi_of_field - #651

Open
sashagavrishev wants to merge 2 commits into
ALF-QMC:masterfrom
sashagavrishev:feature/op-phi-no-alloc
Open

sashagavrishev wants to merge 2 commits into
ALF-QMC:masterfrom
sashagavrishev:feature/op-phi-no-alloc

Conversation

@sashagavrishev

@sashagavrishev sashagavrishev commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

This short change which addresses an inefficiency highlighted by @johanneshofmann87 in #646; this PR is also designed to merge cleanly with #646.

In Operator_mod.F90 The routines Op_Wrapup and Op_Wrapdo sit in the hot loop of the sequential field updates; Op_mmultL, Op_mmultR run for every operator on every time slice when building the propagation matrices. Each call builds a one-entry Fields object just to read φ for a single HS field value, which appears as

ALF/Prog/Operator_mod.F90

Lines 569 to 571 in f81b5cb

Call nsigma_single%make(1,1)
nsigma_single%f(1,1) = HS_field
nsigma_single%t(1) = op%type
in these Op_* routines. Therefore we get three heap allocations and their deallocations per call
allocate (this%f(N_OP,N_tau), this%t(N_OP), this%Flip_protocol(N_OP) )
, and the type-bound %phi is looked up repeatedly on every loop iteration, e.g.
call ZSCAL(N1,conjg(exp(sign*nsigma_single%phi(1,1)*Op%g_t(nt)*Op%E(I))),Mat(1,Op%P(I)),1)
.

Instead, this PR adds Phi_of_field to Fields_mod.F90 and makes Fields_Phi call it. The four routines now compute φ once per call into a local phi_loc, so the loop no longer touches the allocator.

There is no actual change to the calculation, so the results should be identical.

sashagavrishev added a commit to sashagavrishev/ALF that referenced this pull request Sep 29, 2026
sashagavrishev added a commit to sashagavrishev/ALF that referenced this pull request Sep 29, 2026
Takes the delayed-update files from the pull-request branch as they now
stand: delay_resolve resolves the depth once, auto can keep the immediate
update and logs it beside the probed depths, a fixed depth is capped at
Ndim, and the panels are sized by Op%N_non_zero. Tests 40-43 and a
Z2_Matter set for the delayed-vs-immediate check come with them.

Operator_mod keeps ALF-QMC#651's Phi_of_field reads and gains the same in
Op_Wrap_panels; its docstring now matches the PR. CHANGELOG keeps the
fork-local NBin/CPU_MAX entry.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant