From e891286291c4d424906418c6820c9c7af5aa7e62 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 16 Nov 2022 01:43:49 +0100 Subject: [PATCH] `kernel_atax`: Add comments to the second iteration --- OpenMP/linear-algebra/kernels/atax/atax.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/OpenMP/linear-algebra/kernels/atax/atax.c b/OpenMP/linear-algebra/kernels/atax/atax.c index d467e34..4d37d54 100644 --- a/OpenMP/linear-algebra/kernels/atax/atax.c +++ b/OpenMP/linear-algebra/kernels/atax/atax.c @@ -69,17 +69,19 @@ static void kernel_atax(int nx, int ny, for (i = 0; i < _PB_NY; i++) y[i] = 0; - // TODO: Optimizable loop, no dependencies - // actually tmp[i] could be a local variable - for (i = 0; i < _PB_NX; i++) - tmp[i] = 0; - - // TODO: what do we do here? + /// This computes... something? I guess whatever ATAX is? + // Trying to parallelize this only seems to increase the time required for (i = 0; i < _PB_NX; i++) { + /// Every iteration has its own tmp variable + tmp[i] = 0; + for (j = 0; j < _PB_NY; j++) - tmp[i] = tmp[i] + A[i][j] * x[j]; + /// Which gets increased by a bit on every iteration + tmp[i] += A[i][j] * x[j]; + for (j = 0; j < _PB_NY; j++) + /// Which is later used for [something else] y[j] = y[j] + A[i][j] * tmp[i]; } }