185. MOVE_ALLOC may be faster than RESHAPE or allocation on assignment to resize an array.#
topic: Allocation
Note
This tip is a draft1.
Another way to grow an array is
x = reshape(x,[size(x)+size(new)],pad=new)
The code compares the speeds of move_alloc, reshape, and allocation on assignment in growing an array. Move_alloc was fastest for gfortran, but this is platform-dependent.
Another way to grow an array is
— FortranTip (@fortrantip) April 10, 2022
x = reshape(x,[size(x)+size(new)],pad=new)
The code compares the speeds of move_alloc, reshape, and allocation on assignment in growing an array. Move_alloc was fastest for gfortran, but this is platform-dependent.pic.twitter.com/LMVRYZXBnt
- 1
From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.