From 8a9e1676ebd63c709b44c979656a66a75057d170 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 27 Jun 2014 17:27:28 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12147 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/GPU/Install.sh | 4 ++++ src/GPU/pair_born_gpu.cpp | 15 ++++++++++++- src/GPU/pair_born_gpu.h | 1 + src/GPU/pair_buck_gpu.cpp | 14 +++++++++++- src/GPU/pair_buck_gpu.h | 1 + src/GPU/pair_coul_long_gpu.cpp | 19 +++++++++++++---- src/GPU/pair_coul_long_gpu.h | 1 + src/GPU/pair_gauss_gpu.cpp | 12 ++++++++++- src/GPU/pair_gauss_gpu.h | 1 + src/GPU/pair_lj_cut_gpu.cpp | 17 +++++++++++++-- src/GPU/pair_lj_cut_gpu.h | 1 + src/GPU/pair_lj_expand_gpu.cpp | 13 +++++++++++- src/GPU/pair_lj_expand_gpu.h | 1 + src/GPU/pair_soft_gpu.cpp | 12 ++++++++++- src/GPU/pair_soft_gpu.h | 1 + src/comm_tiled.cpp | 39 ++++++++++++++++++++++++++++++++-- src/pair_coul_debye.cpp | 6 ++++-- 17 files changed, 143 insertions(+), 15 deletions(-) diff --git a/src/GPU/Install.sh b/src/GPU/Install.sh index 7291a1491b..a83e5825da 100644 --- a/src/GPU/Install.sh +++ b/src/GPU/Install.sh @@ -43,6 +43,10 @@ action pair_buck_gpu.cpp pair_buck.cpp action pair_buck_gpu.h pair_buck.cpp action pair_colloid_gpu.cpp pair_colloid.cpp action pair_colloid_gpu.h pair_colloid.cpp +action pair_coul_cut_gpu.cpp +action pair_coul_cut_gpu.h +action pair_coul_debye_gpu.cpp +action pair_coul_debye_gpu.h action pair_coul_dsf_gpu.cpp action pair_coul_dsf_gpu.h action pair_coul_long_gpu.cpp pair_coul_long.cpp diff --git a/src/GPU/pair_born_gpu.cpp b/src/GPU/pair_born_gpu.cpp index c9f17cc5f1..19b28007e4 100644 --- a/src/GPU/pair_born_gpu.cpp +++ b/src/GPU/pair_born_gpu.cpp @@ -47,6 +47,10 @@ int born_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen); +void born_gpu_reinit(const int ntypes, double **host_rhoinv, + double **host_born1, double **host_born2, double **host_born3, + double **host_a, double **host_c, double **host_d, + double **offset); void born_gpu_clear(); int ** born_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, @@ -67,7 +71,6 @@ double born_gpu_bytes(); PairBornGPU::PairBornGPU(LAMMPS *lmp) : PairBorn(lmp), gpu_mode(GPU_FORCE) { respa_enable = 0; - reinitflag = 0; cpu_time = 0.0; GPU_EXTRA::gpu_ready(lmp->modify, lmp->error); } @@ -165,6 +168,16 @@ void PairBornGPU::init_style() /* ---------------------------------------------------------------------- */ +void PairBornGPU::reinit() +{ + Pair::reinit(); + + born_gpu_reinit(atom->ntypes+1, rhoinv, born1, born2, born3, + a, c, d, offset); +} + +/* ---------------------------------------------------------------------- */ + double PairBornGPU::memory_usage() { double bytes = Pair::memory_usage(); diff --git a/src/GPU/pair_born_gpu.h b/src/GPU/pair_born_gpu.h index 215ef2fa66..459b363a76 100644 --- a/src/GPU/pair_born_gpu.h +++ b/src/GPU/pair_born_gpu.h @@ -31,6 +31,7 @@ class PairBornGPU : public PairBorn { 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 }; diff --git a/src/GPU/pair_buck_gpu.cpp b/src/GPU/pair_buck_gpu.cpp index f663d7dd1d..a30164bac7 100644 --- a/src/GPU/pair_buck_gpu.cpp +++ b/src/GPU/pair_buck_gpu.cpp @@ -45,6 +45,9 @@ int buck_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv, double **offset, double *special_lj, const int inum, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen); +void buck_gpu_reinit(const int ntypes, double **cutsq, double **host_rhoinv, + double **host_buck1, double **host_buck2, + double **host_a, double **host_c, double **offset); void buck_gpu_clear(); int ** buck_gpu_compute_n(const int ago, const int inum_full, const int nall, double **host_x, int *host_type, double *sublo, @@ -65,7 +68,6 @@ double buck_gpu_bytes(); PairBuckGPU::PairBuckGPU(LAMMPS *lmp) : PairBuck(lmp), gpu_mode(GPU_FORCE) { respa_enable = 0; - reinitflag = 0; cpu_time = 0.0; GPU_EXTRA::gpu_ready(lmp->modify, lmp->error); } @@ -162,6 +164,16 @@ void PairBuckGPU::init_style() /* ---------------------------------------------------------------------- */ +void PairBuckGPU::reinit() +{ + Pair::reinit(); + + buck_gpu_reinit(atom->ntypes+1, cutsq, rhoinv, buck1, buck2, + a, c, offset); +} + +/* ---------------------------------------------------------------------- */ + double PairBuckGPU::memory_usage() { double bytes = Pair::memory_usage(); diff --git a/src/GPU/pair_buck_gpu.h b/src/GPU/pair_buck_gpu.h index b907bd501f..6e0074878c 100644 --- a/src/GPU/pair_buck_gpu.h +++ b/src/GPU/pair_buck_gpu.h @@ -31,6 +31,7 @@ class PairBuckGPU : public PairBuck { 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 }; diff --git a/src/GPU/pair_coul_long_gpu.cpp b/src/GPU/pair_coul_long_gpu.cpp index 31d925f4b0..76ee538da4 100644 --- a/src/GPU/pair_coul_long_gpu.cpp +++ b/src/GPU/pair_coul_long_gpu.cpp @@ -48,10 +48,12 @@ using namespace LAMMPS_NS; // External functions from cuda library for atom decomposition -int cl_gpu_init(const int nlocal, const int nall, const int max_nbors, +int cl_gpu_init(const int ntypes, double **scale, + const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen, double host_cut_coulsq, double *host_special_coul, const double qqrd2e, const double g_ewald); +void cl_gpu_reinit(const int ntypes, double **scale); void cl_gpu_clear(); int ** cl_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, @@ -75,7 +77,6 @@ PairCoulLongGPU::PairCoulLongGPU(LAMMPS *lmp) : PairCoulLong(lmp), gpu_mode(GPU_FORCE) { respa_enable = 0; - reinitflag = 0; cpu_time = 0.0; GPU_EXTRA::gpu_ready(lmp->modify, lmp->error); } @@ -144,7 +145,7 @@ void PairCoulLongGPU::init_style() error->all(FLERR,"Cannot use newton pair with coul/long/gpu pair style"); // Repeat cutsq calculation because done after call to init_style - double cell_size = sqrt(cut_coul) + neighbor->skin; + double cell_size = cut_coul + neighbor->skin; cut_coulsq = cut_coul * cut_coul; @@ -161,7 +162,8 @@ void PairCoulLongGPU::init_style() int maxspecial=0; if (atom->molecular) maxspecial=atom->maxspecial; - int success = cl_gpu_init(atom->nlocal, atom->nlocal+atom->nghost, 300, + int success = cl_gpu_init(atom->ntypes+1, scale, + atom->nlocal, atom->nlocal+atom->nghost, 300, maxspecial, cell_size, gpu_mode, screen, cut_coulsq, force->special_coul, force->qqrd2e, g_ewald); @@ -176,6 +178,15 @@ void PairCoulLongGPU::init_style() /* ---------------------------------------------------------------------- */ +void PairCoulLongGPU::reinit() +{ + Pair::reinit(); + + cl_gpu_reinit(atom->ntypes+1, scale); +} + +/* ---------------------------------------------------------------------- */ + double PairCoulLongGPU::memory_usage() { double bytes = Pair::memory_usage(); diff --git a/src/GPU/pair_coul_long_gpu.h b/src/GPU/pair_coul_long_gpu.h index a8eabd2a49..d67c20581e 100644 --- a/src/GPU/pair_coul_long_gpu.h +++ b/src/GPU/pair_coul_long_gpu.h @@ -31,6 +31,7 @@ class PairCoulLongGPU : public PairCoulLong { 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 }; diff --git a/src/GPU/pair_gauss_gpu.cpp b/src/GPU/pair_gauss_gpu.cpp index 8bfc774461..1fe5664423 100644 --- a/src/GPU/pair_gauss_gpu.cpp +++ b/src/GPU/pair_gauss_gpu.cpp @@ -44,6 +44,8 @@ int gauss_gpu_init(const int ntypes, double **cutsq, double **host_a, double **b, double **offset, double *special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen); +int gauss_gpu_reinit(const int ntypes, double **cutsq, double **host_a, + double **b, double **offset); void gauss_gpu_clear(); int ** gauss_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, @@ -64,7 +66,6 @@ double gauss_gpu_bytes(); PairGaussGPU::PairGaussGPU(LAMMPS *lmp) : PairGauss(lmp), gpu_mode(GPU_FORCE) { respa_enable = 0; - reinitflag = 0; cpu_time = 0.0; GPU_EXTRA::gpu_ready(lmp->modify, lmp->error); } @@ -161,6 +162,15 @@ void PairGaussGPU::init_style() /* ---------------------------------------------------------------------- */ +void PairGaussGPU::reinit() +{ + Pair::reinit(); + + gauss_gpu_reinit(atom->ntypes+1, cutsq, a, b, offset); +} + +/* ---------------------------------------------------------------------- */ + double PairGaussGPU::memory_usage() { double bytes = Pair::memory_usage(); diff --git a/src/GPU/pair_gauss_gpu.h b/src/GPU/pair_gauss_gpu.h index 39ce13e6a1..9581afa092 100644 --- a/src/GPU/pair_gauss_gpu.h +++ b/src/GPU/pair_gauss_gpu.h @@ -31,6 +31,7 @@ class PairGaussGPU : public PairGauss { 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 }; diff --git a/src/GPU/pair_lj_cut_gpu.cpp b/src/GPU/pair_lj_cut_gpu.cpp index 39485de7e7..6d0556bb31 100644 --- a/src/GPU/pair_lj_cut_gpu.cpp +++ b/src/GPU/pair_lj_cut_gpu.cpp @@ -44,6 +44,11 @@ int ljl_gpu_init(const int ntypes, double **cutsq, double **host_lj1, double **offset, double *special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen); + +int ljl_gpu_reinit(const int ntypes, double **cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, double **host_lj4, + double **offset); + void ljl_gpu_clear(); int ** ljl_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, @@ -64,7 +69,6 @@ double ljl_gpu_bytes(); PairLJCutGPU::PairLJCutGPU(LAMMPS *lmp) : PairLJCut(lmp), gpu_mode(GPU_FORCE) { respa_enable = 0; - reinitflag = 0; cpu_time = 0.0; GPU_EXTRA::gpu_ready(lmp->modify, lmp->error); } @@ -87,7 +91,7 @@ void PairLJCutGPU::compute(int eflag, int vflag) int nall = atom->nlocal + atom->nghost; int inum, host_start; - + bool success = true; int *ilist, *numneigh, **firstneigh; if (gpu_mode != GPU_FORCE) { @@ -163,6 +167,15 @@ void PairLJCutGPU::init_style() /* ---------------------------------------------------------------------- */ +void PairLJCutGPU::reinit() +{ + Pair::reinit(); + + ljl_gpu_reinit(atom->ntypes+1, cutsq, lj1, lj2, lj3, lj4, offset); +} + +/* ---------------------------------------------------------------------- */ + double PairLJCutGPU::memory_usage() { double bytes = Pair::memory_usage(); diff --git a/src/GPU/pair_lj_cut_gpu.h b/src/GPU/pair_lj_cut_gpu.h index 5f26e24461..4b54479b59 100644 --- a/src/GPU/pair_lj_cut_gpu.h +++ b/src/GPU/pair_lj_cut_gpu.h @@ -31,6 +31,7 @@ class PairLJCutGPU : public PairLJCut { 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 }; diff --git a/src/GPU/pair_lj_expand_gpu.cpp b/src/GPU/pair_lj_expand_gpu.cpp index 2a9ad13425..20185905e3 100644 --- a/src/GPU/pair_lj_expand_gpu.cpp +++ b/src/GPU/pair_lj_expand_gpu.cpp @@ -45,6 +45,9 @@ int lje_gpu_init(const int ntypes, double **cutsq, double **host_lj1, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen); +int lje_gpu_reinit(const int ntypes, double **cutsq, double **host_lj1, + double **host_lj2, double **host_lj3, double **host_lj4, + double **offset, double **shift); void lje_gpu_clear(); int ** lje_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, double *sublo, @@ -65,7 +68,6 @@ double lje_gpu_bytes(); PairLJExpandGPU::PairLJExpandGPU(LAMMPS *lmp) : PairLJExpand(lmp), gpu_mode(GPU_FORCE) { respa_enable = 0; - reinitflag = 0; cpu_time = 0.0; GPU_EXTRA::gpu_ready(lmp->modify, lmp->error); } @@ -162,6 +164,15 @@ void PairLJExpandGPU::init_style() /* ---------------------------------------------------------------------- */ +void PairLJExpandGPU::reinit() +{ + Pair::reinit(); + + lje_gpu_reinit(atom->ntypes+1, cutsq, lj1, lj2, lj3, lj4, offset, shift); +} + +/* ---------------------------------------------------------------------- */ + double PairLJExpandGPU::memory_usage() { double bytes = Pair::memory_usage(); diff --git a/src/GPU/pair_lj_expand_gpu.h b/src/GPU/pair_lj_expand_gpu.h index c0821b9ebd..c56b1e45c2 100644 --- a/src/GPU/pair_lj_expand_gpu.h +++ b/src/GPU/pair_lj_expand_gpu.h @@ -31,6 +31,7 @@ class PairLJExpandGPU : public PairLJExpand { 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 }; diff --git a/src/GPU/pair_soft_gpu.cpp b/src/GPU/pair_soft_gpu.cpp index 6d62d46147..14751febf9 100644 --- a/src/GPU/pair_soft_gpu.cpp +++ b/src/GPU/pair_soft_gpu.cpp @@ -45,6 +45,8 @@ int soft_gpu_init(const int ntypes, double **cutsq, double **prefactor, double **cut, double *special_lj, const int nlocal, const int nall, const int max_nbors, const int maxspecial, const double cell_size, int &gpu_mode, FILE *screen); +void soft_gpu_reinit(const int ntypes, double **cutsq, double **host_prefactor, + double **host_cut); void soft_gpu_clear(); int ** soft_gpu_compute_n(const int ago, const int inum, const int nall, double **host_x, int *host_type, @@ -68,7 +70,6 @@ using namespace MathConst; PairSoftGPU::PairSoftGPU(LAMMPS *lmp) : PairSoft(lmp), gpu_mode(GPU_FORCE) { respa_enable = 0; - reinitflag = 0; cpu_time = 0.0; GPU_EXTRA::gpu_ready(lmp->modify, lmp->error); } @@ -165,6 +166,15 @@ void PairSoftGPU::init_style() /* ---------------------------------------------------------------------- */ +void PairSoftGPU::reinit() +{ + Pair::reinit(); + + soft_gpu_reinit(atom->ntypes+1, cutsq, prefactor, cut); +} + +/* ---------------------------------------------------------------------- */ + double PairSoftGPU::memory_usage() { double bytes = Pair::memory_usage(); diff --git a/src/GPU/pair_soft_gpu.h b/src/GPU/pair_soft_gpu.h index fcc8372336..8f10327399 100644 --- a/src/GPU/pair_soft_gpu.h +++ b/src/GPU/pair_soft_gpu.h @@ -31,6 +31,7 @@ class PairSoftGPU : public PairSoft { 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 }; diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp index 1fca4e721b..9f111b999a 100644 --- a/src/comm_tiled.cpp +++ b/src/comm_tiled.cpp @@ -84,12 +84,39 @@ void CommTiled::init() void CommTiled::setup() { // error on triclinic or multi? - // set nswap + // set nswap = 2*dim // setup neighbor proc info for exchange() // setup nsendproc and nrecvproc bounts // setup sendproc and recvproc lists - // setup sendbox + // setup sendboxes // reallocate requests and statuses + + // check that cutoff is <= 1/2 of periodic box len? + + // loop over dims + // left: + // construct ghost boxes + // differnet in x,y,z + // account for ghost borders in y,z + // account for PBC by shifting + // split into multiple boxes if straddles PBC + // drop boxes down RCB tree + // count unique procs they cover + // what about self if crosses PBC + // for each proc they cover: + // compute box I send it to left + // is a message I will recv from right (don't care about box) + // for ghost-extended boxes + // do not count procs that do not overlap my owned box at all + // only touching edge of my owned box does not count + // in this case list I send to and recv from may be different? + // same thing to right + + // what need from decomp (RCB): + // dropbox: return list of procs with overlap and overlapping boxes + // return n, proclist, boxlist + // otherbox: bbox of another proc + // dropatom: return what proc owns the atom coord } /* ---------------------------------------------------------------------- @@ -249,6 +276,14 @@ void CommTiled::reverse_comm() void CommTiled::exchange() { + // loop over atoms + // if not outside my box, continue + // find which proc it is in + // find which one of my touching procs it is, else lost + // make sure all atoms are "lost" that should be (e.g. outside non-PBC) + // add to list to send to that proc + // loop over touching procs + // send buffer to them } /* ---------------------------------------------------------------------- diff --git a/src/pair_coul_debye.cpp b/src/pair_coul_debye.cpp index 150ab12fd1..c772961ec0 100644 --- a/src/pair_coul_debye.cpp +++ b/src/pair_coul_debye.cpp @@ -85,7 +85,8 @@ void PairCoulDebye::compute(int eflag, int vflag) r = sqrt(rsq); rinv = 1.0/r; screening = exp(-kappa*r); - forcecoul = qqrd2e * qtmp*q[j] * screening * (kappa + rinv); + forcecoul = qqrd2e * scale[itype][jtype] * + qtmp*q[j] * screening * (kappa + rinv); fpair = factor_coul*forcecoul * r2inv; f[i][0] += delx*fpair; @@ -97,7 +98,8 @@ void PairCoulDebye::compute(int eflag, int vflag) f[j][2] -= delz*fpair; } - if (eflag) ecoul = factor_coul * qqrd2e * qtmp*q[j] * rinv * screening; + if (eflag) ecoul = factor_coul * qqrd2e * + scale[itype][jtype] * qtmp*q[j] * rinv * screening; if (evflag) ev_tally(i,j,nlocal,newton_pair, 0.0,ecoul,fpair,delx,dely,delz);