diff options
author | Erik Schnetter <schnetter@gmail.com> | 2012-04-28 16:11:59 -0400 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2012-09-11 18:23:16 +0100 |
commit | 36d17c974604151cfb236e5e5dacc50af180461f (patch) | |
tree | aaa8f4ec478810e761f4c2e3a53d3195db446088 /Carpet/CarpetLib/src/mem.cc | |
parent | 68361828d2cca3aeada6d23efdbf9b2952a8918a (diff) |
CarpetLib: Check whether grid functions are aligned
Check whether grid functions are aligned to multiples of a cache line.
Diffstat (limited to 'Carpet/CarpetLib/src/mem.cc')
-rw-r--r-- | Carpet/CarpetLib/src/mem.cc | 10 |
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) { |