Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reeber double free #100

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 8 additions & 29 deletions Exec/LyA/ascent_actions.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
---
-
action: add_pipelines
pipelines:
slice:
f1:
params:
normal:
x: 0.0
? "y"
: 0.0
z: 1.0
point:
x: 0.0
? "y"
: 0.0
z: 0.0
topology: topo
type: exaslice
-
action: add_extracts
extracts:
e1:
type: volume
params:
field: xh
filename: xh_pic
e2:
type: volume
params:
fields:
- Density
- Xmom
- Ymom
- Zmom
- rho_E
- rho_e
path: the_slice
protocol: blueprint/mesh/hdf5
pipeline: slice
type: relay
field: density
filename: density_pic
2 changes: 1 addition & 1 deletion Source/IO/Nyx_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ Nyx::updateInSitu ()
#endif

#ifdef REEBER
amrex::Vector<Halo>& reeber_halos);
amrex::Vector<Halo> reeber_halos;
halo_find(parent->dtLevel(level), reeber_halos);
halo_print(reeber_halos);
#endif
Expand Down
17 changes: 12 additions & 5 deletions Util/reeber/src/reeber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void prepare_master_reader(
int finest_level,
const Vector<IntVect>& level_refinements,
const amrex::Geometry geom_in,
std::vector<std::unique_ptr<Real[]>>& pointers_to_copied_data)
std::vector<Real*>& pointers_to_copied_data)
{
std::vector<std::string> new_state_vars { "density", "xmom", "ymom", "zmom" };
const size_t density_var_idx = 0;
Expand Down Expand Up @@ -227,7 +227,10 @@ void prepare_master_reader(
gid_to_fab_size[gid] = core_fab_size;

pointers_to_copied_data.emplace_back(new Real[core_fab_size]);
Real* core_fab_ptr = pointers_to_copied_data.back().get();
// Real* core_fab_ptr = pointers_to_copied_data.back().get();

// HACK: use raw pointer to avoid double free
Real* core_fab_ptr = pointers_to_copied_data.back();

GridRef core_grid_ref(core_fab_ptr, core_shape, false);

Expand Down Expand Up @@ -266,7 +269,10 @@ void prepare_master_reader(

// reserve memory for dm_density
pointers_to_copied_data.emplace_back(new Real[core_fab_size]);
Real* extra_ptr_copy = pointers_to_copied_data.back().get();
// Real* extra_ptr_copy = pointers_to_copied_data.back().get();

// HACK: use raw pointer to avoid double free
Real* extra_ptr_copy = pointers_to_copied_data.back();
extra_pointers.push_back(extra_ptr_copy);

// reserve memory for variables in new_state
Expand Down Expand Up @@ -430,7 +436,7 @@ std::vector<Halo> compute_halos(diy::mpi::communicator& world,
new Block(b->fab, b->extra_names_, b->extra_fabs_, local_ref, local_lev, diy_domain,
l->bounds(),
l->core(), cp.gid(),
new_link, absolute_rho, negate, /*absolute = */ true, cell_volume),
new_link, absolute_rho, negate, /* wrap = */ true, /*absolute = */ true, cell_volume),
new_link);

//if (debug) fmt::print(std::cerr, "Added block gid = {}\n", cp.gid());
Expand Down Expand Up @@ -571,7 +577,8 @@ void Nyx::runReeberAnalysis(Vector<MultiFab*>& new_state,

// store pointers to all dynamically allocated arrays, so that
// data will be freed automatically after exiting compute_halos
std::vector<std::unique_ptr<Real[]>> pointers_to_copied_data;
// std::vector<std::unique_ptr<Real[]>> pointers_to_copied_data;
std::vector<Real*> pointers_to_copied_data; // HACK: avoid double free

diy::mpi::communicator world = ParallelDescriptor::Communicator();

Expand Down