diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 7431d14a82..86a4996ae9 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -40,7 +40,8 @@ extern int lmp_init_device(MPI_Comm world, MPI_Comm replica, const int first_gpu, const int last_gpu, const int gpu_mode, const double particle_split, const int nthreads, const int t_per_atom, - const double cell_size, char *opencl_flags); + const double cell_size, char *opencl_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); @@ -98,6 +99,7 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : int threads_per_atom = -1; double binsize = 0.0; char *opencl_flags = NULL; + int block_pair = -1; int iarg = 4; while (iarg < narg) { @@ -142,15 +144,13 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); opencl_flags = arg[iarg+1]; iarg += 2; + } else if (strcmp(arg[iarg],"blocksize") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); + block_pair = force->inumeric(FLERR,arg[iarg+1]); + iarg += 2; } else error->all(FLERR,"Illegal package gpu command"); } - // error check - - if ((_gpu_mode == GPU_NEIGH || _gpu_mode == GPU_HYB_NEIGH) && - domain->triclinic) - error->all(FLERR,"Cannot use package gpu neigh yes with triclinic box"); - #ifndef _OPENMP if (nthreads > 1) error->all(FLERR,"No OpenMP support compiled in"); @@ -171,7 +171,8 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : if (binsize == 0.0) binsize = -1.0; int gpu_flag = lmp_init_device(universe->uworld, world, first_gpu, last_gpu, _gpu_mode, _particle_split, nthreads, - threads_per_atom, binsize, opencl_flags); + threads_per_atom, binsize, opencl_flags, + block_pair); GPU_EXTRA::check_flag(gpu_flag,error,world); } @@ -215,6 +216,17 @@ void FixGPU::init() error->all(FLERR,"GPU split param must be positive " "for hybrid pair styles"); + // neighbor list builds on the GPU with triclinic box is not yet supported + + if ((_gpu_mode == GPU_NEIGH || _gpu_mode == GPU_HYB_NEIGH) && + domain->triclinic) + error->all(FLERR,"Cannot use package gpu neigh yes with triclinic box"); + + // give a warning if no pair style is defined + + if (!force->pair) + error->warning(FLERR,"Using package gpu without any pair style defined"); + // make sure fdotr virial is not accumulated multiple times if (force->pair_match("hybrid",1) != NULL) { @@ -246,7 +258,7 @@ void FixGPU::setup(int vflag) if (strstr(update->integrate_style,"verlet")) post_force(vflag); else { - // in setup only, all forces calculated on GPU are put in the outer level + // In setup only, all forces calculated on GPU are put in the outer level ((Respa *) update->integrate)->copy_flevel_f(_nlevels_respa-1); post_force(vflag); ((Respa *) update->integrate)->copy_f_flevel(_nlevels_respa-1); @@ -264,6 +276,8 @@ void FixGPU::min_setup(int vflag) void FixGPU::post_force(int vflag) { + if (!force->pair) return; + timer->stamp(); double lvirial[6]; for (int i = 0; i < 6; i++) lvirial[i] = 0.0; diff --git a/src/GPU/pair_lj_cut_coul_long_gpu.cpp b/src/GPU/pair_lj_cut_coul_long_gpu.cpp index 5b367ec6bf..166649f6d9 100644 --- a/src/GPU/pair_lj_cut_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_long_gpu.cpp @@ -56,6 +56,9 @@ int ljcl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, double **host_cut_ljsq, double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double g_ewald); +int ljcl_gpu_reinit(const int ntypes, double **cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, double **host_lj4, + double **offset, double **host_lj_cutsq); void ljcl_gpu_clear(); int ** ljcl_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, @@ -79,7 +82,6 @@ PairLJCutCoulLongGPU::PairLJCutCoulLongGPU(LAMMPS *lmp) : PairLJCutCoulLong(lmp), gpu_mode(GPU_FORCE) { respa_enable = 0; - reinitflag = 0; cpu_time = 0.0; GPU_EXTRA::gpu_ready(lmp->modify, lmp->error); } @@ -195,6 +197,15 @@ void PairLJCutCoulLongGPU::init_style() /* ---------------------------------------------------------------------- */ +void PairLJCutCoulLongGPU::reinit() +{ + Pair::reinit(); + + ljcl_gpu_reinit(atom->ntypes+1, cutsq, lj1, lj2, lj3, lj4, offset, cut_ljsq); +} + +/* ---------------------------------------------------------------------- */ + double PairLJCutCoulLongGPU::memory_usage() { double bytes = Pair::memory_usage(); diff --git a/src/GPU/pair_lj_cut_coul_long_gpu.h b/src/GPU/pair_lj_cut_coul_long_gpu.h index 34b2a0e09f..231ed9d086 100644 --- a/src/GPU/pair_lj_cut_coul_long_gpu.h +++ b/src/GPU/pair_lj_cut_coul_long_gpu.h @@ -31,6 +31,7 @@ class PairLJCutCoulLongGPU : public PairLJCutCoulLong { void cpu_compute(int, int, int, int, int *, int *, int **); void compute(int, int); void init_style(); + void reinit(); double memory_usage(); enum { GPU_FORCE, GPU_NEIGH, GPU_HYB_NEIGH };