diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 59876a82fa..44f4a5789d 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -22,6 +22,7 @@ #include "error.h" #include "timer.h" #include "modify.h" +#include "update.h" #include "domain.h" #include "universe.h" #include "gpu_extra.h" @@ -123,6 +124,7 @@ int FixGPU::setmask() int mask = 0; mask |= POST_FORCE; mask |= MIN_POST_FORCE; + mask |= POST_FORCE_RESPA; return mask; } @@ -135,11 +137,27 @@ void FixGPU::init() if (_gpu_mode == GPU_NEIGH || _gpu_mode == GPU_HYB_NEIGH) if (force->pair_match("hybrid",1) != NULL || force->pair_match("hybrid/overlay",1) != NULL) - error->all(FLERR,"Cannot use pair hybrid with GPU neighbor builds"); + error->all(FLERR,"Cannot use pair hybrid with GPU neighbor list builds"); if (_particle_split < 0) if (force->pair_match("hybrid",1) != NULL || force->pair_match("hybrid/overlay",1) != NULL) - error->all(FLERR,"Fix GPU split must be positive for hybrid pair styles"); + error->all(FLERR,"GPU 'split' must be positive for hybrid pair styles"); + + // r-RESPA support + + if (strstr(update->integrate_style,"respa")) { + _nlevels_respa = ((Respa *) update->integrate)->nlevels; + + // need to check that gpu accelerated styles are at the outmost levels + + if ((force->pair_match("/gpu",0) != NULL) && + (((Respa *) update->integrate)->level_pair != _nlevels_respa-1)) + error->all(FLERR,"GPU pair style must be at outermost respa level"); + + if ((force->kspace_match("/gpu",0) != NULL) && + (((Respa *) update->integrate)->level_kspace != _nlevels_respa-1)) + error->all(FLERR,"GPU Kspace style must be at outermost respa level"); + } } /* ---------------------------------------------------------------------- */ @@ -150,7 +168,14 @@ void FixGPU::setup(int vflag) if (neighbor->exclude_setting()!=0) error->all(FLERR, "Cannot use neigh_modify exclude with GPU neighbor builds"); - post_force(vflag); + + if (strstr(update->integrate_style,"verlet")) + post_force(vflag); + else { + ((Respa *) update->integrate)->copy_flevel_f(_nlevels_respa-1); + post_force_respa(vflag,_nlevels_respa-1,0); + ((Respa *) update->integrate)->copy_f_flevel(_nlevels_respa-1); + } } /* ---------------------------------------------------------------------- */ @@ -192,6 +217,13 @@ void FixGPU::min_post_force(int vflag) /* ---------------------------------------------------------------------- */ +void FixGPU::post_force_respa(int vflag, int ilevel, int iloop) +{ + if (ilevel == _nlevels_respa-1) post_force(vflag); +} + +/* ---------------------------------------------------------------------- */ + double FixGPU::memory_usage() { double bytes = 0.0; diff --git a/src/GPU/fix_gpu.h b/src/GPU/fix_gpu.h index 88e8d30889..e4cc797bd4 100644 --- a/src/GPU/fix_gpu.h +++ b/src/GPU/fix_gpu.h @@ -34,10 +34,12 @@ class FixGPU : public Fix { void min_setup(int); void post_force(int); void min_post_force(int); + void post_force_respa(int, int, int); double memory_usage(); private: int _gpu_mode; + int _nlevels_respa; double _particle_split; }; @@ -86,4 +88,9 @@ E: Cannot use neigh_modify exclude with GPU neighbor builds This is a current limitation of the GPU implementation in LAMMPS. +E: GPU styles must be on the outmost r-RESPA level + +Self-explanatory. + + */