aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/data.cc
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2009-09-21 11:34:34 -0500
committerBarry Wardell <barry.wardell@gmail.com>2011-12-14 16:45:09 +0000
commitc085bd77e10269a141fa00e27a92e36697589b96 (patch)
treefb65a95a0d8b427cb57767c0af1e5a670249cb05 /Carpet/CarpetLib/src/data.cc
parent0e7806cba5f78ac0b19bb93df919e84e95c1465b (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/data.cc')
-rw-r--r--Carpet/CarpetLib/src/data.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/Carpet/CarpetLib/src/data.cc b/Carpet/CarpetLib/src/data.cc
index da32ee4ea..9482ad518 100644
--- a/Carpet/CarpetLib/src/data.cc
+++ b/Carpet/CarpetLib/src/data.cc
@@ -336,15 +336,20 @@ void data<T>::allocate (const ibbox& extent_,
assert (all(extent_.lower() > numeric_limits<int>::min() / 2));
assert (all(extent_.upper() < numeric_limits<int>::max() / 2));
assert (all(extent_.upper() > numeric_limits<int>::min() / 2));
+
// data
_extent = extent_;
- _shape = max(ivect(0), _extent.shape() / _extent.stride());
+ //_shape = max (ivect(0), _extent.shape() / _extent.stride());
+ _shape = allocated_memory_shape (_extent);
+ assert (all (_shape >= max (ivect(0), _extent.shape() / _extent.stride())));
+
_size = 1;
for (int d=0; d<dim; ++d) {
_stride[d] = _size;
assert (_shape[d]==0 or _size <= numeric_limits<int>::max() / _shape[d]);
_size *= _shape[d];
}
+
_proc = proc_;
if (dist::rank() == _proc) {
if (vectorindex == 0) {
@@ -380,7 +385,9 @@ size_t data<T>::allocsize (const ibbox & extent_, const int proc_) const
if (dist::rank() != proc_) return 0;
if (vectorindex != 0) return 0;
assert (not vectorleader);
- return vectorlength * extent_.size() * sizeof (T);
+ ivect const shape_ = allocated_memory_shape (extent_);
+ //return vectorlength * extent_.size() * sizeof (T);
+ return vectorlength * prod(shape_) * sizeof (T);
}