Merge pull request #26 from timattox/USER-DPD_GBhacks_optimize
Reduce memory churn in several files
This commit is contained in:
@ -79,6 +79,17 @@ FixRxKokkos<DeviceType>::~FixRxKokkos()
|
||||
{
|
||||
//printf("Inside FixRxKokkos::~FixRxKokkos copymode= %d\n", copymode);
|
||||
if (copymode) return;
|
||||
|
||||
if (localTempFlag)
|
||||
memory->destroy_kokkos(k_dpdThetaLocal, dpdThetaLocal);
|
||||
|
||||
memory->destroy_kokkos(k_sumWeights, sumWeights);
|
||||
//memory->destroy_kokkos(k_sumWeights);
|
||||
|
||||
//delete [] scratchSpace;
|
||||
memory->destroy_kokkos(d_scratchSpace);
|
||||
|
||||
memory->destroy_kokkos(k_cutsq);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -1433,9 +1444,12 @@ void FixRxKokkos<DeviceType>::solve_reactions(const int vflag, const bool isPreF
|
||||
{
|
||||
const int count = nlocal + (newton_pair ? nghost : 0);
|
||||
|
||||
memory->create_kokkos (k_dpdThetaLocal, dpdThetaLocal, count, "FixRxKokkos::dpdThetaLocal");
|
||||
this->d_dpdThetaLocal = k_dpdThetaLocal.d_view;
|
||||
this->h_dpdThetaLocal = k_dpdThetaLocal.h_view;
|
||||
if (count > k_dpdThetaLocal.d_view.dimension_0()) {
|
||||
memory->destroy_kokkos (k_dpdThetaLocal, dpdThetaLocal);
|
||||
memory->create_kokkos (k_dpdThetaLocal, dpdThetaLocal, count, "FixRxKokkos::dpdThetaLocal");
|
||||
this->d_dpdThetaLocal = k_dpdThetaLocal.d_view;
|
||||
this->h_dpdThetaLocal = k_dpdThetaLocal.h_view;
|
||||
}
|
||||
|
||||
const int neighflag = lmp->kokkos->neighflag;
|
||||
|
||||
@ -1527,7 +1541,10 @@ void FixRxKokkos<DeviceType>::solve_reactions(const int vflag, const bool isPreF
|
||||
//double *scratchSpace = new double[ scratchSpaceSize * nlocal ];
|
||||
|
||||
//typename ArrayTypes<DeviceType>::t_double_1d d_scratchSpace("d_scratchSpace", scratchSpaceSize * nlocal);
|
||||
memory->create_kokkos (d_scratchSpace, nlocal*scratchSpaceSize, "FixRxKokkos::d_scratchSpace");
|
||||
if (nlocal*scratchSpaceSize > d_scratchSpace.dimension_0()) {
|
||||
memory->destroy_kokkos (d_scratchSpace);
|
||||
memory->create_kokkos (d_scratchSpace, nlocal*scratchSpaceSize, "FixRxKokkos::d_scratchSpace");
|
||||
}
|
||||
|
||||
#if 0
|
||||
Kokkos::parallel_reduce( nlocal, LAMMPS_LAMBDA(int i, CounterType &counter)
|
||||
@ -1630,9 +1647,6 @@ void FixRxKokkos<DeviceType>::solve_reactions(const int vflag, const bool isPreF
|
||||
Kokkos::parallel_reduce( Kokkos::RangePolicy<DeviceType, Tag_FixRxKokkos_solveSystems<false> >(0,nlocal), *this, TotalCounters);
|
||||
#endif
|
||||
|
||||
//delete [] scratchSpace;
|
||||
memory->destroy_kokkos (d_scratchSpace);
|
||||
|
||||
TimerType timer_ODE = getTimeStamp();
|
||||
|
||||
// Check the error flag for any failures.
|
||||
@ -1651,9 +1665,6 @@ void FixRxKokkos<DeviceType>::solve_reactions(const int vflag, const bool isPreF
|
||||
|
||||
atomKK->modified ( Host, DVECTOR_MASK );
|
||||
|
||||
if (localTempFlag)
|
||||
memory->destroy_kokkos(k_dpdThetaLocal, dpdThetaLocal);
|
||||
|
||||
TimerType timer_stop = getTimeStamp();
|
||||
|
||||
double time_ODE = getElapsedTime(timer_localTemperature, timer_ODE);
|
||||
@ -2012,8 +2023,11 @@ void FixRxKokkos<DeviceType>::computeLocalTemperature()
|
||||
const int ntypes = atom->ntypes;
|
||||
|
||||
//memory->create_kokkos (k_cutsq, h_cutsq, ntypes+1, ntypes+1, "pair:cutsq");
|
||||
memory->create_kokkos (k_cutsq, ntypes+1, ntypes+1, "FixRxKokkos::k_cutsq");
|
||||
d_cutsq = k_cutsq.template view<DeviceType>();
|
||||
if (ntypes+1 > k_cutsq.dimension_0()) {
|
||||
memory->destroy_kokkos (k_cutsq);
|
||||
memory->create_kokkos (k_cutsq, ntypes+1, ntypes+1, "FixRxKokkos::k_cutsq");
|
||||
d_cutsq = k_cutsq.template view<DeviceType>();
|
||||
}
|
||||
|
||||
for (int i = 1; i <= ntypes; ++i)
|
||||
for (int j = i; j <= ntypes; ++j)
|
||||
@ -2030,9 +2044,12 @@ void FixRxKokkos<DeviceType>::computeLocalTemperature()
|
||||
int sumWeightsCt = nlocal + (NEWTON_PAIR ? nghost : 0);
|
||||
|
||||
//memory->create_kokkos (k_sumWeights, sumWeights, sumWeightsCt, "FixRxKokkos::sumWeights");
|
||||
memory->create_kokkos (k_sumWeights, sumWeightsCt, "FixRxKokkos::sumWeights");
|
||||
d_sumWeights = k_sumWeights.d_view;
|
||||
h_sumWeights = k_sumWeights.h_view;
|
||||
if (sumWeightsCt > k_sumWeights.d_view.dimension_0()) {
|
||||
memory->destroy_kokkos(k_sumWeights, sumWeights);
|
||||
memory->create_kokkos (k_sumWeights, sumWeightsCt, "FixRxKokkos::sumWeights");
|
||||
d_sumWeights = k_sumWeights.d_view;
|
||||
h_sumWeights = k_sumWeights.h_view;
|
||||
}
|
||||
|
||||
// Initialize the accumulator to zero ...
|
||||
//Kokkos::parallel_for (sumWeightsCt,
|
||||
@ -2165,11 +2182,6 @@ void FixRxKokkos<DeviceType>::computeLocalTemperature()
|
||||
Kokkos::parallel_for (Kokkos::RangePolicy<DeviceType, Tag_FixRxKokkos_2ndPairOperator<WT_FLAG, LOCAL_TEMP_FLAG> >(0, nlocal), *this);
|
||||
#endif
|
||||
|
||||
// Clean up the local kokkos data.
|
||||
//memory->destroy_kokkos(k_cutsq, h_cutsq);
|
||||
memory->destroy_kokkos(k_cutsq);
|
||||
//memory->destroy_kokkos(k_sumWeights, sumWeights);
|
||||
memory->destroy_kokkos(k_sumWeights);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -180,10 +180,12 @@ void PairMultiLucyRXKokkos<DeviceType>::compute_style(int eflag_in, int vflag_in
|
||||
|
||||
{
|
||||
const int ntotal = nlocal + nghost;
|
||||
d_mixWtSite1old = typename AT::t_float_1d("PairMultiLucyRX::mixWtSite1old",ntotal);
|
||||
d_mixWtSite2old = typename AT::t_float_1d("PairMultiLucyRX::mixWtSite2old",ntotal);
|
||||
d_mixWtSite1 = typename AT::t_float_1d("PairMultiLucyRX::mixWtSite1",ntotal);
|
||||
d_mixWtSite2 = typename AT::t_float_1d("PairMultiLucyRX::mixWtSite2",ntotal);
|
||||
if (ntotal > d_mixWtSite1.dimension_0()) {
|
||||
d_mixWtSite1old = typename AT::t_float_1d("PairMultiLucyRX::mixWtSite1old",ntotal);
|
||||
d_mixWtSite2old = typename AT::t_float_1d("PairMultiLucyRX::mixWtSite2old",ntotal);
|
||||
d_mixWtSite1 = typename AT::t_float_1d("PairMultiLucyRX::mixWtSite1",ntotal);
|
||||
d_mixWtSite2 = typename AT::t_float_1d("PairMultiLucyRX::mixWtSite2",ntotal);
|
||||
}
|
||||
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXgetMixingWeights>(0,ntotal),*this);
|
||||
}
|
||||
|
||||
@ -534,10 +534,10 @@ static void compute_all_items(
|
||||
typename ArrayTypes<DeviceType>::t_int_1d_const d_numneigh,
|
||||
typename ArrayTypes<DeviceType>::t_x_array_randomread x,
|
||||
typename ArrayTypes<DeviceType>::t_int_1d_randomread type,
|
||||
Kokkos::View<double*, DeviceType> mixWtSite1old,
|
||||
Kokkos::View<double*, DeviceType> mixWtSite2old,
|
||||
Kokkos::View<double*, DeviceType> mixWtSite1,
|
||||
Kokkos::View<double*, DeviceType> mixWtSite2,
|
||||
Kokkos::View<double*, DeviceType> const& mixWtSite1old,
|
||||
Kokkos::View<double*, DeviceType> const& mixWtSite2old,
|
||||
Kokkos::View<double*, DeviceType> const& mixWtSite1,
|
||||
Kokkos::View<double*, DeviceType> const& mixWtSite2,
|
||||
Few<int, 4> special_lj,
|
||||
Few<Few<F_FLOAT, MAX_TYPES_STACKPARAMS+1>, MAX_TYPES_STACKPARAMS+1> m_cutsq,
|
||||
typename ArrayTypes<DeviceType>::t_ffloat_2d d_cutsq,
|
||||
@ -597,10 +597,10 @@ static void getAllMixingWeights(
|
||||
int nspecies,
|
||||
int isite1, int isite2,
|
||||
bool fractionalWeighting,
|
||||
Kokkos::View<double*, DeviceType> mixWtSite1old,
|
||||
Kokkos::View<double*, DeviceType> mixWtSite2old,
|
||||
Kokkos::View<double*, DeviceType> mixWtSite1,
|
||||
Kokkos::View<double*, DeviceType> mixWtSite2) {
|
||||
Kokkos::View<double*, DeviceType> const& mixWtSite1old,
|
||||
Kokkos::View<double*, DeviceType> const& mixWtSite2old,
|
||||
Kokkos::View<double*, DeviceType> const& mixWtSite1,
|
||||
Kokkos::View<double*, DeviceType> const& mixWtSite2) {
|
||||
Kokkos::parallel_for(ntotal,
|
||||
LAMMPS_LAMBDA(int i) {
|
||||
getMixingWeights<DeviceType>(dvector,nspecies,isite1,isite2,fractionalWeighting,
|
||||
@ -651,10 +651,12 @@ void PairTableRXKokkos<DeviceType>::compute_style(int eflag_in, int vflag_in)
|
||||
// loop over neighbors of my atoms
|
||||
|
||||
const int ntotal = atom->nlocal + atom->nghost;
|
||||
auto mixWtSite1old = Kokkos::View<double*, DeviceType>("PairTableRXKokkos::mixWtSite1old", ntotal);
|
||||
auto mixWtSite2old = Kokkos::View<double*, DeviceType>("PairTableRXKokkos::mixWtSite2old", ntotal);
|
||||
auto mixWtSite1 = Kokkos::View<double*, DeviceType>("PairTableRXKokkos::mixWtSite1", ntotal);
|
||||
auto mixWtSite2 = Kokkos::View<double*, DeviceType>("PairTableRXKokkos::mixWtSite2", ntotal);
|
||||
if (ntotal > mixWtSite1.dimension_0()) {
|
||||
mixWtSite1old = Kokkos::View<double*, DeviceType>("PairTableRXKokkos::mixWtSite1old", ntotal);
|
||||
mixWtSite2old = Kokkos::View<double*, DeviceType>("PairTableRXKokkos::mixWtSite2old", ntotal);
|
||||
mixWtSite1 = Kokkos::View<double*, DeviceType>("PairTableRXKokkos::mixWtSite1", ntotal);
|
||||
mixWtSite2 = Kokkos::View<double*, DeviceType>("PairTableRXKokkos::mixWtSite2", ntotal);
|
||||
}
|
||||
|
||||
getAllMixingWeights(ntotal, atomKK->k_dvector.template view<DeviceType>(),
|
||||
nspecies, isite1, isite2, fractionalWeighting,
|
||||
|
||||
@ -96,6 +96,11 @@ class PairTableRXKokkos : public PairTable {
|
||||
|
||||
/* PairTableRX members */
|
||||
|
||||
Kokkos::View<double*, DeviceType> mixWtSite1old;
|
||||
Kokkos::View<double*, DeviceType> mixWtSite2old;
|
||||
Kokkos::View<double*, DeviceType> mixWtSite1;
|
||||
Kokkos::View<double*, DeviceType> mixWtSite2;
|
||||
|
||||
int nspecies;
|
||||
char *site1, *site2;
|
||||
int isite1, isite2;
|
||||
|
||||
Reference in New Issue
Block a user