From b4277735d56ae023bd52bc19214d5a6280ce932f Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 9 Feb 2013 11:09:05 -0500 Subject: LoopControl: Share cache lines for SMT threads --- Carpet/LoopControl/src/loopcontrol.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Carpet/LoopControl') diff --git a/Carpet/LoopControl/src/loopcontrol.cc b/Carpet/LoopControl/src/loopcontrol.cc index 50672cded..95165e754 100644 --- a/Carpet/LoopControl/src/loopcontrol.cc +++ b/Carpet/LoopControl/src/loopcontrol.cc @@ -465,17 +465,17 @@ void lc_control_init(lc_control_t* restrict const control, } // Parameters (all in units of grid points) - // TODO: put fine threads into i direction, so that they share cache - // lines ptrdiff_t smt_size[LC_DIM] = { 1, 1, 1 }; { int const num_fine_threads = get_num_fine_threads(); - if (num_fine_threads <= loopsize_j) { + // If possible, stagger fine threads in the i direction, so that + // they share cache lines + if (istr * num_fine_threads <= loopsize_i) { + smt_size[0] = num_fine_threads; + } else if (num_fine_threads <= loopsize_j) { smt_size[1] = num_fine_threads; - } else if (num_fine_threads <= loopsize_k) { - smt_size[2] = num_fine_threads; } else { - smt_size[0] = num_fine_threads; + smt_size[2] = num_fine_threads; } } ptrdiff_t const tile_size[LC_DIM] = { -- cgit v1.2.3