Liste des Groupes | Revenir à cl c |
Lawrence D'Oliveiro <ldo@nz.invalid> wrote:Yes. Main memory accesses are slow - access to memory in caches is a lot less slow, but still slower than registers. If you need to use dynamic memory, the allocator will have to access a lot of different memory locations to figure out where to allocate the memory. Most of those will be in cache (assuming you are doing a lot of dynamic allocations), but some might not be. And the memory you allocate in the end might force more cache allocations and deallocations.On Thu, 26 Jun 2025 12:51:19 -0000 (UTC), Waldek Hebisch wrote:Did you measure things? CPU has caches and cache friendly code
>When working with such (low for me) precisions dynamic allocation of>
memory is major cost item, frequently more important than calculation.
To avoid this cost one needs stack allocatation.
What you may not realize is that, on current machines, there is about a
100:1 speed difference between accessing CPU registers and accessing main
memory.
>
Whether that main memory access is doing “stack allocation” or “heap
allocation” is going to make very little difference to this.
makes a difference. Avoiding dynamic allocation helps, that is
measurable. Rational explanation is that stack allocated things
do not move and have close to zero cost to manage. Moving stuff
leads to cache misses.
Les messages affichés proviennent d'usenet.