From f6c0d4fec3e9ab2aef345de194ca360f8d1fabba Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 5 Sep 2014 14:39:17 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12405 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/KOKKOS/atom_kokkos.cpp | 20 +++++++++++++++++--- src/KOKKOS/atom_kokkos.h | 4 +++- src/KOKKOS/fix_nve_kokkos.cpp | 2 +- src/atom.h | 2 ++ src/fix_addforce.cpp | 16 +++++++++++++++- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/KOKKOS/atom_kokkos.cpp b/src/KOKKOS/atom_kokkos.cpp index 89c7eea007..51f4239dca 100644 --- a/src/KOKKOS/atom_kokkos.cpp +++ b/src/KOKKOS/atom_kokkos.cpp @@ -31,6 +31,7 @@ AtomKokkos::AtomKokkos(LAMMPS *lmp) : Atom(lmp) // set CommKokkos pointer to Atom class, since CommKokkos allocated first ((CommKokkos *) comm)->atomKK = this; + execution_space = ExecutionSpaceFromDevice::space; } /* ---------------------------------------------------------------------- */ @@ -48,8 +49,7 @@ AtomKokkos::~AtomKokkos() memory->destroy_kokkos(k_f, f); memory->destroy_kokkos(k_mass, mass); - - memory->destroy_kokkos(k_q,q); + memory->destroy_kokkos(k_q, q); memory->destroy_kokkos(k_nspecial, nspecial); memory->destroy_kokkos(k_special, special); @@ -73,7 +73,6 @@ AtomKokkos::~AtomKokkos() memory->destroy_kokkos(k_improper_atom2, improper_atom2); memory->destroy_kokkos(k_improper_atom3, improper_atom3); memory->destroy_kokkos(k_improper_atom4, improper_atom4); - } /* ---------------------------------------------------------------------- */ @@ -204,6 +203,7 @@ void AtomKokkos::sort() /* ---------------------------------------------------------------------- reallocate memory to the pointer selected by the mask ------------------------------------------------------------------------- */ + void AtomKokkos::grow(unsigned int mask){ if (mask && SPECIAL_MASK){ @@ -217,6 +217,8 @@ void AtomKokkos::grow(unsigned int mask){ } +/* ---------------------------------------------------------------------- */ + void AtomKokkos::deallocate_topology() { memory->destroy_kokkos(k_bond_type, bond_type); @@ -240,3 +242,15 @@ void AtomKokkos::deallocate_topology() memory->destroy_kokkos(k_improper_atom4, improper_atom4); } +/* ---------------------------------------------------------------------- + perform sync and modify for each of 2 masks + called by individual styles to override default sync/modify calls + done at higher levels (Verlet,Modify,etc) +------------------------------------------------------------------------- */ + +void AtomKokkos::sync_modify(unsigned int datamask_read, + unsigned int datamask_modify) +{ + sync(execution_space,datamask_read); + modified(execution_space,datamask_modify); +} diff --git a/src/KOKKOS/atom_kokkos.h b/src/KOKKOS/atom_kokkos.h index 2abf288793..fc12c1cfec 100644 --- a/src/KOKKOS/atom_kokkos.h +++ b/src/KOKKOS/atom_kokkos.h @@ -28,7 +28,6 @@ class AtomKokkos : public Atom { DAT::tdual_v_array k_v; DAT::tdual_f_array k_f; - DAT::tdual_float_1d k_mass; DAT::tdual_float_1d k_q; @@ -48,6 +47,8 @@ class AtomKokkos : public Atom { DAT::tdual_int_2d k_improper_type; DAT::tdual_tagint_2d k_improper_atom1, k_improper_atom2, k_improper_atom3, k_improper_atom4; + ExecutionSpace execution_space; + AtomKokkos(class LAMMPS *); ~AtomKokkos(); @@ -57,6 +58,7 @@ class AtomKokkos : public Atom { virtual void sort(); virtual void grow(unsigned int mask); virtual void deallocate_topology(); + void sync_modify(unsigned int, unsigned int); }; template diff --git a/src/KOKKOS/fix_nve_kokkos.cpp b/src/KOKKOS/fix_nve_kokkos.cpp index 6f7f1e6300..3bc1a5629b 100644 --- a/src/KOKKOS/fix_nve_kokkos.cpp +++ b/src/KOKKOS/fix_nve_kokkos.cpp @@ -34,7 +34,7 @@ FixNVEKokkos::FixNVEKokkos(LAMMPS *lmp, int narg, char **arg) : execution_space = ExecutionSpaceFromDevice::space; datamask_read = X_MASK | V_MASK | F_MASK | MASK_MASK | RMASS_MASK | TYPE_MASK; - datamask_modify = X_MASK | V_MASK | F_MASK; + datamask_modify = X_MASK | V_MASK; } /* ---------------------------------------------------------------------- */ diff --git a/src/atom.h b/src/atom.h index 2f21fee722..f8f45457ef 100644 --- a/src/atom.h +++ b/src/atom.h @@ -222,6 +222,8 @@ class Atom : protected Pointers { int find_custom(char *, int &); int add_custom(char *, int); void remove_custom(int, int); + + virtual void sync_modify(unsigned int, unsigned int) {} void *extract(char *); diff --git a/src/fix_addforce.cpp b/src/fix_addforce.cpp index db2a78f2f6..c14f6f7761 100644 --- a/src/fix_addforce.cpp +++ b/src/fix_addforce.cpp @@ -15,6 +15,7 @@ #include "stdlib.h" #include "fix_addforce.h" #include "atom.h" +#include "atom_masks.h" #include "update.h" #include "modify.h" #include "domain.h" @@ -75,13 +76,19 @@ FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) : // optional args + nevery = 1; iregion = -1; idregion = NULL; estr = NULL; int iarg = 6; while (iarg < narg) { - if (strcmp(arg[iarg],"region") == 0) { + if (strcmp(arg[iarg],"every") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix addforce command"); + nevery = atoi(arg[iarg+1]); + if (nevery <= 0) error->all(FLERR,"Illegal fix addforce command"); + iarg += 2; + } else if (strcmp(arg[iarg],"region") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix addforce command"); iregion = domain->find_region(arg[iarg+1]); if (iregion == -1) @@ -124,6 +131,8 @@ FixAddForce::~FixAddForce() int FixAddForce::setmask() { + datamask_read = datamask_modify = 0; + int mask = 0; mask |= POST_FORCE; mask |= THERMO_ENERGY; @@ -225,6 +234,11 @@ void FixAddForce::post_force(int vflag) imageint *image = atom->image; int nlocal = atom->nlocal; + if (update->ntimestep % nevery) return; + + atom->sync_modify((unsigned int) (F_MASK | MASK_MASK), + (unsigned int) F_MASK); + // update region if necessary Region *region = NULL;