aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2012-04-28 16:11:59 -0400
committerErik Schnetter <schnetter@gmail.com>2012-04-28 16:11:59 -0400
commitcea113a6fc98c384003805d18193cbd415149ac9 (patch)
tree148152497fd6ad65cd5f5c28f8cd84eed80d2447
parent5f3eb785fe02bf2de752329bd70be0ad56d2cf7b (diff)
CarpetLib: Check whether grid functions are aligned
Check whether grid functions are aligned to multiples of a cache line.
-rw-r--r--Carpet/CarpetLib/src/mem.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/Carpet/CarpetLib/src/mem.cc b/Carpet/CarpetLib/src/mem.cc
index 27f86e951..23c0e574b 100644
--- a/Carpet/CarpetLib/src/mem.cc
+++ b/Carpet/CarpetLib/src/mem.cc
@@ -74,6 +74,16 @@ mem (size_t const vectorlength, size_t const nelems,
double(total_allocated_bytes/MEGA),
int(total_allocated_objects));
}
+ size_t const expected_pagesize = 4096;
+ size_t const min_alignment = 64;
+ if (nbytes >= expected_pagesize and (size_t)storage_ % min_alignment != 0) {
+ T Tdummy;
+ CCTK_VWarn (CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Allocated %.0f bytes (%.3f MB) of memory for type %s, but the result is not aligned to %d bytes",
+ double(nbytes), double(nbytes/MEGA),
+ typestring(Tdummy),
+ int(min_alignment));
+ }
total_allocated_bytes += nbytes;
max_allocated_bytes = max (max_allocated_bytes, total_allocated_bytes);
if (poison_new_memory) {