Previously the function put_atoms_in_box was called only by the
nblib integrator, or when constructing a system via a SimulationState
object. In the case of the integrator, this is a needless performance
degradation. When using an nb force calculator without
first putting atoms in the box, this could lead to a cryptic
error from nbnxm grid search failure. Both of these issues are
rectified with this change, which also adds a member to the
non-bonded force calculator to hold the requested number of OMP
threads to use in a call to put_atoms_in_box_omp, which is faster
than the non OMP version.
GmxBackendData(const NBKernelOptions& options,
int numEnergyGroups,
gmx::ArrayRef<int> exclusionRanges,
GmxBackendData(const NBKernelOptions& options,
int numEnergyGroups,
gmx::ArrayRef<int> exclusionRanges,
- gmx::ArrayRef<int> exclusionElements)
+ gmx::ArrayRef<int> exclusionElements) :
+ numThreads_(options.numOpenMPThreads)
{
// Set hardware params from the execution context
setGmxNonBondedNThreads(options.numOpenMPThreads);
{
// Set hardware params from the execution context
setGmxNonBondedNThreads(options.numOpenMPThreads);
//! Non-bonded flop counter; currently only needed as an argument for dispatchNonbondedKernel
t_nrnb nrnb_;
//! Non-bonded flop counter; currently only needed as an argument for dispatchNonbondedKernel
t_nrnb nrnb_;
+ //! Number of OpenMP threads to use
+ int numThreads_;
+
//! Keep track of whether updatePairlist has been called at least once
bool updatePairlistCalled{ false };
};
//! Keep track of whether updatePairlist has been called at least once
bool updatePairlistCalled{ false };
};
const NBKernelOptions& options);
//! calculates a new pair list based on new coordinates (for every NS step)
const NBKernelOptions& options);
//! calculates a new pair list based on new coordinates (for every NS step)
- void updatePairlist(gmx::ArrayRef<const gmx::RVec> coordinates, const Box& box);
+ void updatePairlist(gmx::ArrayRef<gmx::RVec> coordinates, const Box& box);
//! Compute forces and return
void compute(gmx::ArrayRef<const gmx::RVec> coordinateInput,
//! Compute forces and return
void compute(gmx::ArrayRef<const gmx::RVec> coordinateInput,
system_.nonBondedParams_);
}
system_.nonBondedParams_);
}
-void GmxNBForceCalculatorCpu::CpuImpl::updatePairlist(gmx::ArrayRef<const gmx::RVec> coordinates,
- const Box& box)
+void GmxNBForceCalculatorCpu::CpuImpl::updatePairlist(gmx::ArrayRef<gmx::RVec> coordinates, const Box& box)
{
if (coordinates.size() != system_.numParticles_)
{
{
if (coordinates.size() != system_.numParticles_)
{
const real particleDensity = static_cast<real>(coordinates.size()) / det(legacyBox);
const real particleDensity = static_cast<real>(coordinates.size()) / det(legacyBox);
+ // If particles are too far outside the box, the grid setup can fail
+ put_atoms_in_box_omp(PbcType::Xyz, box.legacyMatrix(), coordinates, backend_.numThreads_);
+
// Put particles on a grid based on bounds specified by the box
nbnxn_put_on_grid(backend_.nbv_.get(),
legacyBox,
// Put particles on a grid based on bounds specified by the box
nbnxn_put_on_grid(backend_.nbv_.get(),
legacyBox,
GmxNBForceCalculatorCpu::~GmxNBForceCalculatorCpu() = default;
//! calculates a new pair list based on new coordinates (for every NS step)
GmxNBForceCalculatorCpu::~GmxNBForceCalculatorCpu() = default;
//! calculates a new pair list based on new coordinates (for every NS step)
-void GmxNBForceCalculatorCpu::updatePairlist(gmx::ArrayRef<const gmx::RVec> coordinates, const Box& box)
+void GmxNBForceCalculatorCpu::updatePairlist(gmx::ArrayRef<gmx::RVec> coordinates, const Box& box)
{
impl_->updatePairlist(coordinates, box);
}
{
impl_->updatePairlist(coordinates, box);
}
~GmxNBForceCalculatorCpu();
//! calculates a new pair list based on new coordinates (for every NS step)
~GmxNBForceCalculatorCpu();
//! calculates a new pair list based on new coordinates (for every NS step)
- void updatePairlist(gmx::ArrayRef<const gmx::RVec> coordinates, const Box& box);
+ void updatePairlist(gmx::ArrayRef<gmx::RVec> coordinates, const Box& box);
//! Compute forces and return
void compute(gmx::ArrayRef<const gmx::RVec> coordinateInput,
//! Compute forces and return
void compute(gmx::ArrayRef<const gmx::RVec> coordinateInput,
+LeapFrog::LeapFrog(gmx::ArrayRef<const real> inverseMasses, const Box& box) :
+ inverseMasses_(inverseMasses.begin(), inverseMasses.end()), box_(box)
+{
+}
+
void LeapFrog::integrate(const real dt, gmx::ArrayRef<Vec3> x, gmx::ArrayRef<Vec3> v, gmx::ArrayRef<const Vec3> f)
{
for (size_t i = 0; i < x.size(); i++)
void LeapFrog::integrate(const real dt, gmx::ArrayRef<Vec3> x, gmx::ArrayRef<Vec3> v, gmx::ArrayRef<const Vec3> f)
{
for (size_t i = 0; i < x.size(); i++)
x[i][dim] += v[i][dim] * dt;
}
}
x[i][dim] += v[i][dim] * dt;
}
}
- put_atoms_in_box(PbcType::Xyz, box_.legacyMatrix(), x);
*/
LeapFrog(const Topology& topology, const Box& box);
*/
LeapFrog(const Topology& topology, const Box& box);
+ /*! \brief Constructor.
+ *
+ * \param[in] masses List of inverse masses.
+ * \param[in] box Box object for ensuring that coordinates remain within bounds
+ */
+ LeapFrog(gmx::ArrayRef<const real> inverseMasses, const Box& box);
+
/*! \brief Integrate
*
* Integrates the equation of motion using Leap-Frog algorithm.
/*! \brief Integrate
*
* Integrates the equation of motion using Leap-Frog algorithm.