Merge branch 'upstream' into gpu-newton-pair-on

This commit is contained in:
Trung Nguyen
2021-11-20 08:30:39 -06:00
1813 changed files with 66672 additions and 33211 deletions

View File

@ -13,25 +13,23 @@
------------------------------------------------------------------------- */
#include "fix_gpu.h"
#include <cstring>
#include "atom.h"
#include "citeme.h"
#include "comm.h"
#include "error.h"
#include "force.h"
#include "gpu_extra.h"
#include "modify.h"
#include "neighbor.h"
#include "pair.h"
#include "pair_hybrid.h"
#include "pair_hybrid_overlay.h"
#include "respa.h"
#include "input.h"
#include "timer.h"
#include "modify.h"
#include "update.h"
#include "domain.h"
#include "universe.h"
#include "gpu_extra.h"
#include "neighbor.h"
#include "citeme.h"
#include "error.h"
#include "update.h"
#include <cstring>
#if (LAL_USE_OMP == 1)
#include <omp.h>
@ -49,12 +47,10 @@ extern int lmp_init_device(MPI_Comm world, MPI_Comm replica, const int ngpu,
const int ocl_platform, char *device_type_flags,
const int block_pair);
extern void lmp_clear_device();
extern double lmp_gpu_forces(double **f, double **tor, double *eatom,
double **vatom, double *virial, double &ecoul,
int &err_flag);
extern double lmp_gpu_update_bin_size(const double subx, const double suby,
const double subz, const int nlocal,
const double cut);
extern double lmp_gpu_forces(double **f, double **tor, double *eatom, double **vatom,
double *virial, double &ecoul, int &err_flag);
extern double lmp_gpu_update_bin_size(const double subx, const double suby, const double subz,
const int nlocal, const double cut);
static const char cite_gpu_package[] =
"GPU package (short-range, long-range and three-body potentials):\n\n"
@ -140,16 +136,17 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
while (iarg < narg) {
if (strcmp(arg[iarg],"neigh") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
if (strcmp(arg[iarg+1],"yes") == 0) _gpu_mode = GPU_NEIGH;
else if (strcmp(arg[iarg+1],"no") == 0) _gpu_mode = GPU_FORCE;
else if (strcmp(arg[iarg+1],"hybrid") == 0) _gpu_mode = GPU_HYB_NEIGH;
const std::string modearg = arg[iarg+1];
if ((modearg == "yes") || (modearg == "on") || (modearg == "true"))
_gpu_mode = GPU_NEIGH;
else if ((modearg == "no") || (modearg == "off") || (modearg == "false"))
_gpu_mode = GPU_FORCE;
else if (modearg == "hybrid") _gpu_mode = GPU_HYB_NEIGH;
else error->all(FLERR,"Illegal package gpu command");
iarg += 2;
} else if (strcmp(arg[iarg],"newton") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
if (strcmp(arg[iarg+1],"off") == 0) newtonflag = 0;
else if (strcmp(arg[iarg+1],"on") == 0) newtonflag = 1;
else error->all(FLERR,"Illegal package gpu command");
newtonflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"binsize") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
@ -189,9 +186,7 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
iarg += 2;
} else if (strcmp(arg[iarg],"pair/only") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
if (strcmp(arg[iarg+1],"off") == 0) pair_only_flag = 0;
else if (strcmp(arg[iarg+1],"on") == 0) pair_only_flag = 1;
else error->all(FLERR,"Illegal package gpu command");
pair_only_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"ocl_args") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
@ -202,7 +197,7 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
#if (LAL_USE_OMP == 0)
if (nthreads > 1)
error->all(FLERR,"No OpenMP support compiled in");
error->all(FLERR,"No OpenMP support compiled into the GPU package");
#else
if (nthreads > 0) {
omp_set_num_threads(nthreads);
@ -277,12 +272,15 @@ void FixGPU::init()
error->warning(FLERR,"Using package gpu without any pair style defined");
// make sure fdotr virial is not accumulated multiple times
// also disallow GPU neighbor lists for hybrid styles
if (force->pair_match("^hybrid",0) != nullptr) {
PairHybrid *hybrid = (PairHybrid *) force->pair;
for (int i = 0; i < hybrid->nstyles; i++)
if (!utils::strmatch(hybrid->keywords[i],"/gpu$"))
force->pair->no_virial_fdotr_compute = 1;
if (_gpu_mode != GPU_FORCE)
error->all(FLERR, "Must not use GPU neighbor lists with hybrid pair style");
}
// rRESPA support
@ -297,8 +295,7 @@ void FixGPU::setup(int vflag)
{
if (_gpu_mode == GPU_NEIGH || _gpu_mode == GPU_HYB_NEIGH)
if (neighbor->exclude_setting() != 0)
error->all(FLERR,
"Cannot use neigh_modify exclude with GPU neighbor builds");
error->all(FLERR, "Cannot use neigh_modify exclude with GPU neighbor builds");
if (utils::strmatch(update->integrate_style,"^verlet")) post_force(vflag);
else {
@ -325,15 +322,12 @@ void FixGPU::post_force(int /* vflag */)
timer->stamp();
double lvirial[6];
for (int i = 0; i < 6; i++) lvirial[i] = 0.0;
int err_flag;
double my_eng = lmp_gpu_forces(atom->f, atom->torque, force->pair->eatom,
force->pair->vatom, lvirial,
force->pair->eng_coul, err_flag);
if (err_flag) {
if (err_flag==1)
error->one(FLERR,
"Too many neighbors on GPU. Use neigh_modify one to increase limit.");
}
int err_flag = 0;
double my_eng = lmp_gpu_forces(atom->f, atom->torque, force->pair->eatom, force->pair->vatom,
lvirial, force->pair->eng_coul, err_flag);
if (err_flag==1)
error->one(FLERR,"Neighbor list problem on the GPU. Try increasing the value of 'neigh_modify one' "
"or the GPU neighbor list 'binsize'.");
force->pair->eng_vdwl += my_eng;
force->pair->virial[0] += lvirial[0];