This fixes an incorrect delete issue in free energy runs.
Change-Id: Ib247c6eaa98807fe3abe2fcefd09d8509d6b8598
const int forceFlags,
t_nrnb *nrnb)
{
- const gmx::ArrayRef<t_nblist const * const > nbl_fep = pairlistSets().pairlistSet(iLocality).fepLists();
+ const auto nbl_fep = pairlistSets().pairlistSet(iLocality).fepLists();
/* When the first list is empty, all are empty and there is nothing to do */
if (!pairlistSets().params().haveFep || nbl_fep[0]->nrj == 0)
{
try
{
- gmx_nb_free_energy_kernel(nbl_fep[th],
+ gmx_nb_free_energy_kernel(nbl_fep[th].get(),
x, f, fr, &mdatoms, &kernel_data, nrnb);
}
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
{
try
{
- gmx_nb_free_energy_kernel(nbl_fep[th],
+ gmx_nb_free_energy_kernel(nbl_fep[th].get(),
x, f, fr, &mdatoms, &kernel_data, nrnb);
}
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
* master thread (but all contained list memory thread local)
* impacts performance.
*/
- snew(fepLists_[i], 1);
- nbnxn_init_pairlist_fep(fepLists_[i]);
+ fepLists_[i] = std::make_unique<t_nblist>();
+ nbnxn_init_pairlist_fep(fepLists_[i].get());
}
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
}
}
}
-static void balance_fep_lists(gmx::ArrayRef<t_nblist *> fepLists,
- gmx::ArrayRef<PairsearchWork> work)
+static void balance_fep_lists(gmx::ArrayRef < std::unique_ptr < t_nblist>> fepLists,
+ gmx::ArrayRef<PairsearchWork> work)
{
const int numLists = fepLists.ssize();
/* Count the total i-lists and pairs */
int nri_tot = 0;
int nrj_tot = 0;
- for (auto list : fepLists)
+ for (const auto &list : fepLists)
{
nri_tot += list->nri;
nrj_tot += list->nrj;
t_nblist *nbld = work[th_dest].nbl_fep.get();
for (int th = 0; th < numLists; th++)
{
- t_nblist *nbls = fepLists[th];
+ const t_nblist *nbls = fepLists[th].get();
for (int i = 0; i < nbls->nri; i++)
{
/* Swap the list pointers */
for (int th = 0; th < numLists; th++)
{
- t_nblist *nbl_tmp = work[th].nbl_fep.release();
- work[th].nbl_fep.reset(fepLists[th]);
- fepLists[th] = nbl_tmp;
+ fepLists[th].swap(work[th].nbl_fep);
if (debug)
{
if (params_.haveFep)
{
- clear_pairlist_fep(fepLists_[th]);
+ clear_pairlist_fep(fepLists_[th].get());
}
}
work.cycleCounter.start();
- t_nblist *fepListPtr = (fepLists_.empty() ? nullptr : fepLists_[th]);
+ t_nblist *fepListPtr = (fepLists_.empty() ? nullptr : fepLists_[th].get());
/* Divide the i cells equally over the pairlists */
if (isCpuType_)
#ifndef GMX_NBNXM_PAIRLISTSET_H
#define GMX_NBNXM_PAIRLISTSET_H
+#include <memory>
+
#include "gromacs/math/vectypes.h"
#include "gromacs/nbnxm/pairlist.h"
#include "gromacs/utility/basedefinitions.h"
}
//! Returns the lists of free-energy pairlists, empty when nonbonded interactions are not perturbed
- gmx::ArrayRef<t_nblist const * const> fepLists() const
+ gmx::ArrayRef < const std::unique_ptr < t_nblist>> fepLists() const
{
return fepLists_;
}
//! Tells whether the lists is of CPU type, otherwise GPU type
gmx_bool isCpuType_;
//! Lists for perturbed interactions in simple atom-atom layout
- std::vector<t_nblist *> fepLists_;
+ std::vector < std::unique_ptr < t_nblist>> fepLists_;
public:
/* Pair counts for flop counting */