Repository navigation
Conversation
allocate() called the allocation functor twice and used only the second buffer; the first one was freed right away.
Collaborator
|
Hi there, this is jenkins continuous integration... |
egparedes
marked this pull request as ready for review
November 27, 2026 07:46
Contributor
Author
|
@havogt can you take a look at this? |
fthaler
approved these changes
Nov 30, 2026
Contributor
|
cscs-ci run |
1 similar comment
|
cscs-ci run |
This was referenced Dec 3, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
allocateinsid::allocator(include/gridtools/sid/allocator.hpp) calls the allocation functor twice and only keeps the second result:ptris never used. Everyallocatecall therefore requests two buffers from the functor and releases the unused one when it returns. This PR removes the first line.The effect depends on the allocator:
fnbackend (plainsid::allocatoroverstd::make_unique<char[]>): the change removes one allocation and one zero-fill per temporary per call.cached_allocator(GPUfnbackend,cpu_kfirstandcpu_ifirststencil backends): the discarded buffer was returned to the cache, so the change saves an extra cached buffer per temporary size rather than time.How it was observed
Observed on a GT4Py
gtfn_cpuprogram:straceshowed twommap/munmappairs of the temporary's size per call.Testing
test_sid_allocator, which counts the calls of the allocation functor. Without the fix it fails (2 calls for oneallocate), with the fix it passes.test_sid_*unit tests,test_tmp_storage_sid_cpu_ifirst,test_fn_{backend_naive,cartesian,executor,run,unstructured}, thefnnaive regressionscartesian_horizontal_diffusion,cartesian_vertical_advection,tridiagonal_solveandunstructured_nabla, andhorizontal_diffusionwithnaive,cpu_kfirstandcpu_ifirst.Possible follow-up (not part of this PR)
The CPU
fnbackend allocates withstd::make_unique<char[]>, which value-initializes the buffer, so the remaining allocation is still zero-filled. Using an allocation that leaves the buffer uninitialized would avoid that, but it changes behavior and is better discussed separately.🤖 Written by an agent on my behalf.