2 years ago
#62252

GuillemVS
Where should I expect the Cache to be refilled? C
I just recently found out about cache misses, specifically when I was designing matrix multiplications.
Having this tiled code that multiplies a matrix and a vector:
void aiMatMulVec_raw(const mFloat *M, const mFloat *V, const size_t nSize, mFloat *W) {
for (size_t i = 0, k = min(i + nTile, nSize); i < nSize; i = k) {
memset(W + i, 0, (k - i) * sizeof(mFloat));
for (size_t j = 0, l = min(j + nTile, nSize); j < nSize; j = l)
for (size_t x = i; x < k; x++) {
mFloat value = 0.0f;
mFloat *mPtr = M + x * nSize;
for (size_t y = j; y < l; y++)
value += mPtr[y] * V[y];
W[x] += value;
};
};
};
The efficiency went up by a lot using this 4 loops, instead of 2, with large matrices; but I wanted to find the most efficient tile size. And when I looked up the Cache Line size of the process' mask, trying to come up with a function that determines a good tile size, these questions appeared:
Where should I expect a refill of the cache?
Should I consider
__builtin_prefetch
to best determine such thing?Does a cache block include multiple pointers (buffers) or only one?
c
matrix
cpu-cache
0 Answers
Your Answer