Skip to content

fn naive backend: allocate temporaries without zero-initialization - #1835

Open
havogt wants to merge 1 commit into
GridTools:masterfrom
havogt:fn-naive-tmp-no-zero-fill
Open

havogt wants to merge 1 commit into
GridTools:masterfrom
havogt:fn-naive-tmp-no-zero-fill

Conversation

@havogt

@havogt havogt commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

The fn naive backend allocated temporaries with std::make_unique<char[]>, which value-initializes and therefore zero-fills every temporary, single-threaded, on every call. This replaces it with std::unique_ptr<char[]>(new char[n]) (std::make_unique_for_overwrite is C++20; GridTools requires C++17).

Nothing reads temporaries before writing them: the GPU fn backend already uses uninitialized cuda_malloc. As an extra check, all fn unit tests and fn naive regressions pass with every temporary poisoned to 0xFF bytes.

A side effect: pages are now first touched by the parallel stencil loops instead of the calling thread, which helps NUMA placement.

Measured from gt4py (gtfn CPU, 6 temporaries of 256×256×80 float64, laptop, with the double allocation of #1832 removed): 104 ms → 37 ms per call.

std::make_unique<char[]> value-initializes, which zero-fills every
temporary serially on each call.
@havogt

havogt commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Written by an agent on behalf of @havogt

@gridtoolsjenkins

Copy link
Copy Markdown
Collaborator

Hi there, this is jenkins continuous integration...
Do you want me to verify this patch?

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.

2 participants