Fix a few more issues

This commit is contained in:
Stan Gerald Moore
2022-04-08 12:52:26 -06:00
parent 40aa146624
commit f8ec0365c6
4 changed files with 46 additions and 65 deletions

View File

@ -370,25 +370,20 @@ void PairDPDExtKokkos<DeviceType>::ev_tally_xyz(EV_FLOAT &ev, const int &i, cons
}
if (vflag_either) {
const E_FLOAT v0 = delx*delx*fx;
const E_FLOAT v1 = dely*dely*fy;
const E_FLOAT v2 = delz*delz*fz;
const E_FLOAT v3 = delx*dely*fy;
const E_FLOAT v4 = delx*delz*fz;
const E_FLOAT v5 = dely*delz*fz;
const E_FLOAT v0 = delx*fx;
const E_FLOAT v1 = dely*fy;
const E_FLOAT v2 = delz*fz;
const E_FLOAT v3 = delx*fy;
const E_FLOAT v4 = delx*fz;
const E_FLOAT v5 = dely*fz;
if (vflag_global) {
ev.v[0] += 0.5*v0;
ev.v[1] += 0.5*v1;
ev.v[2] += 0.5*v2;
ev.v[3] += 0.5*v3;
ev.v[4] += 0.5*v4;
ev.v[5] += 0.5*v5;
ev.v[1] += 0.5*v1;
ev.v[2] += 0.5*v2;
ev.v[3] += 0.5*v3;
ev.v[4] += 0.5*v4;
ev.v[5] += 0.5*v5;
ev.v[0] += v0;
ev.v[1] += v1;
ev.v[2] += v2;
ev.v[3] += v3;
ev.v[4] += v4;
ev.v[5] += v5;
}
if (vflag_atom) {

View File

@ -67,7 +67,6 @@ PairDPDExtTstatKokkos<DeviceType>::~PairDPDExtTstatKokkos() {
rand_pool.destroy();
#endif
memoryKK->destroy_kokkos(k_eatom,eatom);
memoryKK->destroy_kokkos(k_vatom,vatom);
memoryKK->destroy_kokkos(k_cutsq,cutsq);
@ -124,10 +123,12 @@ void PairDPDExtTstatKokkos<DeviceType>::compute(int eflagin, int vflagin)
k_params.template modify<LMPHostType>();
if (eflag_atom) {
memoryKK->destroy_kokkos(k_eatom,eatom);
memoryKK->create_kokkos(k_eatom,eatom,maxeatom,"pair:eatom");
d_eatom = k_eatom.template view<DeviceType>();
maxeatom = atom->nmax;
memory->destroy(eatom);
memory->create(eatom,maxeatom,"pair:eatom");
memset(&eatom[0], 0, maxeatom * sizeof(double));
}
if (vflag_atom) {
memoryKK->destroy_kokkos(k_vatom,vatom);
memoryKK->create_kokkos(k_vatom,vatom,maxvatom,"pair:vatom");
@ -160,11 +161,9 @@ void PairDPDExtTstatKokkos<DeviceType>::compute(int eflagin, int vflagin)
need_dup = lmp->kokkos->need_dup<DeviceType>();
if (need_dup) {
dup_f = Kokkos::Experimental::create_scatter_view<Kokkos::Experimental::ScatterSum, Kokkos::Experimental::ScatterDuplicated>(f);
dup_eatom = Kokkos::Experimental::create_scatter_view<Kokkos::Experimental::ScatterSum, Kokkos::Experimental::ScatterDuplicated>(d_eatom);
dup_vatom = Kokkos::Experimental::create_scatter_view<Kokkos::Experimental::ScatterSum, Kokkos::Experimental::ScatterDuplicated>(d_vatom);
} else {
ndup_f = Kokkos::Experimental::create_scatter_view<Kokkos::Experimental::ScatterSum, Kokkos::Experimental::ScatterNonDuplicated>(f);
ndup_eatom = Kokkos::Experimental::create_scatter_view<Kokkos::Experimental::ScatterSum, Kokkos::Experimental::ScatterNonDuplicated>(d_eatom);
ndup_vatom = Kokkos::Experimental::create_scatter_view<Kokkos::Experimental::ScatterSum, Kokkos::Experimental::ScatterNonDuplicated>(d_vatom);
}
@ -184,7 +183,6 @@ void PairDPDExtTstatKokkos<DeviceType>::compute(int eflagin, int vflagin)
if (need_dup)
Kokkos::Experimental::contribute(f, dup_f);
if (eflag_global) eng_vdwl += ev.evdwl;
if (vflag_global) {
virial[0] += ev.v[0];
virial[1] += ev.v[1];
@ -196,13 +194,6 @@ void PairDPDExtTstatKokkos<DeviceType>::compute(int eflagin, int vflagin)
if (vflag_fdotr) pair_virial_fdotr_compute(this);
if (eflag_atom) {
if (need_dup)
Kokkos::Experimental::contribute(d_eatom, dup_eatom);
k_eatom.template modify<DeviceType>();
k_eatom.template sync<LMPHostType>();
}
if (vflag_atom) {
if (need_dup)
Kokkos::Experimental::contribute(d_vatom, dup_vatom);
@ -218,7 +209,6 @@ void PairDPDExtTstatKokkos<DeviceType>::compute(int eflagin, int vflagin)
// free duplicated memory
if (need_dup) {
dup_f = decltype(dup_f)();
dup_eatom = decltype(dup_eatom)();
dup_vatom = decltype(dup_vatom)();
}
}
@ -237,6 +227,7 @@ template<class DeviceType>
template<int NEIGHFLAG, int VFLAG>
KOKKOS_INLINE_FUNCTION
void PairDPDExtTstatKokkos<DeviceType>::operator() (TagDPDExtTstatKokkos<NEIGHFLAG,VFLAG>, const int &ii, EV_FLOAT &ev) const {
// The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial
auto v_f = ScatterViewHelper<NeedDup_v<NEIGHFLAG,DeviceType>,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f);
@ -362,25 +353,20 @@ void PairDPDExtTstatKokkos<DeviceType>::v_tally_xyz(EV_FLOAT &ev, const int &i,
auto v_vatom = ScatterViewHelper<NeedDup_v<NEIGHFLAG,DeviceType>,decltype(dup_vatom),decltype(ndup_vatom)>::get(dup_vatom,ndup_vatom);
auto a_vatom = v_vatom.template access<AtomicDup_v<NEIGHFLAG,DeviceType>>();
const E_FLOAT v0 = delx*delx*fx;
const E_FLOAT v1 = dely*dely*fy;
const E_FLOAT v2 = delz*delz*fz;
const E_FLOAT v3 = delx*dely*fy;
const E_FLOAT v4 = delx*delz*fz;
const E_FLOAT v5 = dely*delz*fz;
const E_FLOAT v0 = delx*fx;
const E_FLOAT v1 = dely*fy;
const E_FLOAT v2 = delz*fz;
const E_FLOAT v3 = delx*fy;
const E_FLOAT v4 = delx*fz;
const E_FLOAT v5 = dely*fz;
if (vflag_global) {
ev.v[0] += 0.5*v0;
ev.v[1] += 0.5*v1;
ev.v[2] += 0.5*v2;
ev.v[3] += 0.5*v3;
ev.v[4] += 0.5*v4;
ev.v[5] += 0.5*v5;
ev.v[1] += 0.5*v1;
ev.v[2] += 0.5*v2;
ev.v[3] += 0.5*v3;
ev.v[4] += 0.5*v4;
ev.v[5] += 0.5*v5;
ev.v[0] += v0;
ev.v[1] += v1;
ev.v[2] += v2;
ev.v[3] += v3;
ev.v[4] += v4;
ev.v[5] += v5;
}
if (vflag_atom) {

View File

@ -95,10 +95,8 @@ class PairDPDExtTstatKokkos : public PairDPDExtTstat {
using NonDupScatterView = KKScatterView<DataType, Layout, KKDeviceType, KKScatterSum, KKScatterNonDuplicated>;
DupScatterView<F_FLOAT*[3], typename DAT::t_f_array::array_layout> dup_f;
DupScatterView<E_FLOAT*, typename DAT::t_efloat_1d::array_layout> dup_eatom;
DupScatterView<F_FLOAT*[6], typename DAT::t_virial_array::array_layout> dup_vatom;
NonDupScatterView<F_FLOAT*[3], typename DAT::t_f_array::array_layout> ndup_f;
NonDupScatterView<E_FLOAT*, typename DAT::t_efloat_1d::array_layout> ndup_eatom;
NonDupScatterView<F_FLOAT*[6], typename DAT::t_virial_array::array_layout> ndup_vatom;
#ifdef DPD_USE_RAN_MARS
@ -127,9 +125,7 @@ class PairDPDExtTstatKokkos : public PairDPDExtTstat {
typename Kokkos::DualView<params_dpd**,
Kokkos::LayoutRight,DeviceType>::t_dev_const_um params;
DAT::tdual_efloat_1d k_eatom;
DAT::tdual_virial_array k_vatom;
typename AT::t_efloat_1d d_eatom;
typename AT::t_virial_array d_vatom;
KOKKOS_INLINE_FUNCTION

View File

@ -115,12 +115,20 @@ void PairDPDTstatKokkos<DeviceType>::compute(int eflagin, int vflagin)
temperature = t_start + delta * (t_stop-t_start);
double boltz = force->boltz;
for (int i = 1; i <= atom->ntypes; i++)
for (int j = i; j <= atom->ntypes; j++)
for (int j = i; j <= atom->ntypes; j++) {
k_params.h_view(i,j).sigma = k_params.h_view(j,i).sigma =
sqrt(2.0*boltz*temperature*gamma[i][j]);
}
}
k_params.template modify<LMPHostType>();
if (eflag_atom) {
maxeatom = atom->nmax;
memory->destroy(eatom);
memory->create(eatom,maxeatom,"pair:eatom");
memset(&eatom[0], 0, maxeatom * sizeof(double));
}
if (vflag_atom) {
memoryKK->destroy_kokkos(k_vatom,vatom);
memoryKK->create_kokkos(k_vatom,vatom,maxvatom,"pair:vatom");
@ -230,6 +238,7 @@ void PairDPDTstatKokkos<DeviceType>::operator() (TagDPDTstatKokkos<NEIGHFLAG,VFL
double vxtmp,vytmp,vztmp,delvx,delvy,delvz;
double rsq,r,rinv,dot,wd,randnum,factor_dpd;
double fx = 0,fy = 0,fz = 0;
i = d_ilist[ii];
xtmp = x(i,0);
ytmp = x(i,1);
@ -311,17 +320,12 @@ void PairDPDTstatKokkos<DeviceType>::v_tally(EV_FLOAT &ev, const int &i, const i
const E_FLOAT v5 = dely*delz*fpair;
if (vflag_global) {
ev.v[0] += 0.5*v0;
ev.v[1] += 0.5*v1;
ev.v[2] += 0.5*v2;
ev.v[3] += 0.5*v3;
ev.v[4] += 0.5*v4;
ev.v[0] += 0.5*v0;
ev.v[1] += 0.5*v1;
ev.v[2] += 0.5*v2;
ev.v[3] += 0.5*v3;
ev.v[4] += 0.5*v4;
ev.v[5] += 0.5*v5;
ev.v[0] += v0;
ev.v[1] += v1;
ev.v[2] += v2;
ev.v[3] += v3;
ev.v[4] += v4;
ev.v[5] += v5;
}
if (vflag_atom) {