Merge pull request #2985 from stanmoore1/kk_issues
Fix issues with Kokkos package
This commit is contained in:
@ -68,14 +68,14 @@ void BondClass2Kokkos<DeviceType>::compute(int eflag_in, int vflag_in)
|
||||
//if(k_eatom.extent(0)<maxeatom) { // won't work without adding zero functor
|
||||
memoryKK->destroy_kokkos(k_eatom,eatom);
|
||||
memoryKK->create_kokkos(k_eatom,eatom,maxeatom,"improper:eatom");
|
||||
d_eatom = k_eatom.template view<DeviceType>();
|
||||
d_eatom = k_eatom.template view<KKDeviceType>();
|
||||
//}
|
||||
}
|
||||
if (vflag_atom) {
|
||||
//if(k_vatom.extent(0)<maxvatom) { // won't work without adding zero functor
|
||||
memoryKK->destroy_kokkos(k_vatom,vatom);
|
||||
memoryKK->create_kokkos(k_vatom,vatom,maxvatom,"improper:vatom");
|
||||
d_vatom = k_vatom.template view<DeviceType>();
|
||||
d_vatom = k_vatom.template view<KKDeviceType>();
|
||||
//}
|
||||
}
|
||||
|
||||
@ -210,10 +210,10 @@ void BondClass2Kokkos<DeviceType>::coeff(int narg, char **arg)
|
||||
BondClass2::coeff(narg, arg);
|
||||
|
||||
int n = atom->nbondtypes;
|
||||
Kokkos::DualView<F_FLOAT*,DeviceType> k_k2("BondClass2::k2",n+1);
|
||||
Kokkos::DualView<F_FLOAT*,DeviceType> k_k3("BondClass2::k3",n+1);
|
||||
Kokkos::DualView<F_FLOAT*,DeviceType> k_k4("BondClass2::k4",n+1);
|
||||
Kokkos::DualView<F_FLOAT*,DeviceType> k_r0("BondClass2::r0",n+1);
|
||||
typename AT::tdual_ffloat_1d k_k2("BondClass2::k2",n+1);
|
||||
typename AT::tdual_ffloat_1d k_k3("BondClass2::k3",n+1);
|
||||
typename AT::tdual_ffloat_1d k_k4("BondClass2::k4",n+1);
|
||||
typename AT::tdual_ffloat_1d k_r0("BondClass2::r0",n+1);
|
||||
|
||||
d_k2 = k_k2.template view<DeviceType>();
|
||||
d_k3 = k_k3.template view<DeviceType>();
|
||||
@ -247,10 +247,10 @@ void BondClass2Kokkos<DeviceType>::read_restart(FILE *fp)
|
||||
BondClass2::read_restart(fp);
|
||||
|
||||
int n = atom->nbondtypes;
|
||||
Kokkos::DualView<F_FLOAT*,DeviceType> k_k2("BondClass2::k2",n+1);
|
||||
Kokkos::DualView<F_FLOAT*,DeviceType> k_k3("BondClass2::k3",n+1);
|
||||
Kokkos::DualView<F_FLOAT*,DeviceType> k_k4("BondClass2::k4",n+1);
|
||||
Kokkos::DualView<F_FLOAT*,DeviceType> k_r0("BondClass2::r0",n+1);
|
||||
typename AT::tdual_ffloat_1d k_k2("BondClass2::k2",n+1);
|
||||
typename AT::tdual_ffloat_1d k_k3("BondClass2::k3",n+1);
|
||||
typename AT::tdual_ffloat_1d k_k4("BondClass2::k4",n+1);
|
||||
typename AT::tdual_ffloat_1d k_r0("BondClass2::r0",n+1);
|
||||
|
||||
d_k2 = k_k2.template view<DeviceType>();
|
||||
d_k3 = k_k3.template view<DeviceType>();
|
||||
|
||||
@ -67,10 +67,11 @@ class BondClass2Kokkos : public BondClass2 {
|
||||
typename Kokkos::View<double*[3],typename AT::t_f_array::array_layout,typename KKDevice<DeviceType>::value,Kokkos::MemoryTraits<Kokkos::Atomic> > f;
|
||||
typename AT::t_int_2d bondlist;
|
||||
|
||||
Kokkos::DualView<E_FLOAT*,Kokkos::LayoutRight,DeviceType> k_eatom;
|
||||
Kokkos::DualView<F_FLOAT*[6],Kokkos::LayoutRight,DeviceType> k_vatom;
|
||||
Kokkos::View<E_FLOAT*,Kokkos::LayoutRight,typename KKDevice<DeviceType>::value,Kokkos::MemoryTraits<Kokkos::Atomic> > d_eatom;
|
||||
Kokkos::View<F_FLOAT*[6],Kokkos::LayoutRight,typename KKDevice<DeviceType>::value,Kokkos::MemoryTraits<Kokkos::Atomic> > d_vatom;
|
||||
typedef typename KKDevice<DeviceType>::value KKDeviceType;
|
||||
Kokkos::DualView<E_FLOAT*,Kokkos::LayoutRight,KKDeviceType> k_eatom;
|
||||
Kokkos::DualView<F_FLOAT*[6],Kokkos::LayoutRight,KKDeviceType> k_vatom;
|
||||
Kokkos::View<E_FLOAT*,Kokkos::LayoutRight,KKDeviceType,Kokkos::MemoryTraits<Kokkos::Atomic> > d_eatom;
|
||||
Kokkos::View<F_FLOAT*[6],Kokkos::LayoutRight,KKDeviceType,Kokkos::MemoryTraits<Kokkos::Atomic> > d_vatom;
|
||||
|
||||
int nlocal,newton_bond;
|
||||
int eflag,vflag;
|
||||
|
||||
@ -173,8 +173,6 @@ void ComputeOrientOrderAtomKokkos<DeviceType>::compute_peratom()
|
||||
x = atomKK->k_x.view<DeviceType>();
|
||||
mask = atomKK->k_mask.view<DeviceType>();
|
||||
|
||||
Kokkos::deep_copy(d_qnm,{0.0,0.0});
|
||||
|
||||
int vector_length_default = 1;
|
||||
int team_size_default = 1;
|
||||
if (!host_flag)
|
||||
@ -185,6 +183,8 @@ void ComputeOrientOrderAtomKokkos<DeviceType>::compute_peratom()
|
||||
if (chunk_size > inum - chunk_offset)
|
||||
chunk_size = inum - chunk_offset;
|
||||
|
||||
Kokkos::deep_copy(d_qnm,{0.0,0.0});
|
||||
|
||||
//Neigh
|
||||
{
|
||||
int vector_length = vector_length_default;
|
||||
@ -286,7 +286,7 @@ void ComputeOrientOrderAtomKokkos<DeviceType>::operator() (TagComputeOrientOrder
|
||||
const int i = d_ilist[ii + chunk_offset];
|
||||
const int ncount = d_ncount(ii);
|
||||
|
||||
// if not nnn neighbors, order parameter = 0;
|
||||
// if not nnn neighbors, order parameter = 0
|
||||
|
||||
if ((ncount == 0) || (ncount < nnn)) {
|
||||
for (int jj = 0; jj < ncol; jj++)
|
||||
@ -316,7 +316,7 @@ void ComputeOrientOrderAtomKokkos<DeviceType>::operator() (TagComputeOrientOrder
|
||||
const int ncount = d_ncount(ii);
|
||||
if (jj >= ncount) return;
|
||||
|
||||
// if not nnn neighbors, order parameter = 0;
|
||||
// if not nnn neighbors, order parameter = 0
|
||||
|
||||
if ((ncount == 0) || (ncount < nnn))
|
||||
return;
|
||||
@ -328,6 +328,12 @@ template<class DeviceType>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void ComputeOrientOrderAtomKokkos<DeviceType>::operator() (TagComputeOrientOrderAtomBOOP2,const int& ii) const {
|
||||
const int ncount = d_ncount(ii);
|
||||
|
||||
// if not nnn neighbors, order parameter = 0
|
||||
|
||||
if ((ncount == 0) || (ncount < nnn))
|
||||
return;
|
||||
|
||||
calc_boop2(ncount, ii);
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,20 @@ ModifyKokkos::ModifyKokkos(LAMMPS *lmp) : Modify(lmp)
|
||||
void ModifyKokkos::setup(int vflag)
|
||||
{
|
||||
// compute setup needs to come before fix setup
|
||||
// b/c NH fixes need use DOF of temperature computes
|
||||
// b/c NH fixes need DOF of temperature computes
|
||||
// fix group setup() is special case since populates a dynamic group
|
||||
// needs to be done before temperature compute setup
|
||||
|
||||
for (int i = 0; i < nfix; i++) {
|
||||
if (strcmp(fix[i]->style,"GROUP") == 0) {
|
||||
atomKK->sync(fix[i]->execution_space,fix[i]->datamask_read);
|
||||
int prev_auto_sync = lmp->kokkos->auto_sync;
|
||||
if (!fix[i]->kokkosable) lmp->kokkos->auto_sync = 1;
|
||||
fix[i]->setup(vflag);
|
||||
lmp->kokkos->auto_sync = prev_auto_sync;
|
||||
atomKK->modified(fix[i]->execution_space,fix[i]->datamask_modify);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < ncompute; i++) compute[i]->setup();
|
||||
|
||||
@ -124,6 +137,37 @@ void ModifyKokkos::setup_pre_neighbor()
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
setup post_neighbor call, only for fixes that define post_neighbor
|
||||
called from Verlet, RESPA
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ModifyKokkos::setup_post_neighbor()
|
||||
{
|
||||
if (update->whichflag == 1)
|
||||
for (int i = 0; i < n_post_neighbor; i++) {
|
||||
atomKK->sync(fix[list_post_neighbor[i]]->execution_space,
|
||||
fix[list_post_neighbor[i]]->datamask_read);
|
||||
int prev_auto_sync = lmp->kokkos->auto_sync;
|
||||
if (!fix[list_post_neighbor[i]]->kokkosable) lmp->kokkos->auto_sync = 1;
|
||||
fix[list_post_neighbor[i]]->setup_post_neighbor();
|
||||
lmp->kokkos->auto_sync = prev_auto_sync;
|
||||
atomKK->modified(fix[list_post_neighbor[i]]->execution_space,
|
||||
fix[list_post_neighbor[i]]->datamask_modify);
|
||||
}
|
||||
else if (update->whichflag == 2)
|
||||
for (int i = 0; i < n_min_post_neighbor; i++) {
|
||||
atomKK->sync(fix[list_min_post_neighbor[i]]->execution_space,
|
||||
fix[list_min_post_neighbor[i]]->datamask_read);
|
||||
int prev_auto_sync = lmp->kokkos->auto_sync;
|
||||
if (!fix[list_min_post_neighbor[i]]->kokkosable) lmp->kokkos->auto_sync = 1;
|
||||
fix[list_min_post_neighbor[i]]->setup_post_neighbor();
|
||||
lmp->kokkos->auto_sync = prev_auto_sync;
|
||||
atomKK->modified(fix[list_min_post_neighbor[i]]->execution_space,
|
||||
fix[list_min_post_neighbor[i]]->datamask_modify);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
setup pre_force call, only for fixes that define pre_force
|
||||
called from Verlet, RESPA, Min
|
||||
@ -258,6 +302,24 @@ void ModifyKokkos::pre_neighbor()
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
post_neighbor call, only for relevant fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ModifyKokkos::post_neighbor()
|
||||
{
|
||||
for (int i = 0; i < n_post_neighbor; i++) {
|
||||
atomKK->sync(fix[list_post_neighbor[i]]->execution_space,
|
||||
fix[list_post_neighbor[i]]->datamask_read);
|
||||
int prev_auto_sync = lmp->kokkos->auto_sync;
|
||||
if (!fix[list_post_neighbor[i]]->kokkosable) lmp->kokkos->auto_sync = 1;
|
||||
fix[list_post_neighbor[i]]->post_neighbor();
|
||||
lmp->kokkos->auto_sync = prev_auto_sync;
|
||||
atomKK->modified(fix[list_post_neighbor[i]]->execution_space,
|
||||
fix[list_post_neighbor[i]]->datamask_modify);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pre_force call, only for relevant fixes
|
||||
------------------------------------------------------------------------- */
|
||||
@ -420,6 +482,12 @@ void ModifyKokkos::post_run()
|
||||
atomKK->modified(fix[i]->execution_space,
|
||||
fix[i]->datamask_modify);
|
||||
}
|
||||
|
||||
// must reset this to its default value, since computes may be added
|
||||
// or removed between runs and with this change we will redirect any
|
||||
// calls to addstep_compute() to addstep_compute_all() instead.
|
||||
n_timeflag = -1;
|
||||
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -567,6 +635,24 @@ void ModifyKokkos::min_pre_neighbor()
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
minimizer post-neighbor call, only for relevant fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ModifyKokkos::min_post_neighbor()
|
||||
{
|
||||
for (int i = 0; i < n_min_post_neighbor; i++) {
|
||||
atomKK->sync(fix[list_min_post_neighbor[i]]->execution_space,
|
||||
fix[list_min_post_neighbor[i]]->datamask_read);
|
||||
int prev_auto_sync = lmp->kokkos->auto_sync;
|
||||
if (!fix[list_min_post_neighbor[i]]->kokkosable) lmp->kokkos->auto_sync = 1;
|
||||
fix[list_min_post_neighbor[i]]->min_post_neighbor();
|
||||
lmp->kokkos->auto_sync = prev_auto_sync;
|
||||
atomKK->modified(fix[list_min_post_neighbor[i]]->execution_space,
|
||||
fix[list_min_post_neighbor[i]]->datamask_modify);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
minimizer pre-force call, only for relevant fixes
|
||||
------------------------------------------------------------------------- */
|
||||
@ -646,7 +732,7 @@ double ModifyKokkos::min_energy(double *fextra)
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
store current state of extra dof, only for relevant fixes
|
||||
store current state of extra minimizer dof, only for relevant fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ModifyKokkos::min_store()
|
||||
@ -664,7 +750,7 @@ void ModifyKokkos::min_store()
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
mange state of extra dof on a stack, only for relevant fixes
|
||||
manage state of extra minimizer dof on a stack, only for relevant fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ModifyKokkos::min_clearstore()
|
||||
@ -710,7 +796,7 @@ void ModifyKokkos::min_popstore()
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
displace extra dof along vector hextra, only for relevant fixes
|
||||
displace extra minimizer dof along vector hextra, only for relevant fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ModifyKokkos::min_step(double alpha, double *hextra)
|
||||
@ -755,7 +841,7 @@ double ModifyKokkos::max_alpha(double *hextra)
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
extract extra dof for minimization, only for relevant fixes
|
||||
extract extra minimizer dof, only for relevant fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int ModifyKokkos::min_dof()
|
||||
@ -775,7 +861,7 @@ int ModifyKokkos::min_dof()
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
reset reference state of fix, only for relevant fixes
|
||||
reset minimizer reference state of fix, only for relevant fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int ModifyKokkos::min_reset_ref()
|
||||
@ -788,8 +874,8 @@ int ModifyKokkos::min_reset_ref()
|
||||
int prev_auto_sync = lmp->kokkos->auto_sync;
|
||||
if (!fix[list_min_energy[i]]->kokkosable) lmp->kokkos->auto_sync = 1;
|
||||
itmp = fix[list_min_energy[i]]->min_reset_ref();
|
||||
lmp->kokkos->auto_sync = prev_auto_sync;
|
||||
if (itmp) itmpall = 1;
|
||||
lmp->kokkos->auto_sync = prev_auto_sync;
|
||||
atomKK->modified(fix[list_min_energy[i]]->execution_space,
|
||||
fix[list_min_energy[i]]->datamask_modify);
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ class ModifyKokkos : public Modify {
|
||||
void setup(int);
|
||||
void setup_pre_exchange();
|
||||
void setup_pre_neighbor();
|
||||
void setup_post_neighbor();
|
||||
void setup_pre_force(int);
|
||||
void setup_pre_reverse(int, int);
|
||||
void initial_integrate(int);
|
||||
@ -33,6 +34,7 @@ class ModifyKokkos : public Modify {
|
||||
void pre_decide();
|
||||
void pre_exchange();
|
||||
void pre_neighbor();
|
||||
void post_neighbor();
|
||||
void pre_force(int);
|
||||
void pre_reverse(int,int);
|
||||
void post_force(int);
|
||||
@ -52,6 +54,7 @@ class ModifyKokkos : public Modify {
|
||||
|
||||
void min_pre_exchange();
|
||||
void min_pre_neighbor();
|
||||
void min_post_neighbor();
|
||||
void min_pre_force(int);
|
||||
void min_pre_reverse(int,int);
|
||||
void min_post_force(int);
|
||||
|
||||
Reference in New Issue
Block a user