Enabled newton pair on for gpu pair styles

This commit is contained in:
Trung Nguyen
2021-08-06 01:11:31 -05:00
parent 5045595ad8
commit 0904ffa813
61 changed files with 142 additions and 8 deletions

View File

@ -127,7 +127,7 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
_gpu_mode = GPU_NEIGH;
_particle_split = 1.0;
int nthreads = 0;
int newtonflag = 0;
int newtonflag = force->newton_pair;
int threads_per_atom = -1;
double binsize = 0.0;
char *opencl_args = nullptr;
@ -211,14 +211,16 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
#endif
// set newton pair flag
// require newtonflag = 0 since currently required by all GPU pair styles
if (newtonflag == 1) error->all(FLERR,"Illegal package gpu command");
force->newton_pair = newtonflag;
if (force->newton_pair || force->newton_bond) force->newton = 1;
else force->newton = 0;
// require newton pair off if _particle_split < 1
if (force->newton_pair == 1 && _particle_split < 1)
error->all(FLERR,"Cannot use newton pair on for split less than 1");
if (pair_only_flag) {
lmp->suffixp = lmp->suffix;
lmp->suffix = nullptr;
@ -341,7 +343,23 @@ void FixGPU::post_force(int /* vflag */)
force->pair->virial[4] += lvirial[4];
force->pair->virial[5] += lvirial[5];
if (force->pair->vflag_fdotr) force->pair->virial_fdotr_compute();
// for newton pair off: force->pair->vflag_fdotr = 0
// which has been the case so far, virial_fdotr_compute() is never called
// for newton pair on: force->pair->vflag_fdotr = 1
// for neigh yes: full neighbor lists are built on the device
// for neigh no: full neighbor lists are built on the host
// either way the virial is tallied to force->pair->virial as above
// so as long as _particle_split == 1
// no need to call force->pair->virial_fdotr_compute();
// If _particle_split < 1, the local atom forces computed by
// the gpu pair styles on the host (cpu_compute()) got tallied
// by comm->reverse_comm() (which is done before this post_force() function).
// A call to force->pair->virial_fdotr_compute() would double count
// the virial from the local atoms on the host.
// Here a possible workaround is to comment out the below command
// while enforcing newton pair off for _particle_split < 1.
//if (force->pair->vflag_fdotr) force->pair->virial_fdotr_compute();
timer->stamp(Timer::PAIR);
}