diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2007-05-27 19:09:00 +0000 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2007-05-27 19:09:00 +0000 |
commit | 6b46ed6da5e82d4722cd07f509196c63dc8789a2 (patch) | |
tree | 698f26dd04ecc46d506f8c970ccaa36e9915cd21 /Carpet/CarpetIOASCII | |
parent | e874fe1b4a230cbaad1b9c4959e9ecff59842662 (diff) |
CarpetIOASCII: Use a memory pool to allocate temporary storage
This should help reduce memory fragmentation, and may reduce overall
memory usage.
darcs-hash:20070527190935-dae7b-13cf6d4dfed18380184292dd98c1af7f4c246667.gz
Diffstat (limited to 'Carpet/CarpetIOASCII')
-rw-r--r-- | Carpet/CarpetIOASCII/src/ioascii.cc | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Carpet/CarpetIOASCII/src/ioascii.cc b/Carpet/CarpetIOASCII/src/ioascii.cc index 4305bfa7d..f47c7d060 100644 --- a/Carpet/CarpetIOASCII/src/ioascii.cc +++ b/Carpet/CarpetIOASCII/src/ioascii.cc @@ -1373,18 +1373,25 @@ namespace CarpetIOASCII { } else { // copy to processor 0 and output there - vector<const gdata*> tmps (gfdatas.size()); + mempool pool; + vector<gdata*> tmps (gfdatas.size()); for (size_t n=0; n<gfdatas.size(); ++n) { - gdata * const tmp = - gfdatas.at(n)->make_typed (vi, error_centered, op_sync); - tmp->allocate(gfdatas.at(n)->extent(), 0); - for (comm_state state; not state.done(); state.step()) { - tmp->copy_from (state, gfdatas.at(n), gfdatas.at(n)->extent()); + tmps.at(n) = gfdatas.at(n)->make_typed (vi, error_centered, op_sync); + void * const memptr = + pool.alloc (tmps.at(n)->allocsize (gfdatas.at(n)->extent(), ioproc)); + tmps.at(n)->allocate(gfdatas.at(n)->extent(), ioproc, memptr); + } + for (comm_state state; not state.done(); state.step()) { + for (size_t n=0; n<gfdatas.size(); ++n) { + tmps.at(n)->copy_from (state, gfdatas.at(n), gfdatas.at(n)->extent()); } - tmps.at(n) = tmp; } - WriteASCII (os, tmps, gfext, vi, time, org, dirs, rl, ml, m, c, tl, - coord_time, coord_lower, coord_upper); + vector<const gdata*> ctmps (gfdatas.size()); + for (size_t n=0; n<gfdatas.size(); ++n) { + ctmps.at(n) = tmps.at(n); + } + WriteASCII (os, ctmps, gfext, vi, time, org, dirs, rl, ml, m, c, tl, + coord_time, coord_lower, coord_upper); for (size_t n=0; n<gfdatas.size(); ++n) { delete tmps.at(n); } |