modernize loops over fixes
This commit is contained in:
@ -132,27 +132,20 @@ void AtomKokkos::init()
|
||||
|
||||
void AtomKokkos::update_property_atom()
|
||||
{
|
||||
nprop_atom = 0;
|
||||
for (int ifix = 0; ifix < modify->nfix; ifix++) {
|
||||
if (modify->fix[ifix] && utils::strmatch(modify->fix[ifix]->style, "^property/atom")) {
|
||||
auto fix_i = modify->fix[ifix];
|
||||
if (!fix_i->kokkosable)
|
||||
error->all(FLERR, "KOKKOS package requires a Kokkos-enabled version of fix property/atom");
|
||||
std::vector<Fix *> prop_atom_fixes;
|
||||
for (auto &ifix : modify->get_fix_by_style("^property/atom")) {
|
||||
if (!ifix->kokkosable)
|
||||
error->all(FLERR, "KOKKOS package requires a Kokkos-enabled version of fix property/atom");
|
||||
|
||||
memory->grow(prop_atom,nprop_atom+1,"atom::prop_atom");
|
||||
prop_atom[nprop_atom++] = ifix;
|
||||
}
|
||||
prop_atom_fixes.push_back(ifix);
|
||||
}
|
||||
|
||||
delete [] fix_prop_atom;
|
||||
fix_prop_atom = new FixPropertyAtomKokkos*[nprop_atom];
|
||||
delete[] fix_prop_atom;
|
||||
fix_prop_atom = new FixPropertyAtomKokkos *[prop_atom_fixes.size()];
|
||||
|
||||
for (int n = 0; n < nprop_atom; n++) {
|
||||
auto fix_n = dynamic_cast<FixPropertyAtomKokkos*>(modify->fix[prop_atom[n]]);
|
||||
fix_prop_atom[n] = fix_n;
|
||||
}
|
||||
|
||||
memory->destroy(prop_atom);
|
||||
int n = 0;
|
||||
for (auto &ifix : prop_atom_fixes)
|
||||
fix_prop_atom[n++] = dynamic_cast<FixPropertyAtomKokkos *>(ifix);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -161,13 +154,11 @@ void AtomKokkos::sync(const ExecutionSpace space, unsigned int mask)
|
||||
{
|
||||
if (space == Device && lmp->kokkos->auto_sync) {
|
||||
avecKK->modified(Host, mask);
|
||||
for (int n = 0; n < nprop_atom; n++)
|
||||
fix_prop_atom[n]->modified(Host, mask);
|
||||
for (int n = 0; n < nprop_atom; n++) fix_prop_atom[n]->modified(Host, mask);
|
||||
}
|
||||
|
||||
avecKK->sync(space, mask);
|
||||
for (int n = 0; n < nprop_atom; n++)
|
||||
fix_prop_atom[n]->sync(space, mask);
|
||||
for (int n = 0; n < nprop_atom; n++) fix_prop_atom[n]->sync(space, mask);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -175,13 +166,11 @@ void AtomKokkos::sync(const ExecutionSpace space, unsigned int mask)
|
||||
void AtomKokkos::modified(const ExecutionSpace space, unsigned int mask)
|
||||
{
|
||||
avecKK->modified(space, mask);
|
||||
for (int n = 0; n < nprop_atom; n++)
|
||||
fix_prop_atom[n]->modified(space, mask);
|
||||
for (int n = 0; n < nprop_atom; n++) fix_prop_atom[n]->modified(space, mask);
|
||||
|
||||
if (space == Device && lmp->kokkos->auto_sync) {
|
||||
avecKK->sync(Host, mask);
|
||||
for (int n = 0; n < nprop_atom; n++)
|
||||
fix_prop_atom[n]->sync(Host, mask);
|
||||
for (int n = 0; n < nprop_atom; n++) fix_prop_atom[n]->sync(Host, mask);
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,8 +179,7 @@ void AtomKokkos::modified(const ExecutionSpace space, unsigned int mask)
|
||||
void AtomKokkos::sync_overlapping_device(const ExecutionSpace space, unsigned int mask)
|
||||
{
|
||||
avecKK->sync_overlapping_device(space, mask);
|
||||
for (int n = 0; n < nprop_atom; n++)
|
||||
fix_prop_atom[n]->sync_overlapping_device(space, mask);
|
||||
for (int n = 0; n < nprop_atom; n++) fix_prop_atom[n]->sync_overlapping_device(space, mask);
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ void FixDtResetKokkos<DeviceType>::end_of_step()
|
||||
update->dt = dt;
|
||||
update->dt_default = 0;
|
||||
if (force->pair) force->pair->reset_dt();
|
||||
for (int i = 0; i < modify->nfix; i++) modify->fix[i]->reset_dt();
|
||||
for (auto &ifix : modify->get_fix_list()) ifix->reset_dt();
|
||||
output->reset_dt();
|
||||
|
||||
}
|
||||
|
||||
@ -112,9 +112,8 @@ void NeighBondKokkos<DeviceType>::init_topology_kk() {
|
||||
int i,m;
|
||||
int bond_off = 0;
|
||||
int angle_off = 0;
|
||||
for (i = 0; i < modify->nfix; i++)
|
||||
if ((strcmp(modify->fix[i]->style,"shake") == 0)
|
||||
|| (strcmp(modify->fix[i]->style,"rattle") == 0))
|
||||
for (const auto &ifix : modify->get_fix_list())
|
||||
if (utils::strmatch(ifix->style,"^shake") || utils::strmatch(ifix->style,"^rattle"))
|
||||
bond_off = angle_off = 1;
|
||||
if (force->bond && force->bond_match("quartic")) bond_off = 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user