trixi-framework / trixi-framework/Trixi.jl

Taal: Use `resize!`able storage in trees/containers

Open
#205 1 comment 0 reactions 0 assignees View on GitHub
performance taal
Dominant language
Julia
Stars
731
Forks
166
Avg merge
2d 18h
Merged PRs (30d)
25

Description

Copying a conversation from Slack:

@sloede
> What Tamas proposed in https://discourse.julialang.org/t/resize-and-multidimensional-arrays/47842/4 is the way the Tree already uses right now:
> > If you need to resize a lot, just allocate a “large enough” array and keep track of the dimensions you use at the momene. You can wrap this in a struct and implement the AbstractArray interface very simply.
>
> Do you think this could be an option for us as well? After all, this is what many old-school Fortran/C/C++ simulation codes that use AMR do as well

In some sense, that's what we are currently doing. `resize!` et al. allocate more memory than currently required to make growing faster for future calls, cf. https://github.com/JuliaLang/julia/issues/31855. The relevant code is https://github.com/JuliaLang/julia/blob/master/src/array.c#L897-L905.

Would it be an option to switch to `Vector`s as basic storage, which can be `resize!`ed if necessary, and use `unsafe_wrap`ped `Array`s to interface with them?
This would remove the need to provide a capacity that's big enough. We should then implement `resize!` (and maybe `sizehint!` etc.) for these containers/trees.

@sloede:
> Yes, why not? Although I'd not switch right now unless there's a compelling reason but rather finish the current Taal porting first

So we should look into this once #200 is merged into `master`.

### Things to change
- [x] 1D containers
- [x] 2D containers
- [x] 3D containers
- [ ] tree

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.