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 tabulated bond memory leaks #3961

Merged
merged 7 commits into from
Oct 24, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
core: Remove callback code duplication
jngrad committed Oct 20, 2020
commit 7c850673fa9d25b7c1736f383c449435f1f857c5
40 changes: 16 additions & 24 deletions src/core/communication.cpp
Original file line number Diff line number Diff line change
@@ -310,39 +310,31 @@ inline bool is_tabulated_bond(BondedInteraction const type) {
type == BONDED_IA_TABULATED_DIHEDRAL);
}

void mpi_bcast_ia_params(int i, int j) {
mpi_call(mpi_bcast_ia_params_slave, i, j);
REGISTER_CALLBACK(mpi_bcast_ia_params_slave)

if (j >= 0) {
/* non-bonded interaction parameters */
boost::mpi::broadcast(comm_cart, *get_ia_param(i, j), 0);
} else {
/* bonded interaction parameters */
MPI_Bcast(&(bonded_ia_params[i]), sizeof(Bonded_ia_parameters), MPI_BYTE, 0,
comm_cart);
/* For tabulated potentials we have to send the tables extra */
if (is_tabulated_bond(bonded_ia_params[i].type)) {
boost::mpi::broadcast(comm_cart, *bonded_ia_params[i].p.tab.pot, 0);
}
}

on_short_range_ia_change();
void mpi_bcast_ia_params(int i, int j) {
mpi_call_all(mpi_bcast_ia_params_slave, i, j);
}

void mpi_bcast_ia_params_slave(int i, int j) {
if (j >= 0) { /* non-bonded interaction parameters */

if (j >= 0) {
// non-bonded interaction parameters
boost::mpi::broadcast(comm_cart, *get_ia_param(i, j), 0);
} else { /* bonded interaction parameters */
make_bond_type_exist(i); /* realloc bonded_ia_params on slave nodes! */
if (is_tabulated_bond(bonded_ia_params[i].type)) {
delete bonded_ia_params[i].p.tab.pot;
} else {
// bonded interaction parameters
if (this_node) {
make_bond_type_exist(i); // realloc bonded_ia_params on slave nodes!
if (is_tabulated_bond(bonded_ia_params[i].type)) {
delete bonded_ia_params[i].p.tab.pot;
}
}
MPI_Bcast(&(bonded_ia_params[i]), sizeof(Bonded_ia_parameters), MPI_BYTE, 0,
comm_cart);
/* For tabulated potentials we have to send the tables extra */
// for tabulated potentials we have to send the tables extra
if (is_tabulated_bond(bonded_ia_params[i].type)) {
bonded_ia_params[i].p.tab.pot = new TabulatedPotential();
if (this_node) {
bonded_ia_params[i].p.tab.pot = new TabulatedPotential();
}
boost::mpi::broadcast(comm_cart, *bonded_ia_params[i].p.tab.pot, 0);
}
}