|
From: | Michael Riedl |
Subject: | Re: Dynamic mutidimensional arrays |
Date: | Wed, 5 Apr 2023 13:08:45 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 |
Hallo,
if you carefully desing that (esacially the loop structure around with (i>k>j) you will not have too much cache misses.
This under the assumtion that A and B represent one block of memory each, not that e.g. A^[i] is pointing to somewere and e.g. A^[i+1] to somewhere totally different. Then surely any cache pre-fetch will fail. If A and B are exteemly large a blocking implementation would help out anyway, but that is off-topic here.
Michael
Hi
On Wed, 5 Apr 2023 at 17:46, Fischlin Andreas <andreas.fischlin@env.ethz.ch> wrote:
Have you actually looked at LgMatrices? There is no such run time penalty from calling a procedure such as value(M, i,j). You simply write e.g.
val := A^[i]^[k] * B^[k]^[j];
But that will lead to unnecessary cache misses because of multiple levels of indirection.
If you have such an _expression_ deeply nested in a loop, these cache misses will add up and significantly impact performance.
It is better to allocate all metadata (such as length of a vector) and payload data together in a single memory block. This is called data locality.
regardsbenjamin
[Prev in Thread] | Current Thread | [Next in Thread] |