diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2009-09-21 11:34:34 -0500 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2011-12-14 16:45:09 +0000 |
commit | c085bd77e10269a141fa00e27a92e36697589b96 (patch) | |
tree | fb65a95a0d8b427cb57767c0af1e5a670249cb05 /Carpet/CarpetLib/src/gdata.cc | |
parent | 0e7806cba5f78ac0b19bb93df919e84e95c1465b (diff) |
CarpetLib: Implement padding for grid variables
Ignore-this: 1a389f0dd3f40a0c0edb3fdabd6e7d40
Padding grid variables means that e.g. a component of size 32x32x32 is
allocated as 33x33x33 instead, but only 32x32x32 of this storage is
used. This can improve cache performance considerably. This requires
corresponding changes to the cGH entries.
Diffstat (limited to 'Carpet/CarpetLib/src/gdata.cc')
-rw-r--r-- | Carpet/CarpetLib/src/gdata.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc index e1888835c..4fa5e889f 100644 --- a/Carpet/CarpetLib/src/gdata.cc +++ b/Carpet/CarpetLib/src/gdata.cc @@ -64,6 +64,29 @@ gdata::~gdata () +// Storage management + +ivect +gdata:: +allocated_memory_shape (ibbox const& extent) +{ + DECLARE_CCTK_PARAMETERS; + ivect shape = max (ivect(0), extent.shape() / extent.stride()); + // Enlarge shape to avoid multiples of cache line colours + if (avoid_arraysize_bytes > 0) { + for (int d=0; d<dim; ++d) { + if (shape[d] > 0 and + shape[d] * sizeof(CCTK_REAL) % avoid_arraysize_bytes == 0) + { + ++shape[d]; + } + } + } + return shape; +} + + + // Data manipulators void |