Fixed bugs and added born/coul/long/cs/gpu and coul/long/cs/gpu, need tests
This commit is contained in:
@ -79,7 +79,9 @@ OBJS = $(OBJ_DIR)/lal_atom.o $(OBJ_DIR)/lal_ans.o \
|
|||||||
$(OBJ_DIR)/lal_lj_cubic.o $(OBJ_DIR)/lal_lj_cubic_ext.o \
|
$(OBJ_DIR)/lal_lj_cubic.o $(OBJ_DIR)/lal_lj_cubic_ext.o \
|
||||||
$(OBJ_DIR)/lal_ufm.o $(OBJ_DIR)/lal_ufm_ext.o \
|
$(OBJ_DIR)/lal_ufm.o $(OBJ_DIR)/lal_ufm_ext.o \
|
||||||
$(OBJ_DIR)/lal_dipole_long_lj.o $(OBJ_DIR)/lal_dipole_long_lj_ext.o \
|
$(OBJ_DIR)/lal_dipole_long_lj.o $(OBJ_DIR)/lal_dipole_long_lj_ext.o \
|
||||||
$(OBJ_DIR)/lal_lj_expand_coul_long.o $(OBJ_DIR)/lal_lj_expand_coul_long_ext.o
|
$(OBJ_DIR)/lal_lj_expand_coul_long.o $(OBJ_DIR)/lal_lj_expand_coul_long_ext.o \
|
||||||
|
$(OBJ_DIR)/lal_coul_long_cs.o $(OBJ_DIR)/lal_coul_long_cs_ext.o \
|
||||||
|
$(OBJ_DIR)/lal_born_coul_long_cs.o $(OBJ_DIR)/lal_born_coul_long_cs_ext.o
|
||||||
|
|
||||||
CBNS = $(OBJ_DIR)/device.cubin $(OBJ_DIR)/device_cubin.h \
|
CBNS = $(OBJ_DIR)/device.cubin $(OBJ_DIR)/device_cubin.h \
|
||||||
$(OBJ_DIR)/atom.cubin $(OBJ_DIR)/atom_cubin.h \
|
$(OBJ_DIR)/atom.cubin $(OBJ_DIR)/atom_cubin.h \
|
||||||
@ -137,7 +139,9 @@ CBNS = $(OBJ_DIR)/device.cubin $(OBJ_DIR)/device_cubin.h \
|
|||||||
$(OBJ_DIR)/lj_cubic.cubin $(OBJ_DIR)/lj_cubic_cubin.h \
|
$(OBJ_DIR)/lj_cubic.cubin $(OBJ_DIR)/lj_cubic_cubin.h \
|
||||||
$(OBJ_DIR)/ufm.cubin $(OBJ_DIR)/ufm_cubin.h \
|
$(OBJ_DIR)/ufm.cubin $(OBJ_DIR)/ufm_cubin.h \
|
||||||
$(OBJ_DIR)/dipole_long_lj.cubin $(OBJ_DIR)/dipole_long_lj_cubin.h \
|
$(OBJ_DIR)/dipole_long_lj.cubin $(OBJ_DIR)/dipole_long_lj_cubin.h \
|
||||||
$(OBJ_DIR)/lj_expand_coul_long.cubin $(OBJ_DIR)/lj_expand_coul_long_cubin.h
|
$(OBJ_DIR)/lj_expand_coul_long.cubin $(OBJ_DIR)/lj_expand_coul_long_cubin.h \
|
||||||
|
$(OBJ_DIR)/coul_long_cs.cubin $(OBJ_DIR)/coul_long_cs_cubin.h \
|
||||||
|
$(OBJ_DIR)/born_coul_long_cs.cubin $(OBJ_DIR)/born_coul_long_cs_cubin.h
|
||||||
|
|
||||||
all: $(OBJ_DIR) $(GPU_LIB) $(EXECS)
|
all: $(OBJ_DIR) $(GPU_LIB) $(EXECS)
|
||||||
|
|
||||||
@ -837,6 +841,30 @@ $(OBJ_DIR)/lal_lj_expand_coul_long.o: $(ALL_H) lal_lj_expand_coul_long.h lal_lj_
|
|||||||
$(OBJ_DIR)/lal_lj_expand_coul_long_ext.o: $(ALL_H) lal_lj_expand_coul_long.h lal_lj_expand_coul_long_ext.cpp lal_base_charge.h
|
$(OBJ_DIR)/lal_lj_expand_coul_long_ext.o: $(ALL_H) lal_lj_expand_coul_long.h lal_lj_expand_coul_long_ext.cpp lal_base_charge.h
|
||||||
$(CUDR) -o $@ -c lal_lj_expand_coul_long_ext.cpp -I$(OBJ_DIR)
|
$(CUDR) -o $@ -c lal_lj_expand_coul_long_ext.cpp -I$(OBJ_DIR)
|
||||||
|
|
||||||
|
$(OBJ_DIR)/coul_long_cs.cubin: lal_coul_long_cs.cu lal_precision.h lal_preprocessor.h
|
||||||
|
$(CUDA) --cubin -DNV_KERNEL -o $@ lal_coul_long_cs.cu
|
||||||
|
|
||||||
|
$(OBJ_DIR)/coul_long_cs_cubin.h: $(OBJ_DIR)/coul_long_cs.cubin $(OBJ_DIR)/coul_long_cs.cubin
|
||||||
|
$(BIN2C) -c -n coul_long_cs $(OBJ_DIR)/coul_long_cs.cubin > $(OBJ_DIR)/coul_long_cs_cubin.h
|
||||||
|
|
||||||
|
$(OBJ_DIR)/lal_coul_long_cs.o: $(ALL_H) lal_coul_long_cs.h lal_coul_long_cs.cpp $(OBJ_DIR)/coul_long_cs_cubin.h $(OBJ_DIR)/lal_base_charge.o
|
||||||
|
$(CUDR) -o $@ -c lal_coul_long_cs.cpp -I$(OBJ_DIR)
|
||||||
|
|
||||||
|
$(OBJ_DIR)/lal_coul_long_cs_ext.o: $(ALL_H) lal_coul_long_cs.h lal_coul_long_cs_ext.cpp lal_base_charge.h
|
||||||
|
$(CUDR) -o $@ -c lal_coul_long_cs_ext.cpp -I$(OBJ_DIR)
|
||||||
|
|
||||||
|
$(OBJ_DIR)/born_coul_long_cs.cubin: lal_born_coul_long_cs.cu lal_precision.h lal_preprocessor.h
|
||||||
|
$(CUDA) --cubin -DNV_KERNEL -o $@ lal_born_coul_long_cs.cu
|
||||||
|
|
||||||
|
$(OBJ_DIR)/born_coul_long_cs_cubin.h: $(OBJ_DIR)/born_coul_long_cs.cubin $(OBJ_DIR)/born_coul_long_cs.cubin
|
||||||
|
$(BIN2C) -c -n born_coul_long_cs $(OBJ_DIR)/born_coul_long_cs.cubin > $(OBJ_DIR)/born_coul_long_cs_cubin.h
|
||||||
|
|
||||||
|
$(OBJ_DIR)/lal_born_coul_long_cs.o: $(ALL_H) lal_born_coul_long_cs.h lal_born_coul_long_cs.cpp $(OBJ_DIR)/born_coul_long_cs_cubin.h $(OBJ_DIR)/lal_base_charge.o
|
||||||
|
$(CUDR) -o $@ -c lal_born_coul_long_cs.cpp -I$(OBJ_DIR)
|
||||||
|
|
||||||
|
$(OBJ_DIR)/lal_born_coul_long_cs_ext.o: $(ALL_H) lal_born_coul_long_cs.h lal_born_coul_long_cs_ext.cpp lal_base_charge.h
|
||||||
|
$(CUDR) -o $@ -c lal_born_coul_long_cs_ext.cpp -I$(OBJ_DIR)
|
||||||
|
|
||||||
$(BIN_DIR)/nvc_get_devices: ./geryon/ucl_get_devices.cpp $(NVD_H)
|
$(BIN_DIR)/nvc_get_devices: ./geryon/ucl_get_devices.cpp $(NVD_H)
|
||||||
$(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda
|
$(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,9 @@ OBJS = $(OBJ_DIR)/lal_atom.o $(OBJ_DIR)/lal_answer.o \
|
|||||||
$(OBJ_DIR)/lal_lj_cubic.o $(OBJ_DIR)/lal_lj_cubic_ext.o \
|
$(OBJ_DIR)/lal_lj_cubic.o $(OBJ_DIR)/lal_lj_cubic_ext.o \
|
||||||
$(OBJ_DIR)/lal_ufm.o $(OBJ_DIR)/lal_ufm_ext.o \
|
$(OBJ_DIR)/lal_ufm.o $(OBJ_DIR)/lal_ufm_ext.o \
|
||||||
$(OBJ_DIR)/lal_dipole_long_lj.o $(OBJ_DIR)/lal_dipole_long_lj_ext.o \
|
$(OBJ_DIR)/lal_dipole_long_lj.o $(OBJ_DIR)/lal_dipole_long_lj_ext.o \
|
||||||
$(OBJ_DIR)/lal_lj_expand_coul_long.o $(OBJ_DIR)/lal_lj_expand_coul_long_ext.o
|
$(OBJ_DIR)/lal_lj_expand_coul_long.o $(OBJ_DIR)/lal_lj_expand_coul_long_ext.o \
|
||||||
|
$(OBJ_DIR)/lal_coul_long_cs.o $(OBJ_DIR)/lal_coul_long_cs_ext.o \
|
||||||
|
$(OBJ_DIR)/lal_born_coul_long_cs.o $(OBJ_DIR)/lal_born_coul_long_cs_ext.o
|
||||||
|
|
||||||
KERS = $(OBJ_DIR)/device_cl.h $(OBJ_DIR)/atom_cl.h \
|
KERS = $(OBJ_DIR)/device_cl.h $(OBJ_DIR)/atom_cl.h \
|
||||||
$(OBJ_DIR)/neighbor_cpu_cl.h $(OBJ_DIR)/pppm_cl.h \
|
$(OBJ_DIR)/neighbor_cpu_cl.h $(OBJ_DIR)/pppm_cl.h \
|
||||||
@ -98,7 +100,8 @@ KERS = $(OBJ_DIR)/device_cl.h $(OBJ_DIR)/atom_cl.h \
|
|||||||
$(OBJ_DIR)/coul_debye_cl.h $(OBJ_DIR)/zbl_cl.h \
|
$(OBJ_DIR)/coul_debye_cl.h $(OBJ_DIR)/zbl_cl.h \
|
||||||
$(OBJ_DIR)/lj_cubic_cl.h $(OBJ_DIR)/vashishta_cl.h \
|
$(OBJ_DIR)/lj_cubic_cl.h $(OBJ_DIR)/vashishta_cl.h \
|
||||||
$(OBJ_DIR)/ufm_cl.h $(OBJ_DIR)/dipole_long_lj_cl.h \
|
$(OBJ_DIR)/ufm_cl.h $(OBJ_DIR)/dipole_long_lj_cl.h \
|
||||||
$(OBJ_DIR)/lj_expand_coul_long_cl.h
|
$(OBJ_DIR)/lj_expand_coul_long_cl.h $(OBJ_DIR)/coul_long_cs_cl.h \
|
||||||
|
$(OBJ_DIR)/born_coul_long_cs_cl.h
|
||||||
|
|
||||||
|
|
||||||
OCL_EXECS = $(BIN_DIR)/ocl_get_devices
|
OCL_EXECS = $(BIN_DIR)/ocl_get_devices
|
||||||
@ -609,6 +612,24 @@ $(OBJ_DIR)/lal_lj_expand_coul_long.o: $(ALL_H) lal_lj_expand_coul_long.h lal_lj_
|
|||||||
$(OBJ_DIR)/lal_lj_expand_coul_long_ext.o: $(ALL_H) lal_lj_expand_coul_long.h lal_lj_expand_coul_long_ext.cpp lal_base_charge.h
|
$(OBJ_DIR)/lal_lj_expand_coul_long_ext.o: $(ALL_H) lal_lj_expand_coul_long.h lal_lj_expand_coul_long_ext.cpp lal_base_charge.h
|
||||||
$(OCL) -o $@ -c lal_lj_expand_coul_long_ext.cpp -I$(OBJ_DIR)
|
$(OCL) -o $@ -c lal_lj_expand_coul_long_ext.cpp -I$(OBJ_DIR)
|
||||||
|
|
||||||
|
$(OBJ_DIR)/coul_long_cs_cl.h: lal_coul_long_cs.cu $(PRE1_H)
|
||||||
|
$(BSH) ./geryon/file_to_cstr.sh coul_long_cs $(PRE1_H) lal_coul_long_cs.cu $(OBJ_DIR)/coul_long_cs_cl.h;
|
||||||
|
|
||||||
|
$(OBJ_DIR)/lal_coul_long_cs.o: $(ALL_H) lal_coul_long_cs.h lal_coul_long_cs.cpp $(OBJ_DIR)/coul_long_cs_cl.h $(OBJ_DIR)/coul_long_cs_cl.h $(OBJ_DIR)/lal_base_charge.o
|
||||||
|
$(OCL) -o $@ -c lal_coul_long_cs.cpp -I$(OBJ_DIR)
|
||||||
|
|
||||||
|
$(OBJ_DIR)/lal_coul_long_cs_ext.o: $(ALL_H) lal_coul_long_cs.h lal_coul_long_cs_ext.cpp lal_base_charge.h
|
||||||
|
$(OCL) -o $@ -c lal_coul_long_cs_ext.cpp -I$(OBJ_DIR)
|
||||||
|
|
||||||
|
$(OBJ_DIR)/born_coul_long_cs_cl.h: lal_born_coul_long_cs.cu $(PRE1_H)
|
||||||
|
$(BSH) ./geryon/file_to_cstr.sh born_coul_long_cs $(PRE1_H) lal_born_coul_long_cs.cu $(OBJ_DIR)/born_coul_long_cs_cl.h;
|
||||||
|
|
||||||
|
$(OBJ_DIR)/lal_born_coul_long_cs.o: $(ALL_H) lal_born_coul_long_cs.h lal_born_coul_long_cs.cpp $(OBJ_DIR)/born_coul_long_cs_cl.h $(OBJ_DIR)/born_coul_long_cs_cl.h $(OBJ_DIR)/lal_base_charge.o
|
||||||
|
$(OCL) -o $@ -c lal_born_coul_long_cs.cpp -I$(OBJ_DIR)
|
||||||
|
|
||||||
|
$(OBJ_DIR)/lal_born_coul_long_cs_ext.o: $(ALL_H) lal_born_coul_long_cs.h lal_born_coul_long_cs_ext.cpp lal_base_charge.h
|
||||||
|
$(OCL) -o $@ -c lal_born_coul_long_cs_ext.cpp -I$(OBJ_DIR)
|
||||||
|
|
||||||
$(BIN_DIR)/ocl_get_devices: ./geryon/ucl_get_devices.cpp $(OCL_H)
|
$(BIN_DIR)/ocl_get_devices: ./geryon/ucl_get_devices.cpp $(OCL_H)
|
||||||
$(OCL) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_OPENCL $(OCL_LINK)
|
$(OCL) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_OPENCL $(OCL_LINK)
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,7 @@ int BornCoulLongT::init(const int ntypes, double **host_cutsq, double **host_rho
|
|||||||
const double g_ewald) {
|
const double g_ewald) {
|
||||||
int success;
|
int success;
|
||||||
success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split,
|
success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split,
|
||||||
_screen,born_coul_long,"k_born_long");
|
_screen,born_coul_long,"k_born_coul_long");
|
||||||
if (success!=0)
|
if (success!=0)
|
||||||
return success;
|
return success;
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ texture<int2> q_tex;
|
|||||||
#define q_tex q_
|
#define q_tex q_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__kernel void k_born_long(const __global numtyp4 *restrict x_,
|
__kernel void k_born_coul_long(const __global numtyp4 *restrict x_,
|
||||||
const __global numtyp4 *restrict coeff1,
|
const __global numtyp4 *restrict coeff1,
|
||||||
const __global numtyp4 *restrict coeff2,
|
const __global numtyp4 *restrict coeff2,
|
||||||
const int lj_types,
|
const int lj_types,
|
||||||
@ -110,7 +110,7 @@ __kernel void k_born_long(const __global numtyp4 *restrict x_,
|
|||||||
forcecoul = prefactor * (_erfc + EWALD_F*grij*expm2-factor_coul);
|
forcecoul = prefactor * (_erfc + EWALD_F*grij*expm2-factor_coul);
|
||||||
} else forcecoul = (numtyp)0.0;
|
} else forcecoul = (numtyp)0.0;
|
||||||
|
|
||||||
if (rsq < cutsq_sigma[mtype].y) {
|
if (rsq < cutsq_sigma[mtype].y) { // cut_ljsq
|
||||||
numtyp r = ucl_sqrt(rsq);
|
numtyp r = ucl_sqrt(rsq);
|
||||||
rexp = ucl_exp((cutsq_sigma[mtype].z-r)*coeff1[mtype].x);
|
rexp = ucl_exp((cutsq_sigma[mtype].z-r)*coeff1[mtype].x);
|
||||||
r6inv = r2inv*r2inv*r2inv;
|
r6inv = r2inv*r2inv*r2inv;
|
||||||
@ -127,7 +127,7 @@ __kernel void k_born_long(const __global numtyp4 *restrict x_,
|
|||||||
if (eflag>0) {
|
if (eflag>0) {
|
||||||
if (rsq < cut_coulsq)
|
if (rsq < cut_coulsq)
|
||||||
e_coul += prefactor*(_erfc-factor_coul);
|
e_coul += prefactor*(_erfc-factor_coul);
|
||||||
if (rsq < coeff1[mtype].w) {
|
if (rsq < cutsq_sigma[mtype].y) {
|
||||||
numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv
|
numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv
|
||||||
+ coeff2[mtype].z*r2inv*r6inv;
|
+ coeff2[mtype].z*r2inv*r6inv;
|
||||||
energy+=factor_lj*(e-coeff2[mtype].w);
|
energy+=factor_lj*(e-coeff2[mtype].w);
|
||||||
@ -149,7 +149,7 @@ __kernel void k_born_long(const __global numtyp4 *restrict x_,
|
|||||||
} // if ii
|
} // if ii
|
||||||
}
|
}
|
||||||
|
|
||||||
__kernel void k_born_long_fast(const __global numtyp4 *restrict x_,
|
__kernel void k_born_coul_long_fast(const __global numtyp4 *restrict x_,
|
||||||
const __global numtyp4 *restrict coeff1_in,
|
const __global numtyp4 *restrict coeff1_in,
|
||||||
const __global numtyp4 *restrict coeff2_in,
|
const __global numtyp4 *restrict coeff2_in,
|
||||||
const __global numtyp *restrict sp_lj_in,
|
const __global numtyp *restrict sp_lj_in,
|
||||||
@ -232,7 +232,7 @@ __kernel void k_born_long_fast(const __global numtyp4 *restrict x_,
|
|||||||
forcecoul = prefactor * (_erfc + EWALD_F*grij*expm2-factor_coul);
|
forcecoul = prefactor * (_erfc + EWALD_F*grij*expm2-factor_coul);
|
||||||
} else forcecoul = (numtyp)0.0;
|
} else forcecoul = (numtyp)0.0;
|
||||||
|
|
||||||
if (rsq < cutsq_sigma[mtype].y) {
|
if (rsq < cutsq_sigma[mtype].y) { // cut_ljsq
|
||||||
numtyp r = ucl_sqrt(rsq);
|
numtyp r = ucl_sqrt(rsq);
|
||||||
rexp = ucl_exp((cutsq_sigma[mtype].z-r)*coeff1[mtype].x);
|
rexp = ucl_exp((cutsq_sigma[mtype].z-r)*coeff1[mtype].x);
|
||||||
r6inv = r2inv*r2inv*r2inv;
|
r6inv = r2inv*r2inv*r2inv;
|
||||||
@ -249,7 +249,7 @@ __kernel void k_born_long_fast(const __global numtyp4 *restrict x_,
|
|||||||
if (eflag>0) {
|
if (eflag>0) {
|
||||||
if (rsq < cut_coulsq)
|
if (rsq < cut_coulsq)
|
||||||
e_coul += prefactor*(_erfc-factor_coul);
|
e_coul += prefactor*(_erfc-factor_coul);
|
||||||
if (rsq < coeff1[mtype].w) {
|
if (rsq < cutsq_sigma[mtype].y) {
|
||||||
numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv
|
numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv
|
||||||
+ coeff2[mtype].z*r2inv*r6inv;
|
+ coeff2[mtype].z*r2inv*r6inv;
|
||||||
energy+=factor_lj*(e-coeff2[mtype].w);
|
energy+=factor_lj*(e-coeff2[mtype].w);
|
||||||
|
|||||||
175
lib/gpu/lal_born_coul_long_cs.cpp
Normal file
175
lib/gpu/lal_born_coul_long_cs.cpp
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
born_coul_long_cs.cpp
|
||||||
|
-------------------
|
||||||
|
Trung Dac Nguyen (Northwestern)
|
||||||
|
|
||||||
|
Class for acceleration of the born/coul/long/cs pair style.
|
||||||
|
|
||||||
|
__________________________________________________________________________
|
||||||
|
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
|
||||||
|
__________________________________________________________________________
|
||||||
|
|
||||||
|
begin :
|
||||||
|
email : trung.nguyen@northwestern.edu
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifdef USE_OPENCL
|
||||||
|
#include "born_coul_long_cs_cl.h"
|
||||||
|
#elif defined(USE_CUDART)
|
||||||
|
const char *born_coul_long_cs=0;
|
||||||
|
#else
|
||||||
|
#include "born_coul_long_cs_cubin.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "lal_born_coul_long_cs.h"
|
||||||
|
#include <cassert>
|
||||||
|
using namespace LAMMPS_AL;
|
||||||
|
#define BornCoulLongCST BornCoulLongCS<numtyp, acctyp>
|
||||||
|
|
||||||
|
extern Device<PRECISION,ACC_PRECISION> device;
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
BornCoulLongCST::BornCoulLongCS() : BaseCharge<numtyp,acctyp>(),
|
||||||
|
_allocated(false) {
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
BornCoulLongCST::~BornCoulLongCS() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
int BornCoulLongCST::bytes_per_atom(const int max_nbors) const {
|
||||||
|
return this->bytes_per_atom_atomic(max_nbors);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
int BornCoulLongCST::init(const int ntypes, double **host_cutsq, double **host_rhoinv,
|
||||||
|
double **host_born1, double **host_born2, double **host_born3,
|
||||||
|
double **host_a, double **host_c, double **host_d,
|
||||||
|
double **host_sigma, double **host_offset,
|
||||||
|
double *host_special_lj, const int nlocal,
|
||||||
|
const int nall, const int max_nbors,
|
||||||
|
const int maxspecial, const double cell_size,
|
||||||
|
const double gpu_split, FILE *_screen,
|
||||||
|
double **host_cut_ljsq, const double host_cut_coulsq,
|
||||||
|
double *host_special_coul, const double qqrd2e,
|
||||||
|
const double g_ewald) {
|
||||||
|
int success;
|
||||||
|
success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split,
|
||||||
|
_screen,born_coul_long_cs,"k_born_coul_long_cs");
|
||||||
|
if (success!=0)
|
||||||
|
return success;
|
||||||
|
|
||||||
|
// If atom type constants fit in shared memory use fast kernel
|
||||||
|
int lj_types=ntypes;
|
||||||
|
shared_types=false;
|
||||||
|
int max_shared_types=this->device->max_shared_types();
|
||||||
|
if (lj_types<=max_shared_types && this->_block_size>=max_shared_types) {
|
||||||
|
lj_types=max_shared_types;
|
||||||
|
shared_types=true;
|
||||||
|
}
|
||||||
|
_lj_types=lj_types;
|
||||||
|
|
||||||
|
// Allocate a host write buffer for data initialization
|
||||||
|
UCL_H_Vec<numtyp> host_write(lj_types*lj_types*32,*(this->ucl_device),
|
||||||
|
UCL_WRITE_ONLY);
|
||||||
|
|
||||||
|
for (int i=0; i<lj_types*lj_types; i++)
|
||||||
|
host_write[i]=0.0;
|
||||||
|
|
||||||
|
coeff1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
|
||||||
|
this->atom->type_pack4(ntypes,lj_types,coeff1,host_write,host_rhoinv,
|
||||||
|
host_born1,host_born2,host_born3);
|
||||||
|
|
||||||
|
coeff2.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
|
||||||
|
this->atom->type_pack4(ntypes,lj_types,coeff2,host_write,host_a,host_c,
|
||||||
|
host_d,host_offset);
|
||||||
|
|
||||||
|
cutsq_sigma.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
|
||||||
|
this->atom->type_pack4(ntypes,lj_types,cutsq_sigma,host_write,host_cutsq,
|
||||||
|
host_cut_ljsq,host_sigma);
|
||||||
|
|
||||||
|
sp_lj.alloc(8,*(this->ucl_device),UCL_READ_ONLY);
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
host_write[i]=host_special_lj[i];
|
||||||
|
host_write[i+4]=host_special_coul[i];
|
||||||
|
}
|
||||||
|
ucl_copy(sp_lj,host_write,8,false);
|
||||||
|
|
||||||
|
_cut_coulsq=host_cut_coulsq;
|
||||||
|
_qqrd2e=qqrd2e;
|
||||||
|
_g_ewald=g_ewald;
|
||||||
|
|
||||||
|
_allocated=true;
|
||||||
|
this->_max_bytes=coeff1.row_bytes()+coeff2.row_bytes()
|
||||||
|
+cutsq_sigma.row_bytes()+sp_lj.row_bytes();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
void BornCoulLongCST::clear() {
|
||||||
|
if (!_allocated)
|
||||||
|
return;
|
||||||
|
_allocated=false;
|
||||||
|
|
||||||
|
coeff1.clear();
|
||||||
|
coeff2.clear();
|
||||||
|
cutsq_sigma.clear();
|
||||||
|
sp_lj.clear();
|
||||||
|
this->clear_atomic();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
double BornCoulLongCST::host_memory_usage() const {
|
||||||
|
return this->host_memory_usage_atomic()+sizeof(BornCoulLongCS<numtyp,acctyp>);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Calculate energies, forces, and torques
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
void BornCoulLongCST::loop(const bool _eflag, const bool _vflag) {
|
||||||
|
// Compute the block size and grid size to keep all cores busy
|
||||||
|
const int BX=this->block_size();
|
||||||
|
int eflag, vflag;
|
||||||
|
if (_eflag)
|
||||||
|
eflag=1;
|
||||||
|
else
|
||||||
|
eflag=0;
|
||||||
|
|
||||||
|
if (_vflag)
|
||||||
|
vflag=1;
|
||||||
|
else
|
||||||
|
vflag=0;
|
||||||
|
|
||||||
|
int GX=static_cast<int>(ceil(static_cast<double>(this->ans->inum())/
|
||||||
|
(BX/this->_threads_per_atom)));
|
||||||
|
|
||||||
|
int ainum=this->ans->inum();
|
||||||
|
int nbor_pitch=this->nbor->nbor_pitch();
|
||||||
|
this->time_pair.start();
|
||||||
|
if (shared_types) {
|
||||||
|
this->k_pair_fast.set_size(GX,BX);
|
||||||
|
this->k_pair_fast.run(&this->atom->x, &coeff1, &coeff2, &sp_lj,
|
||||||
|
&this->nbor->dev_nbor,
|
||||||
|
&this->_nbor_data->begin(),
|
||||||
|
&this->ans->force,
|
||||||
|
&this->ans->engv, &eflag, &vflag,
|
||||||
|
&ainum, &nbor_pitch, &this->atom->q,
|
||||||
|
&cutsq_sigma, &_cut_coulsq, &_qqrd2e,
|
||||||
|
&_g_ewald, &this->_threads_per_atom);
|
||||||
|
} else {
|
||||||
|
this->k_pair.set_size(GX,BX);
|
||||||
|
this->k_pair.run(&this->atom->x, &coeff1, &coeff2, &_lj_types, &sp_lj,
|
||||||
|
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
|
||||||
|
&this->ans->force, &this->ans->engv,
|
||||||
|
&eflag, &vflag, &ainum,
|
||||||
|
&nbor_pitch, &this->atom->q,
|
||||||
|
&cutsq_sigma, &_cut_coulsq,
|
||||||
|
&_qqrd2e, &_g_ewald, &this->_threads_per_atom);
|
||||||
|
}
|
||||||
|
this->time_pair.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
template class BornCoulLongCS<PRECISION,ACC_PRECISION>;
|
||||||
325
lib/gpu/lal_born_coul_long_cs.cu
Normal file
325
lib/gpu/lal_born_coul_long_cs.cu
Normal file
@ -0,0 +1,325 @@
|
|||||||
|
// **************************************************************************
|
||||||
|
// born_coul_long_cs.cu
|
||||||
|
// -------------------
|
||||||
|
// Trung Dac Nguyen (Northwestern)
|
||||||
|
//
|
||||||
|
// Device code for acceleration of the born/coul/long/cs pair style
|
||||||
|
//
|
||||||
|
// __________________________________________________________________________
|
||||||
|
// This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
|
||||||
|
// __________________________________________________________________________
|
||||||
|
//
|
||||||
|
// begin :
|
||||||
|
// email : trung.nguyen@northwestern.edu
|
||||||
|
// ***************************************************************************/
|
||||||
|
|
||||||
|
#ifdef NV_KERNEL
|
||||||
|
|
||||||
|
#include "lal_aux_fun1.h"
|
||||||
|
#ifndef _DOUBLE_DOUBLE
|
||||||
|
texture<float4> pos_tex;
|
||||||
|
texture<float> q_tex;
|
||||||
|
#else
|
||||||
|
texture<int4,1> pos_tex;
|
||||||
|
texture<int2> q_tex;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define pos_tex x_
|
||||||
|
#define q_tex q_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define B0 (numtyp)-0.1335096380159268
|
||||||
|
#define B1 (numtyp)-2.57839507e-1
|
||||||
|
#define B2 (numtyp)-1.37203639e-1
|
||||||
|
#define B3 (numtyp)-8.88822059e-3
|
||||||
|
#define B4 (numtyp)-5.80844129e-3
|
||||||
|
#define B5 (numtyp)1.14652755e-1
|
||||||
|
#define EPSILON (numtyp)1.0e-20
|
||||||
|
#define EPS_EWALD (numtyp)1.0e-6
|
||||||
|
#define EPS_EWALD_SQR (numtyp)1.0e-12
|
||||||
|
|
||||||
|
__kernel void k_born_coul_long_cs(const __global numtyp4 *restrict x_,
|
||||||
|
const __global numtyp4 *restrict coeff1,
|
||||||
|
const __global numtyp4 *restrict coeff2,
|
||||||
|
const int lj_types,
|
||||||
|
const __global numtyp *restrict sp_lj_in,
|
||||||
|
const __global int *dev_nbor,
|
||||||
|
const __global int *dev_packed,
|
||||||
|
__global acctyp4 *restrict ans,
|
||||||
|
__global acctyp *restrict engv,
|
||||||
|
const int eflag, const int vflag, const int inum,
|
||||||
|
const int nbor_pitch,
|
||||||
|
const __global numtyp *restrict q_,
|
||||||
|
const __global numtyp4 *restrict cutsq_sigma,
|
||||||
|
const numtyp cut_coulsq, const numtyp qqrd2e,
|
||||||
|
const numtyp g_ewald, const int t_per_atom) {
|
||||||
|
int tid, ii, offset;
|
||||||
|
atom_info(t_per_atom,ii,tid,offset);
|
||||||
|
|
||||||
|
__local numtyp sp_lj[8];
|
||||||
|
sp_lj[0]=sp_lj_in[0];
|
||||||
|
sp_lj[1]=sp_lj_in[1];
|
||||||
|
sp_lj[2]=sp_lj_in[2];
|
||||||
|
sp_lj[3]=sp_lj_in[3];
|
||||||
|
sp_lj[4]=sp_lj_in[4];
|
||||||
|
sp_lj[5]=sp_lj_in[5];
|
||||||
|
sp_lj[6]=sp_lj_in[6];
|
||||||
|
sp_lj[7]=sp_lj_in[7];
|
||||||
|
|
||||||
|
acctyp energy=(acctyp)0;
|
||||||
|
acctyp e_coul=(acctyp)0;
|
||||||
|
acctyp4 f;
|
||||||
|
f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0;
|
||||||
|
acctyp virial[6];
|
||||||
|
for (int i=0; i<6; i++)
|
||||||
|
virial[i]=(acctyp)0;
|
||||||
|
|
||||||
|
if (ii<inum) {
|
||||||
|
int nbor, nbor_end;
|
||||||
|
int i, numj;
|
||||||
|
__local int n_stride;
|
||||||
|
nbor_info(dev_nbor,dev_packed,nbor_pitch,t_per_atom,ii,offset,i,numj,
|
||||||
|
n_stride,nbor_end,nbor);
|
||||||
|
|
||||||
|
numtyp4 ix; fetch4(ix,i,pos_tex); //x_[i];
|
||||||
|
numtyp qtmp; fetch(qtmp,i,q_tex);
|
||||||
|
int itype=ix.w;
|
||||||
|
|
||||||
|
for ( ; nbor<nbor_end; nbor+=n_stride) {
|
||||||
|
int j=dev_packed[nbor];
|
||||||
|
|
||||||
|
numtyp factor_lj, factor_coul;
|
||||||
|
factor_lj = sp_lj[sbmask(j)];
|
||||||
|
factor_coul = sp_lj[sbmask(j)+4];
|
||||||
|
j &= NEIGHMASK;
|
||||||
|
|
||||||
|
numtyp4 jx; fetch4(jx,j,pos_tex); //x_[j];
|
||||||
|
int jtype=jx.w;
|
||||||
|
|
||||||
|
// Compute r12
|
||||||
|
numtyp delx = ix.x-jx.x;
|
||||||
|
numtyp dely = ix.y-jx.y;
|
||||||
|
numtyp delz = ix.z-jx.z;
|
||||||
|
numtyp rsq = delx*delx+dely*dely+delz*delz;
|
||||||
|
|
||||||
|
int mtype=itype*lj_types+jtype;
|
||||||
|
if (rsq<cutsq_sigma[mtype].x) { // cutsq
|
||||||
|
numtyp forcecoul, forceborn, force, r6inv, prefactor, _erfc;
|
||||||
|
numtyp rexp = (numtyp)0.0;
|
||||||
|
|
||||||
|
if (rsq < cut_coulsq) {
|
||||||
|
rsq += EPSILON;
|
||||||
|
|
||||||
|
numtyp r2inv = ucl_recip(rsq);
|
||||||
|
numtyp r = ucl_rsqrt(r2inv);
|
||||||
|
fetch(prefactor,j,q_tex);
|
||||||
|
prefactor *= qqrd2e * qtmp;
|
||||||
|
if (factor_coul<(numtyp)1.0) {
|
||||||
|
numtyp grij = g_ewald * (r+EPS_EWALD);
|
||||||
|
numtyp expm2 = ucl_exp(-grij*grij);
|
||||||
|
numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*grij);
|
||||||
|
numtyp u = (numtyp)1.0 - t;
|
||||||
|
_erfc = t * ((numtyp)1.0 + u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= (r+EPS_EWALD);
|
||||||
|
forcecoul = prefactor * (_erfc + EWALD_F*grij*expm2 - ((numtyp)1.0-factor_coul));
|
||||||
|
r2inv = ucl_recip(rsq + EPS_EWALD_SQR);
|
||||||
|
forcecoul *= r2inv;
|
||||||
|
} else {
|
||||||
|
numtyp grij = g_ewald * r;
|
||||||
|
numtyp expm2 = ucl_exp(-grij*grij);
|
||||||
|
numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*grij);
|
||||||
|
numtyp u = (numtyp)1.0 - t;
|
||||||
|
_erfc = t * ((numtyp)1.0 + u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= r;
|
||||||
|
forcecoul = prefactor*(_erfc + EWALD_F*grij*expm2);
|
||||||
|
forcecoul *= r2inv;
|
||||||
|
}
|
||||||
|
} else forcecoul = (numtyp)0.0;
|
||||||
|
|
||||||
|
numtyp r2inv = ucl_recip(rsq);
|
||||||
|
if (rsq < cutsq_sigma[mtype].y) { // cut_ljsq
|
||||||
|
numtyp r = ucl_sqrt(rsq);
|
||||||
|
rexp = ucl_exp((cutsq_sigma[mtype].z-r)*coeff1[mtype].x);
|
||||||
|
r6inv = r2inv*r2inv*r2inv;
|
||||||
|
forceborn = (coeff1[mtype].y*r*rexp - coeff1[mtype].z*r6inv
|
||||||
|
+ coeff1[mtype].w*r2inv*r6inv)*factor_lj;
|
||||||
|
} else forceborn = (numtyp)0.0;
|
||||||
|
|
||||||
|
force = forceborn*r2inv + forcecoul;
|
||||||
|
|
||||||
|
f.x+=delx*force;
|
||||||
|
f.y+=dely*force;
|
||||||
|
f.z+=delz*force;
|
||||||
|
|
||||||
|
if (eflag>0) {
|
||||||
|
if (rsq < cut_coulsq) {
|
||||||
|
e_coul += prefactor*_erfc;
|
||||||
|
if (factor_coul<(numtyp)1.0)
|
||||||
|
e_coul -= ((numtyp)1.0-factor_coul)*prefactor;
|
||||||
|
}
|
||||||
|
if (rsq < cutsq_sigma[mtype].y) {
|
||||||
|
numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv
|
||||||
|
+ coeff2[mtype].z*r2inv*r6inv;
|
||||||
|
energy+=factor_lj*(e-coeff2[mtype].w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (vflag>0) {
|
||||||
|
virial[0] += delx*delx*force;
|
||||||
|
virial[1] += dely*dely*force;
|
||||||
|
virial[2] += delz*delz*force;
|
||||||
|
virial[3] += delx*dely*force;
|
||||||
|
virial[4] += delx*delz*force;
|
||||||
|
virial[5] += dely*delz*force;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // for nbor
|
||||||
|
store_answers_q(f,energy,e_coul,virial,ii,inum,tid,t_per_atom,offset,eflag,
|
||||||
|
vflag,ans,engv);
|
||||||
|
} // if ii
|
||||||
|
}
|
||||||
|
|
||||||
|
__kernel void k_born_coul_long_cs_fast(const __global numtyp4 *restrict x_,
|
||||||
|
const __global numtyp4 *restrict coeff1_in,
|
||||||
|
const __global numtyp4 *restrict coeff2_in,
|
||||||
|
const __global numtyp *restrict sp_lj_in,
|
||||||
|
const __global int *dev_nbor,
|
||||||
|
const __global int *dev_packed,
|
||||||
|
__global acctyp4 *restrict ans,
|
||||||
|
__global acctyp *restrict engv,
|
||||||
|
const int eflag, const int vflag, const int inum,
|
||||||
|
const int nbor_pitch,
|
||||||
|
const __global numtyp *restrict q_,
|
||||||
|
const __global numtyp4 *restrict cutsq_sigma,
|
||||||
|
const numtyp cut_coulsq, const numtyp qqrd2e,
|
||||||
|
const numtyp g_ewald, const int t_per_atom) {
|
||||||
|
int tid, ii, offset;
|
||||||
|
atom_info(t_per_atom,ii,tid,offset);
|
||||||
|
|
||||||
|
__local numtyp4 coeff1[MAX_SHARED_TYPES*MAX_SHARED_TYPES];
|
||||||
|
__local numtyp4 coeff2[MAX_SHARED_TYPES*MAX_SHARED_TYPES];
|
||||||
|
__local numtyp sp_lj[8];
|
||||||
|
if (tid<8)
|
||||||
|
sp_lj[tid]=sp_lj_in[tid];
|
||||||
|
if (tid<MAX_SHARED_TYPES*MAX_SHARED_TYPES) {
|
||||||
|
coeff1[tid]=coeff1_in[tid];
|
||||||
|
if (eflag>0)
|
||||||
|
coeff2[tid]=coeff2_in[tid];
|
||||||
|
}
|
||||||
|
|
||||||
|
acctyp energy=(acctyp)0;
|
||||||
|
acctyp e_coul=(acctyp)0;
|
||||||
|
acctyp4 f;
|
||||||
|
f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0;
|
||||||
|
acctyp virial[6];
|
||||||
|
for (int i=0; i<6; i++)
|
||||||
|
virial[i]=(acctyp)0;
|
||||||
|
|
||||||
|
__syncthreads();
|
||||||
|
|
||||||
|
if (ii<inum) {
|
||||||
|
int nbor, nbor_end;
|
||||||
|
int i, numj;
|
||||||
|
__local int n_stride;
|
||||||
|
nbor_info(dev_nbor,dev_packed,nbor_pitch,t_per_atom,ii,offset,i,numj,
|
||||||
|
n_stride,nbor_end,nbor);
|
||||||
|
|
||||||
|
numtyp4 ix; fetch4(ix,i,pos_tex); //x_[i];
|
||||||
|
numtyp qtmp; fetch(qtmp,i,q_tex);
|
||||||
|
int iw=ix.w;
|
||||||
|
int itype=fast_mul((int)MAX_SHARED_TYPES,iw);
|
||||||
|
|
||||||
|
for ( ; nbor<nbor_end; nbor+=n_stride) {
|
||||||
|
int j=dev_packed[nbor];
|
||||||
|
|
||||||
|
numtyp factor_lj, factor_coul;
|
||||||
|
factor_lj = sp_lj[sbmask(j)];
|
||||||
|
factor_coul = sp_lj[sbmask(j)+4];
|
||||||
|
j &= NEIGHMASK;
|
||||||
|
|
||||||
|
numtyp4 jx; fetch4(jx,j,pos_tex); //x_[j];
|
||||||
|
int mtype=itype+jx.w;
|
||||||
|
|
||||||
|
// Compute r12
|
||||||
|
numtyp delx = ix.x-jx.x;
|
||||||
|
numtyp dely = ix.y-jx.y;
|
||||||
|
numtyp delz = ix.z-jx.z;
|
||||||
|
numtyp rsq = delx*delx+dely*dely+delz*delz;
|
||||||
|
|
||||||
|
if (rsq<cutsq_sigma[mtype].x) { // cutsq
|
||||||
|
numtyp forcecoul, forceborn, force, r6inv, prefactor, _erfc;
|
||||||
|
numtyp rexp = (numtyp)0.0;
|
||||||
|
|
||||||
|
if (rsq < cut_coulsq) {
|
||||||
|
rsq += EPSILON;
|
||||||
|
|
||||||
|
numtyp r2inv = ucl_recip(rsq);
|
||||||
|
numtyp r = ucl_rsqrt(r2inv);
|
||||||
|
fetch(prefactor,j,q_tex);
|
||||||
|
prefactor *= qqrd2e * qtmp;
|
||||||
|
if (factor_coul<(numtyp)1.0) {
|
||||||
|
numtyp grij = g_ewald * (r+EPS_EWALD);
|
||||||
|
numtyp expm2 = ucl_exp(-grij*grij);
|
||||||
|
numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*grij);
|
||||||
|
numtyp u = (numtyp)1.0 - t;
|
||||||
|
_erfc = t * ((numtyp)1.0 + u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= (r+EPS_EWALD);
|
||||||
|
forcecoul = prefactor * (_erfc + EWALD_F*grij*expm2 - ((numtyp)1.0-factor_coul));
|
||||||
|
r2inv = ucl_recip(rsq + EPS_EWALD_SQR);
|
||||||
|
forcecoul *= r2inv;
|
||||||
|
} else {
|
||||||
|
numtyp grij = g_ewald * r;
|
||||||
|
numtyp expm2 = ucl_exp(-grij*grij);
|
||||||
|
numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*grij);
|
||||||
|
numtyp u = (numtyp)1.0 - t;
|
||||||
|
_erfc = t * ((numtyp)1.0 + u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= r;
|
||||||
|
forcecoul = prefactor*(_erfc + EWALD_F*grij*expm2);
|
||||||
|
forcecoul *= r2inv;
|
||||||
|
}
|
||||||
|
} else forcecoul = (numtyp)0.0;
|
||||||
|
|
||||||
|
numtyp r2inv = ucl_recip(rsq);
|
||||||
|
if (rsq < cutsq_sigma[mtype].y) { // cut_ljsq
|
||||||
|
numtyp r = ucl_sqrt(rsq);
|
||||||
|
rexp = ucl_exp((cutsq_sigma[mtype].z-r)*coeff1[mtype].x);
|
||||||
|
r6inv = r2inv*r2inv*r2inv;
|
||||||
|
forceborn = (coeff1[mtype].y*r*rexp - coeff1[mtype].z*r6inv
|
||||||
|
+ coeff1[mtype].w*r2inv*r6inv)*factor_lj;
|
||||||
|
} else forceborn = (numtyp)0.0;
|
||||||
|
|
||||||
|
force = forceborn*r2inv + forcecoul;
|
||||||
|
|
||||||
|
f.x+=delx*force;
|
||||||
|
f.y+=dely*force;
|
||||||
|
f.z+=delz*force;
|
||||||
|
|
||||||
|
if (eflag>0) {
|
||||||
|
if (rsq < cut_coulsq) {
|
||||||
|
e_coul += prefactor*_erfc;
|
||||||
|
if (factor_coul<(numtyp)1.0)
|
||||||
|
e_coul -= ((numtyp)1.0-factor_coul)*prefactor;
|
||||||
|
}
|
||||||
|
if (rsq < cutsq_sigma[mtype].y) {
|
||||||
|
numtyp e=coeff2[mtype].x*rexp - coeff2[mtype].y*r6inv
|
||||||
|
+ coeff2[mtype].z*r2inv*r6inv;
|
||||||
|
energy+=factor_lj*(e-coeff2[mtype].w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (vflag>0) {
|
||||||
|
virial[0] += delx*delx*force;
|
||||||
|
virial[1] += dely*dely*force;
|
||||||
|
virial[2] += delz*delz*force;
|
||||||
|
virial[3] += delx*dely*force;
|
||||||
|
virial[4] += delx*delz*force;
|
||||||
|
virial[5] += dely*delz*force;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // for nbor
|
||||||
|
store_answers_q(f,energy,e_coul,virial,ii,inum,tid,t_per_atom,offset,eflag,
|
||||||
|
vflag,ans,engv);
|
||||||
|
} // if ii
|
||||||
|
}
|
||||||
|
|
||||||
88
lib/gpu/lal_born_coul_long_cs.h
Normal file
88
lib/gpu/lal_born_coul_long_cs.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
born_coul_long.h
|
||||||
|
-------------------
|
||||||
|
Trung Dac Nguyen (ORNL)
|
||||||
|
|
||||||
|
Class for acceleration of the born/coul/long/cs pair style.
|
||||||
|
|
||||||
|
__________________________________________________________________________
|
||||||
|
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
|
||||||
|
__________________________________________________________________________
|
||||||
|
|
||||||
|
begin :
|
||||||
|
email : trung.nguyen@northwestern.edu
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LAL_BORN_COUL_LONG_CS_H
|
||||||
|
#define LAL_BORN_COUL_LONG_CS_H
|
||||||
|
|
||||||
|
#include "lal_base_charge.h"
|
||||||
|
|
||||||
|
namespace LAMMPS_AL {
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
class BornCoulLongCS : public BaseCharge<numtyp, acctyp> {
|
||||||
|
public:
|
||||||
|
BornCoulLongCS();
|
||||||
|
~BornCoulLongCS();
|
||||||
|
|
||||||
|
/// Clear any previous data and set up for a new LAMMPS run
|
||||||
|
/** \param max_nbors initial number of rows in the neighbor matrix
|
||||||
|
* \param cell_size cutoff + skin
|
||||||
|
* \param gpu_split fraction of particles handled by device
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* - 0 if successfull
|
||||||
|
* - -1 if fix gpu not found
|
||||||
|
* - -3 if there is an out of memory error
|
||||||
|
* - -4 if the GPU library was not compiled for GPU
|
||||||
|
* - -5 Double precision is not supported on card **/
|
||||||
|
int init(const int ntypes, double **host_cutsq, double **host_rhoinv,
|
||||||
|
double **host_born1, double **host_born2, double **host_born3,
|
||||||
|
double **host_a, double **host_c, double **host_d,
|
||||||
|
double **host_sigma, double **host_offset, double *host_special_lj,
|
||||||
|
const int nlocal, const int nall, const int max_nbors,
|
||||||
|
const int maxspecial, const double cell_size,
|
||||||
|
const double gpu_split, FILE *screen, double **host_cut_ljsq,
|
||||||
|
const double host_cut_coulsq, double *host_special_coul,
|
||||||
|
const double qqrd2e, const double g_ewald);
|
||||||
|
|
||||||
|
/// Clear all host and device data
|
||||||
|
/** \note This is called at the beginning of the init() routine **/
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
/// Returns memory usage on device per atom
|
||||||
|
int bytes_per_atom(const int max_nbors) const;
|
||||||
|
|
||||||
|
/// Total host memory used by library for pair style
|
||||||
|
double host_memory_usage() const;
|
||||||
|
|
||||||
|
// --------------------------- TYPE DATA --------------------------
|
||||||
|
|
||||||
|
/// coeff1.x = rhoinv, coeff1.y = born1, coeff1.z = born2,
|
||||||
|
/// coeff1.w = born3
|
||||||
|
UCL_D_Vec<numtyp4> coeff1;
|
||||||
|
/// coeff2.x = a, coeff2.y = c, coeff2.z = d, coeff2.w = offset
|
||||||
|
UCL_D_Vec<numtyp4> coeff2;
|
||||||
|
/// cutsq_sigma.x = cutsq, cutsq_sigma.y = cutsq_lj,
|
||||||
|
/// cutsq_sigma.z = sigma
|
||||||
|
UCL_D_Vec<numtyp4> cutsq_sigma;
|
||||||
|
/// Special LJ values [0-3] and Special Coul values [4-7]
|
||||||
|
UCL_D_Vec<numtyp> sp_lj;
|
||||||
|
|
||||||
|
/// If atom type constants fit in shared memory, use fast kernels
|
||||||
|
bool shared_types;
|
||||||
|
|
||||||
|
/// Number of atom types
|
||||||
|
int _lj_types;
|
||||||
|
|
||||||
|
numtyp _cut_coulsq, _qqrd2e, _g_ewald;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _allocated;
|
||||||
|
void loop(const bool _eflag, const bool _vflag);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
132
lib/gpu/lal_born_coul_long_cs_ext.cpp
Normal file
132
lib/gpu/lal_born_coul_long_cs_ext.cpp
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
born_coul_long_cs_ext.cpp
|
||||||
|
-------------------
|
||||||
|
Trung Dac Nguyen (ORNL)
|
||||||
|
|
||||||
|
Functions for LAMMPS access to born/coul/long/cs acceleration routines.
|
||||||
|
|
||||||
|
__________________________________________________________________________
|
||||||
|
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
|
||||||
|
__________________________________________________________________________
|
||||||
|
|
||||||
|
begin :
|
||||||
|
email : trung.nguyen@northwestern.edu
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "lal_born_coul_long_cs.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace LAMMPS_AL;
|
||||||
|
|
||||||
|
static BornCoulLongCS<PRECISION,ACC_PRECISION> BCLCSMF;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Allocate memory on host and device and copy constants to device
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
int bornclcs_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv,
|
||||||
|
double **host_born1, double **host_born2, double **host_born3,
|
||||||
|
double **host_a, double **host_c, double **host_d,
|
||||||
|
double **sigma, 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, double **host_cut_ljsq, double host_cut_coulsq,
|
||||||
|
double *host_special_coul, const double qqrd2e,
|
||||||
|
const double g_ewald) {
|
||||||
|
BCLCSMF.clear();
|
||||||
|
gpu_mode=BCLCSMF.device->gpu_mode();
|
||||||
|
double gpu_split=BCLCSMF.device->particle_split();
|
||||||
|
int first_gpu=BCLCSMF.device->first_device();
|
||||||
|
int last_gpu=BCLCSMF.device->last_device();
|
||||||
|
int world_me=BCLCSMF.device->world_me();
|
||||||
|
int gpu_rank=BCLCSMF.device->gpu_rank();
|
||||||
|
int procs_per_gpu=BCLCSMF.device->procs_per_gpu();
|
||||||
|
|
||||||
|
BCLCSMF.device->init_message(screen,"born/coul/long/cs",first_gpu,last_gpu);
|
||||||
|
|
||||||
|
bool message=false;
|
||||||
|
if (BCLCSMF.device->replica_me()==0 && screen)
|
||||||
|
message=true;
|
||||||
|
|
||||||
|
if (message) {
|
||||||
|
fprintf(screen,"Initializing Device and compiling on process 0...");
|
||||||
|
fflush(screen);
|
||||||
|
}
|
||||||
|
|
||||||
|
int init_ok=0;
|
||||||
|
if (world_me==0)
|
||||||
|
init_ok=BCLCSMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2,
|
||||||
|
host_born3, host_a, host_c, host_d, sigma, offset,
|
||||||
|
special_lj, inum, nall, 300, maxspecial, cell_size,
|
||||||
|
gpu_split, screen, host_cut_ljsq, host_cut_coulsq,
|
||||||
|
host_special_coul, qqrd2e, g_ewald);
|
||||||
|
|
||||||
|
BCLCSMF.device->world_barrier();
|
||||||
|
if (message)
|
||||||
|
fprintf(screen,"Done.\n");
|
||||||
|
|
||||||
|
for (int i=0; i<procs_per_gpu; i++) {
|
||||||
|
if (message) {
|
||||||
|
if (last_gpu-first_gpu==0)
|
||||||
|
fprintf(screen,"Initializing Device %d on core %d...",first_gpu,i);
|
||||||
|
else
|
||||||
|
fprintf(screen,"Initializing Devices %d-%d on core %d...",first_gpu,
|
||||||
|
last_gpu,i);
|
||||||
|
fflush(screen);
|
||||||
|
}
|
||||||
|
if (gpu_rank==i && world_me!=0)
|
||||||
|
init_ok=BCLCSMF.init(ntypes, cutsq, host_rhoinv, host_born1, host_born2,
|
||||||
|
host_born3, host_a, host_c, host_d, sigma, offset,
|
||||||
|
special_lj, inum, nall, 300, maxspecial, cell_size,
|
||||||
|
gpu_split, screen, host_cut_ljsq, host_cut_coulsq,
|
||||||
|
host_special_coul, qqrd2e, g_ewald);
|
||||||
|
|
||||||
|
BCLCSMF.device->gpu_barrier();
|
||||||
|
if (message)
|
||||||
|
fprintf(screen,"Done.\n");
|
||||||
|
}
|
||||||
|
if (message)
|
||||||
|
fprintf(screen,"\n");
|
||||||
|
|
||||||
|
if (init_ok==0)
|
||||||
|
BCLCSMF.estimate_gpu_overhead();
|
||||||
|
return init_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bornclcs_gpu_clear() {
|
||||||
|
BCLCSMF.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int** bornclcs_gpu_compute_n(const int ago, const int inum_full,
|
||||||
|
const int nall, double **host_x, int *host_type,
|
||||||
|
double *sublo, double *subhi, tagint *tag, int **nspecial,
|
||||||
|
tagint **special, const bool eflag, const bool vflag,
|
||||||
|
const bool eatom, const bool vatom, int &host_start,
|
||||||
|
int **ilist, int **jnum, const double cpu_time,
|
||||||
|
bool &success, double *host_q, double *boxlo,
|
||||||
|
double *prd) {
|
||||||
|
return BCLCSMF.compute(ago, inum_full, nall, host_x, host_type, sublo,
|
||||||
|
subhi, tag, nspecial, special, eflag, vflag, eatom,
|
||||||
|
vatom, host_start, ilist, jnum, cpu_time, success,
|
||||||
|
host_q, boxlo, prd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bornclcs_gpu_compute(const int ago, const int inum_full, const int nall,
|
||||||
|
double **host_x, int *host_type, int *ilist, int *numj,
|
||||||
|
int **firstneigh, const bool eflag, const bool vflag,
|
||||||
|
const bool eatom, const bool vatom, int &host_start,
|
||||||
|
const double cpu_time, bool &success, double *host_q,
|
||||||
|
const int nlocal, double *boxlo, double *prd) {
|
||||||
|
BCLCSMF.compute(ago,inum_full,nall,host_x,host_type,ilist,numj,
|
||||||
|
firstneigh,eflag,vflag,eatom,vatom,host_start,cpu_time,success,
|
||||||
|
host_q,nlocal,boxlo,prd);
|
||||||
|
}
|
||||||
|
|
||||||
|
double bornclcs_gpu_bytes() {
|
||||||
|
return BCLCSMF.host_memory_usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
158
lib/gpu/lal_coul_long_cs.cpp
Normal file
158
lib/gpu/lal_coul_long_cs.cpp
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
coul_long_cs.cpp
|
||||||
|
-------------------
|
||||||
|
Trung Nguyen (Northwestern)
|
||||||
|
|
||||||
|
Class for acceleration of the coul/long pair style.
|
||||||
|
|
||||||
|
__________________________________________________________________________
|
||||||
|
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
|
||||||
|
__________________________________________________________________________
|
||||||
|
|
||||||
|
begin : June 2018
|
||||||
|
email : trung.nguyen@northwestern.edu
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#if defined(USE_OPENCL)
|
||||||
|
#include "coul_long_cs_cl.h"
|
||||||
|
#elif defined(USE_CUDART)
|
||||||
|
const char *coul_long_cs=0;
|
||||||
|
#else
|
||||||
|
#include "coul_long_cs_cubin.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "lal_coul_long_cs.h"
|
||||||
|
#include <cassert>
|
||||||
|
using namespace LAMMPS_AL;
|
||||||
|
#define CoulLongCST CoulLongCS<numtyp, acctyp>
|
||||||
|
|
||||||
|
extern Device<PRECISION,ACC_PRECISION> pair_gpu_device;
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
CoulLongCST::CoulLongCS() : BaseCharge<numtyp,acctyp>(), _allocated(false) {
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
CoulLongCST::~CoulLongCS() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
int CoulLongCST::bytes_per_atom(const int max_nbors) const {
|
||||||
|
return this->bytes_per_atom_atomic(max_nbors);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
int CoulLongCST::init(const int ntypes, double **host_scale,
|
||||||
|
const int nlocal, const int nall, const int max_nbors,
|
||||||
|
const int maxspecial, const double cell_size,
|
||||||
|
const double gpu_split, FILE *_screen,
|
||||||
|
const double host_cut_coulsq, double *host_special_coul,
|
||||||
|
const double qqrd2e, const double g_ewald) {
|
||||||
|
int success;
|
||||||
|
success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,
|
||||||
|
gpu_split,_screen,coul_long_cs,"k_coul_long_cs");
|
||||||
|
if (success!=0)
|
||||||
|
return success;
|
||||||
|
|
||||||
|
int lj_types=ntypes;
|
||||||
|
shared_types=false;
|
||||||
|
int max_shared_types=this->device->max_shared_types();
|
||||||
|
if (lj_types<=max_shared_types && this->_block_size>=max_shared_types) {
|
||||||
|
lj_types=max_shared_types;
|
||||||
|
shared_types=true;
|
||||||
|
}
|
||||||
|
_lj_types=lj_types;
|
||||||
|
|
||||||
|
// Allocate a host write buffer for data initialization
|
||||||
|
UCL_H_Vec<numtyp> host_write(lj_types*lj_types*32,*(this->ucl_device),
|
||||||
|
UCL_WRITE_ONLY);
|
||||||
|
|
||||||
|
for (int i=0; i<lj_types*lj_types; i++)
|
||||||
|
host_write[i]=0.0;
|
||||||
|
|
||||||
|
scale.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
|
||||||
|
this->atom->type_pack1(ntypes,lj_types,scale,host_write,host_scale);
|
||||||
|
|
||||||
|
sp_cl.alloc(4,*(this->ucl_device),UCL_READ_ONLY);
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
host_write[i]=host_special_coul[i];
|
||||||
|
}
|
||||||
|
ucl_copy(sp_cl,host_write,4,false);
|
||||||
|
|
||||||
|
_cut_coulsq=host_cut_coulsq;
|
||||||
|
_qqrd2e=qqrd2e;
|
||||||
|
_g_ewald=g_ewald;
|
||||||
|
|
||||||
|
_allocated=true;
|
||||||
|
this->_max_bytes=scale.row_bytes()+sp_cl.row_bytes();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
void CoulLongCST::reinit(const int ntypes, double **host_scale) {
|
||||||
|
UCL_H_Vec<numtyp> hscale(_lj_types*_lj_types,*(this->ucl_device),
|
||||||
|
UCL_WRITE_ONLY);
|
||||||
|
this->atom->type_pack1(ntypes,_lj_types,scale,hscale,host_scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
void CoulLongCST::clear() {
|
||||||
|
if (!_allocated)
|
||||||
|
return;
|
||||||
|
_allocated=false;
|
||||||
|
|
||||||
|
scale.clear();
|
||||||
|
sp_cl.clear();
|
||||||
|
this->clear_atomic();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
double CoulLongCST::host_memory_usage() const {
|
||||||
|
return this->host_memory_usage_atomic()+sizeof(CoulLongCS<numtyp,acctyp>);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Calculate energies, forces, and torques
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
void CoulLongCST::loop(const bool _eflag, const bool _vflag) {
|
||||||
|
// Compute the block size and grid size to keep all cores busy
|
||||||
|
const int BX=this->block_size();
|
||||||
|
int eflag, vflag;
|
||||||
|
if (_eflag)
|
||||||
|
eflag=1;
|
||||||
|
else
|
||||||
|
eflag=0;
|
||||||
|
|
||||||
|
if (_vflag)
|
||||||
|
vflag=1;
|
||||||
|
else
|
||||||
|
vflag=0;
|
||||||
|
|
||||||
|
int GX=static_cast<int>(ceil(static_cast<double>(this->ans->inum())/
|
||||||
|
(BX/this->_threads_per_atom)));
|
||||||
|
|
||||||
|
int ainum=this->ans->inum();
|
||||||
|
int nbor_pitch=this->nbor->nbor_pitch();
|
||||||
|
this->time_pair.start();
|
||||||
|
if (shared_types) {
|
||||||
|
this->k_pair_fast.set_size(GX,BX);
|
||||||
|
this->k_pair_fast.run(&this->atom->x, &scale, &sp_cl,
|
||||||
|
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
|
||||||
|
&this->ans->force, &this->ans->engv,
|
||||||
|
&eflag, &vflag, &ainum, &nbor_pitch,
|
||||||
|
&this->atom->q, &_cut_coulsq, &_qqrd2e, &_g_ewald,
|
||||||
|
&this->_threads_per_atom);
|
||||||
|
} else {
|
||||||
|
this->k_pair.set_size(GX,BX);
|
||||||
|
this->k_pair.run(&this->atom->x, &scale, &_lj_types, &sp_cl,
|
||||||
|
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
|
||||||
|
&this->ans->force, &this->ans->engv, &eflag, &vflag,
|
||||||
|
&ainum, &nbor_pitch, &this->atom->q, &_cut_coulsq,
|
||||||
|
&_qqrd2e, &_g_ewald, &this->_threads_per_atom);
|
||||||
|
}
|
||||||
|
this->time_pair.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
template class CoulLongCS<PRECISION,ACC_PRECISION>;
|
||||||
359
lib/gpu/lal_coul_long_cs.cu
Normal file
359
lib/gpu/lal_coul_long_cs.cu
Normal file
@ -0,0 +1,359 @@
|
|||||||
|
// **************************************************************************
|
||||||
|
// coul_long_cs.cu
|
||||||
|
// -------------------
|
||||||
|
// Trung Nguyen (Northwestern)
|
||||||
|
//
|
||||||
|
// Device code for acceleration of the coul/long/cs pair style
|
||||||
|
//
|
||||||
|
// __________________________________________________________________________
|
||||||
|
// This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
|
||||||
|
// __________________________________________________________________________
|
||||||
|
//
|
||||||
|
// begin : June 2018
|
||||||
|
// email : trung.nguyen@northwestern.edu
|
||||||
|
// ***************************************************************************/
|
||||||
|
|
||||||
|
#ifdef NV_KERNEL
|
||||||
|
|
||||||
|
#include "lal_aux_fun1.h"
|
||||||
|
#ifndef _DOUBLE_DOUBLE
|
||||||
|
texture<float4> pos_tex;
|
||||||
|
texture<float> q_tex;
|
||||||
|
#else
|
||||||
|
texture<int4,1> pos_tex;
|
||||||
|
texture<int2> q_tex;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define pos_tex x_
|
||||||
|
#define q_tex q_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (ARCH < 300)
|
||||||
|
|
||||||
|
#define store_answers_lq(f, e_coul, virial, ii, inum, tid, \
|
||||||
|
t_per_atom, offset, eflag, vflag, ans, engv) \
|
||||||
|
if (t_per_atom>1) { \
|
||||||
|
__local acctyp red_acc[6][BLOCK_PAIR]; \
|
||||||
|
\
|
||||||
|
red_acc[0][tid]=f.x; \
|
||||||
|
red_acc[1][tid]=f.y; \
|
||||||
|
red_acc[2][tid]=f.z; \
|
||||||
|
red_acc[3][tid]=e_coul; \
|
||||||
|
\
|
||||||
|
for (unsigned int s=t_per_atom/2; s>0; s>>=1) { \
|
||||||
|
if (offset < s) { \
|
||||||
|
for (int r=0; r<4; r++) \
|
||||||
|
red_acc[r][tid] += red_acc[r][tid+s]; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
f.x=red_acc[0][tid]; \
|
||||||
|
f.y=red_acc[1][tid]; \
|
||||||
|
f.z=red_acc[2][tid]; \
|
||||||
|
e_coul=red_acc[3][tid]; \
|
||||||
|
\
|
||||||
|
if (vflag>0) { \
|
||||||
|
for (int r=0; r<6; r++) \
|
||||||
|
red_acc[r][tid]=virial[r]; \
|
||||||
|
\
|
||||||
|
for (unsigned int s=t_per_atom/2; s>0; s>>=1) { \
|
||||||
|
if (offset < s) { \
|
||||||
|
for (int r=0; r<6; r++) \
|
||||||
|
red_acc[r][tid] += red_acc[r][tid+s]; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
for (int r=0; r<6; r++) \
|
||||||
|
virial[r]=red_acc[r][tid]; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
if (offset==0) { \
|
||||||
|
__global acctyp *ap1=engv+ii; \
|
||||||
|
if (eflag>0) { \
|
||||||
|
*ap1=(acctyp)0; \
|
||||||
|
ap1+=inum; \
|
||||||
|
*ap1=e_coul*(acctyp)0.5; \
|
||||||
|
ap1+=inum; \
|
||||||
|
} \
|
||||||
|
if (vflag>0) { \
|
||||||
|
for (int i=0; i<6; i++) { \
|
||||||
|
*ap1=virial[i]*(acctyp)0.5; \
|
||||||
|
ap1+=inum; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
ans[ii]=f; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define store_answers_lq(f, e_coul, virial, ii, inum, tid, \
|
||||||
|
t_per_atom, offset, eflag, vflag, ans, engv) \
|
||||||
|
if (t_per_atom>1) { \
|
||||||
|
for (unsigned int s=t_per_atom/2; s>0; s>>=1) { \
|
||||||
|
f.x += shfl_xor(f.x, s, t_per_atom); \
|
||||||
|
f.y += shfl_xor(f.y, s, t_per_atom); \
|
||||||
|
f.z += shfl_xor(f.z, s, t_per_atom); \
|
||||||
|
e_coul += shfl_xor(e_coul, s, t_per_atom); \
|
||||||
|
} \
|
||||||
|
if (vflag>0) { \
|
||||||
|
for (unsigned int s=t_per_atom/2; s>0; s>>=1) { \
|
||||||
|
for (int r=0; r<6; r++) \
|
||||||
|
virial[r] += shfl_xor(virial[r], s, t_per_atom); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
if (offset==0) { \
|
||||||
|
__global acctyp *ap1=engv+ii; \
|
||||||
|
if (eflag>0) { \
|
||||||
|
*ap1=(acctyp)0; \
|
||||||
|
ap1+=inum; \
|
||||||
|
*ap1=e_coul*(acctyp)0.5; \
|
||||||
|
ap1+=inum; \
|
||||||
|
} \
|
||||||
|
if (vflag>0) { \
|
||||||
|
for (int i=0; i<6; i++) { \
|
||||||
|
*ap1=virial[i]*(acctyp)0.5; \
|
||||||
|
ap1+=inum; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
ans[ii]=f; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define B0 (numtyp)-0.1335096380159268
|
||||||
|
#define B1 (numtyp)-2.57839507e-1
|
||||||
|
#define B2 (numtyp)-1.37203639e-1
|
||||||
|
#define B3 (numtyp)-8.88822059e-3
|
||||||
|
#define B4 (numtyp)-5.80844129e-3
|
||||||
|
#define B5 (numtyp)1.14652755e-1
|
||||||
|
#define EPSILON (numtyp)1.0e-20
|
||||||
|
#define EPS_EWALD (numtyp)1.0e-6
|
||||||
|
#define EPS_EWALD_SQR (numtyp)1.0e-12
|
||||||
|
|
||||||
|
__kernel void k_coul_long_cs(const __global numtyp4 *restrict x_,
|
||||||
|
const __global numtyp *restrict scale,
|
||||||
|
const int lj_types,
|
||||||
|
const __global numtyp *restrict sp_cl_in,
|
||||||
|
const __global int *dev_nbor,
|
||||||
|
const __global int *dev_packed,
|
||||||
|
__global acctyp4 *restrict ans,
|
||||||
|
__global acctyp *restrict engv,
|
||||||
|
const int eflag, const int vflag, const int inum,
|
||||||
|
const int nbor_pitch,
|
||||||
|
const __global numtyp *restrict q_,
|
||||||
|
const numtyp cut_coulsq, const numtyp qqrd2e,
|
||||||
|
const numtyp g_ewald, const int t_per_atom) {
|
||||||
|
int tid, ii, offset;
|
||||||
|
atom_info(t_per_atom,ii,tid,offset);
|
||||||
|
|
||||||
|
__local numtyp sp_cl[4];
|
||||||
|
sp_cl[0]=sp_cl_in[0];
|
||||||
|
sp_cl[1]=sp_cl_in[1];
|
||||||
|
sp_cl[2]=sp_cl_in[2];
|
||||||
|
sp_cl[3]=sp_cl_in[3];
|
||||||
|
|
||||||
|
acctyp e_coul=(acctyp)0;
|
||||||
|
acctyp4 f;
|
||||||
|
f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0;
|
||||||
|
acctyp virial[6];
|
||||||
|
for (int i=0; i<6; i++)
|
||||||
|
virial[i]=(acctyp)0;
|
||||||
|
|
||||||
|
if (ii<inum) {
|
||||||
|
int nbor, nbor_end;
|
||||||
|
int i, numj;
|
||||||
|
__local int n_stride;
|
||||||
|
nbor_info(dev_nbor,dev_packed,nbor_pitch,t_per_atom,ii,offset,i,numj,
|
||||||
|
n_stride,nbor_end,nbor);
|
||||||
|
|
||||||
|
numtyp4 ix; fetch4(ix,i,pos_tex); //x_[i];
|
||||||
|
int itype=ix.w;
|
||||||
|
numtyp qtmp; fetch(qtmp,i,q_tex);
|
||||||
|
|
||||||
|
for ( ; nbor<nbor_end; nbor+=n_stride) {
|
||||||
|
int j=dev_packed[nbor];
|
||||||
|
|
||||||
|
numtyp factor_coul;
|
||||||
|
factor_coul = sp_cl[sbmask(j)];
|
||||||
|
j &= NEIGHMASK;
|
||||||
|
|
||||||
|
numtyp4 jx; fetch4(jx,j,pos_tex); //x_[j];
|
||||||
|
int jtype=jx.w;
|
||||||
|
|
||||||
|
// Compute r12
|
||||||
|
numtyp delx = ix.x-jx.x;
|
||||||
|
numtyp dely = ix.y-jx.y;
|
||||||
|
numtyp delz = ix.z-jx.z;
|
||||||
|
numtyp rsq = delx*delx+dely*dely+delz*delz;
|
||||||
|
|
||||||
|
int mtype=itype*lj_types+jtype;
|
||||||
|
if (rsq < cut_coulsq) {
|
||||||
|
rsq += EPSILON;
|
||||||
|
|
||||||
|
numtyp force,prefactor,_erfc;
|
||||||
|
numtyp r2inv = ucl_recip(rsq);
|
||||||
|
numtyp r = ucl_rsqrt(r2inv);
|
||||||
|
fetch(prefactor,j,q_tex);
|
||||||
|
prefactor *= qqrd2e * scale[mtype] * qtmp;
|
||||||
|
if (factor_coul<(numtyp)1.0) {
|
||||||
|
numtyp grij = g_ewald * (r+EPS_EWALD);
|
||||||
|
numtyp expm2 = ucl_exp(-grij*grij);
|
||||||
|
numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*grij);
|
||||||
|
numtyp u = (numtyp)1.0 - t;
|
||||||
|
_erfc = t * ((numtyp)1.0 + u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= (r+EPS_EWALD);
|
||||||
|
force = prefactor * (_erfc + EWALD_F*grij*expm2 - ((numtyp)1.0-factor_coul));
|
||||||
|
r2inv = ucl_recip(rsq + EPS_EWALD_SQR);
|
||||||
|
force *= r2inv;
|
||||||
|
} else {
|
||||||
|
numtyp grij = g_ewald * r;
|
||||||
|
numtyp expm2 = ucl_exp(-grij*grij);
|
||||||
|
numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*grij);
|
||||||
|
numtyp u = (numtyp)1.0 - t;
|
||||||
|
_erfc = t * ((numtyp)1.0 + u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= r;
|
||||||
|
force = prefactor*(_erfc + EWALD_F*grij*expm2);
|
||||||
|
force *= r2inv;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.x+=delx*force;
|
||||||
|
f.y+=dely*force;
|
||||||
|
f.z+=delz*force;
|
||||||
|
|
||||||
|
if (eflag>0) {
|
||||||
|
e_coul += prefactor*_erfc;
|
||||||
|
if (factor_coul<(numtyp)1.0)
|
||||||
|
e_coul -= ((numtyp)1.0-factor_coul)*prefactor;
|
||||||
|
}
|
||||||
|
if (vflag>0) {
|
||||||
|
virial[0] += delx*delx*force;
|
||||||
|
virial[1] += dely*dely*force;
|
||||||
|
virial[2] += delz*delz*force;
|
||||||
|
virial[3] += delx*dely*force;
|
||||||
|
virial[4] += delx*delz*force;
|
||||||
|
virial[5] += dely*delz*force;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // for nbor
|
||||||
|
store_answers_lq(f,e_coul,virial,ii,inum,tid,t_per_atom,offset,eflag,
|
||||||
|
vflag,ans,engv);
|
||||||
|
} // if ii
|
||||||
|
}
|
||||||
|
|
||||||
|
__kernel void k_coul_long_cs_fast(const __global numtyp4 *restrict x_,
|
||||||
|
const __global numtyp *restrict scale_in,
|
||||||
|
const __global numtyp *restrict sp_cl_in,
|
||||||
|
const __global int *dev_nbor,
|
||||||
|
const __global int *dev_packed,
|
||||||
|
__global acctyp4 *restrict ans,
|
||||||
|
__global acctyp *restrict engv,
|
||||||
|
const int eflag, const int vflag, const int inum,
|
||||||
|
const int nbor_pitch,
|
||||||
|
const __global numtyp *restrict q_,
|
||||||
|
const numtyp cut_coulsq, const numtyp qqrd2e,
|
||||||
|
const numtyp g_ewald, const int t_per_atom) {
|
||||||
|
int tid, ii, offset;
|
||||||
|
atom_info(t_per_atom,ii,tid,offset);
|
||||||
|
|
||||||
|
__local numtyp scale[MAX_SHARED_TYPES*MAX_SHARED_TYPES];
|
||||||
|
__local numtyp sp_cl[4];
|
||||||
|
if (tid<4)
|
||||||
|
sp_cl[tid]=sp_cl_in[tid];
|
||||||
|
if (tid<MAX_SHARED_TYPES*MAX_SHARED_TYPES)
|
||||||
|
scale[tid]=scale_in[tid];
|
||||||
|
|
||||||
|
acctyp e_coul=(acctyp)0;
|
||||||
|
acctyp4 f;
|
||||||
|
f.x=(acctyp)0; f.y=(acctyp)0; f.z=(acctyp)0;
|
||||||
|
acctyp virial[6];
|
||||||
|
for (int i=0; i<6; i++)
|
||||||
|
virial[i]=(acctyp)0;
|
||||||
|
|
||||||
|
__syncthreads();
|
||||||
|
|
||||||
|
if (ii<inum) {
|
||||||
|
int nbor, nbor_end;
|
||||||
|
int i, numj;
|
||||||
|
__local int n_stride;
|
||||||
|
nbor_info(dev_nbor,dev_packed,nbor_pitch,t_per_atom,ii,offset,i,numj,
|
||||||
|
n_stride,nbor_end,nbor);
|
||||||
|
|
||||||
|
numtyp4 ix; fetch4(ix,i,pos_tex); //x_[i];
|
||||||
|
numtyp qtmp; fetch(qtmp,i,q_tex);
|
||||||
|
int iw=ix.w;
|
||||||
|
int itype=fast_mul((int)MAX_SHARED_TYPES,iw);
|
||||||
|
|
||||||
|
for ( ; nbor<nbor_end; nbor+=n_stride) {
|
||||||
|
int j=dev_packed[nbor];
|
||||||
|
|
||||||
|
numtyp factor_coul;
|
||||||
|
factor_coul = sp_cl[sbmask(j)];
|
||||||
|
j &= NEIGHMASK;
|
||||||
|
|
||||||
|
numtyp4 jx; fetch4(jx,j,pos_tex); //x_[j];
|
||||||
|
int mtype=itype+jx.w;
|
||||||
|
|
||||||
|
// Compute r12
|
||||||
|
numtyp delx = ix.x-jx.x;
|
||||||
|
numtyp dely = ix.y-jx.y;
|
||||||
|
numtyp delz = ix.z-jx.z;
|
||||||
|
numtyp rsq = delx*delx+dely*dely+delz*delz;
|
||||||
|
|
||||||
|
if (rsq < cut_coulsq) {
|
||||||
|
rsq += EPSILON;
|
||||||
|
|
||||||
|
numtyp force,prefactor,_erfc;
|
||||||
|
numtyp r2inv = ucl_recip(rsq);
|
||||||
|
numtyp r = ucl_rsqrt(r2inv);
|
||||||
|
fetch(prefactor,j,q_tex);
|
||||||
|
prefactor *= qqrd2e * scale[mtype] * qtmp;
|
||||||
|
if (factor_coul<(numtyp)1.0) {
|
||||||
|
numtyp grij = g_ewald * (r+EPS_EWALD);
|
||||||
|
numtyp expm2 = ucl_exp(-grij*grij);
|
||||||
|
numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*grij);
|
||||||
|
numtyp u = (numtyp)1.0 - t;
|
||||||
|
_erfc = t * ((numtyp)1.0 + u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= (r+EPS_EWALD);
|
||||||
|
force = prefactor * (_erfc + EWALD_F*grij*expm2 - ((numtyp)1.0-factor_coul));
|
||||||
|
r2inv = ucl_recip(rsq + EPS_EWALD_SQR);
|
||||||
|
force *= r2inv;
|
||||||
|
} else {
|
||||||
|
numtyp grij = g_ewald * r;
|
||||||
|
numtyp expm2 = ucl_exp(-grij*grij);
|
||||||
|
numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*grij);
|
||||||
|
numtyp u = (numtyp)1.0 - t;
|
||||||
|
_erfc = t * ((numtyp)1.0 + u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= r;
|
||||||
|
force = prefactor * (_erfc + EWALD_F*grij*expm2);
|
||||||
|
force *= r2inv;
|
||||||
|
}
|
||||||
|
|
||||||
|
f.x+=delx*force;
|
||||||
|
f.y+=dely*force;
|
||||||
|
f.z+=delz*force;
|
||||||
|
|
||||||
|
if (eflag>0) {
|
||||||
|
e_coul += prefactor*_erfc;
|
||||||
|
if (factor_coul<(numtyp)1.0)
|
||||||
|
e_coul -= ((numtyp)1.0-factor_coul)*prefactor;
|
||||||
|
}
|
||||||
|
if (vflag>0) {
|
||||||
|
virial[0] += delx*delx*force;
|
||||||
|
virial[1] += dely*dely*force;
|
||||||
|
virial[2] += delz*delz*force;
|
||||||
|
virial[3] += delx*dely*force;
|
||||||
|
virial[4] += delx*delz*force;
|
||||||
|
virial[5] += dely*delz*force;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // for nbor
|
||||||
|
store_answers_lq(f,e_coul,virial,ii,inum,tid,t_per_atom,offset,eflag,
|
||||||
|
vflag,ans,engv);
|
||||||
|
} // if ii
|
||||||
|
}
|
||||||
|
|
||||||
82
lib/gpu/lal_coul_long_cs.h
Normal file
82
lib/gpu/lal_coul_long_cs.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
coul_long_cs.h
|
||||||
|
-------------------
|
||||||
|
Trung Nguyen (Northwestern)
|
||||||
|
|
||||||
|
Class for acceleration of the coul/long/cs pair style.
|
||||||
|
|
||||||
|
__________________________________________________________________________
|
||||||
|
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
|
||||||
|
__________________________________________________________________________
|
||||||
|
|
||||||
|
begin : June 2018
|
||||||
|
email : trung.nguyen@northwestern.edu
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LAL_COUL_LONG_CS_H
|
||||||
|
#define LAL_COUL_LONG_CS_H
|
||||||
|
|
||||||
|
#include "lal_base_charge.h"
|
||||||
|
|
||||||
|
namespace LAMMPS_AL {
|
||||||
|
|
||||||
|
template <class numtyp, class acctyp>
|
||||||
|
class CoulLongCS : public BaseCharge<numtyp, acctyp> {
|
||||||
|
public:
|
||||||
|
CoulLongCS();
|
||||||
|
~CoulLongCS();
|
||||||
|
|
||||||
|
/// Clear any previous data and set up for a new LAMMPS run
|
||||||
|
/** \param max_nbors initial number of rows in the neighbor matrix
|
||||||
|
* \param cell_size cutoff + skin
|
||||||
|
* \param gpu_split fraction of particles handled by device
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* - 0 if successfull
|
||||||
|
* - -1 if fix gpu not found
|
||||||
|
* - -3 if there is an out of memory error
|
||||||
|
* - -4 if the GPU library was not compiled for GPU
|
||||||
|
* - -5 Double precision is not supported on card **/
|
||||||
|
int init(const int ntypes, double **scale,
|
||||||
|
const int nlocal, const int nall, const int max_nbors,
|
||||||
|
const int maxspecial, const double cell_size,
|
||||||
|
const double gpu_split, FILE *screen,
|
||||||
|
const double host_cut_coulsq, double *host_special_coul,
|
||||||
|
const double qqrd2e, const double g_ewald);
|
||||||
|
|
||||||
|
/// Send updated coeffs from host to device (to be compatible with fix adapt)
|
||||||
|
void reinit(const int ntypes, double **scale);
|
||||||
|
|
||||||
|
/// Clear all host and device data
|
||||||
|
/** \note This is called at the beginning of the init() routine **/
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
/// Returns memory usage on device per atom
|
||||||
|
int bytes_per_atom(const int max_nbors) const;
|
||||||
|
|
||||||
|
/// Total host memory used by library for pair style
|
||||||
|
double host_memory_usage() const;
|
||||||
|
|
||||||
|
// --------------------------- TYPE DATA --------------------------
|
||||||
|
|
||||||
|
/// scale
|
||||||
|
UCL_D_Vec<numtyp> scale;
|
||||||
|
/// Special Coul values [0-3]
|
||||||
|
UCL_D_Vec<numtyp> sp_cl;
|
||||||
|
|
||||||
|
/// If atom type constants fit in shared memory, use fast kernels
|
||||||
|
bool shared_types;
|
||||||
|
|
||||||
|
/// Number of atom types
|
||||||
|
int _lj_types;
|
||||||
|
|
||||||
|
numtyp _cut_coulsq, _qqrd2e, _g_ewald;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _allocated;
|
||||||
|
void loop(const bool _eflag, const bool _vflag);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
145
lib/gpu/lal_coul_long_cs_ext.cpp
Normal file
145
lib/gpu/lal_coul_long_cs_ext.cpp
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
coul_long_cs_ext.cpp
|
||||||
|
-------------------
|
||||||
|
Trung Nguyen (Northwestern)
|
||||||
|
|
||||||
|
Functions for LAMMPS access to coul/long/cs acceleration routines.
|
||||||
|
|
||||||
|
__________________________________________________________________________
|
||||||
|
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
|
||||||
|
__________________________________________________________________________
|
||||||
|
|
||||||
|
begin : June 2018
|
||||||
|
email : trung.nguyen@northwestern.edu
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "lal_coul_long_cs.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace LAMMPS_AL;
|
||||||
|
|
||||||
|
static CoulLongCS<PRECISION,ACC_PRECISION> CLCSMF;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Allocate memory on host and device and copy constants to device
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
int clcs_gpu_init(const int ntypes, double **host_scale,
|
||||||
|
const int inum, 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) {
|
||||||
|
CLCSMF.clear();
|
||||||
|
gpu_mode=CLCSMF.device->gpu_mode();
|
||||||
|
double gpu_split=CLCSMF.device->particle_split();
|
||||||
|
int first_gpu=CLCSMF.device->first_device();
|
||||||
|
int last_gpu=CLCSMF.device->last_device();
|
||||||
|
int world_me=CLCSMF.device->world_me();
|
||||||
|
int gpu_rank=CLCSMF.device->gpu_rank();
|
||||||
|
int procs_per_gpu=CLCSMF.device->procs_per_gpu();
|
||||||
|
|
||||||
|
CLCSMF.device->init_message(screen,"coul/long/cs",first_gpu,last_gpu);
|
||||||
|
|
||||||
|
bool message=false;
|
||||||
|
if (CLCSMF.device->replica_me()==0 && screen)
|
||||||
|
message=true;
|
||||||
|
|
||||||
|
if (message) {
|
||||||
|
fprintf(screen,"Initializing Device and compiling on process 0...");
|
||||||
|
fflush(screen);
|
||||||
|
}
|
||||||
|
|
||||||
|
int init_ok=0;
|
||||||
|
if (world_me==0)
|
||||||
|
init_ok=CLCSMF.init(ntypes, host_scale, inum, nall, 300, maxspecial,
|
||||||
|
cell_size, gpu_split, screen, host_cut_coulsq,
|
||||||
|
host_special_coul, qqrd2e, g_ewald);
|
||||||
|
|
||||||
|
CLCSMF.device->world_barrier();
|
||||||
|
if (message)
|
||||||
|
fprintf(screen,"Done.\n");
|
||||||
|
|
||||||
|
for (int i=0; i<procs_per_gpu; i++) {
|
||||||
|
if (message) {
|
||||||
|
if (last_gpu-first_gpu==0)
|
||||||
|
fprintf(screen,"Initializing Device %d on core %d...",first_gpu,i);
|
||||||
|
else
|
||||||
|
fprintf(screen,"Initializing Devices %d-%d on core %d...",first_gpu,
|
||||||
|
last_gpu,i);
|
||||||
|
fflush(screen);
|
||||||
|
}
|
||||||
|
if (gpu_rank==i && world_me!=0)
|
||||||
|
init_ok=CLCSMF.init(ntypes, host_scale, inum, nall, 300, maxspecial,
|
||||||
|
cell_size, gpu_split, screen, host_cut_coulsq,
|
||||||
|
host_special_coul, qqrd2e, g_ewald);
|
||||||
|
|
||||||
|
CLCSMF.device->gpu_barrier();
|
||||||
|
if (message)
|
||||||
|
fprintf(screen,"Done.\n");
|
||||||
|
}
|
||||||
|
if (message)
|
||||||
|
fprintf(screen,"\n");
|
||||||
|
|
||||||
|
if (init_ok==0)
|
||||||
|
CLCSMF.estimate_gpu_overhead();
|
||||||
|
return init_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Copy updated coeffs from host to device
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
void clcs_gpu_reinit(const int ntypes, double **host_scale) {
|
||||||
|
int world_me=CLCSMF.device->world_me();
|
||||||
|
int gpu_rank=CLCSMF.device->gpu_rank();
|
||||||
|
int procs_per_gpu=CLCSMF.device->procs_per_gpu();
|
||||||
|
|
||||||
|
if (world_me==0)
|
||||||
|
CLCSMF.reinit(ntypes, host_scale);
|
||||||
|
|
||||||
|
CLCSMF.device->world_barrier();
|
||||||
|
|
||||||
|
for (int i=0; i<procs_per_gpu; i++) {
|
||||||
|
if (gpu_rank==i && world_me!=0)
|
||||||
|
CLCSMF.reinit(ntypes, host_scale);
|
||||||
|
|
||||||
|
CLCSMF.device->gpu_barrier();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void clcs_gpu_clear() {
|
||||||
|
CLCSMF.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int** clcs_gpu_compute_n(const int ago, const int inum_full,
|
||||||
|
const int nall, double **host_x, int *host_type,
|
||||||
|
double *sublo, double *subhi, tagint *tag, int **nspecial,
|
||||||
|
tagint **special, const bool eflag, const bool vflag,
|
||||||
|
const bool eatom, const bool vatom, int &host_start,
|
||||||
|
int **ilist, int **jnum, const double cpu_time,
|
||||||
|
bool &success, double *host_q, double *boxlo,
|
||||||
|
double *prd) {
|
||||||
|
return CLCSMF.compute(ago, inum_full, nall, host_x, host_type, sublo,
|
||||||
|
subhi, tag, nspecial, special, eflag, vflag, eatom,
|
||||||
|
vatom, host_start, ilist, jnum, cpu_time, success,
|
||||||
|
host_q, boxlo, prd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clcs_gpu_compute(const int ago, const int inum_full, const int nall,
|
||||||
|
double **host_x, int *host_type, int *ilist, int *numj,
|
||||||
|
int **firstneigh, const bool eflag, const bool vflag,
|
||||||
|
const bool eatom, const bool vatom, int &host_start,
|
||||||
|
const double cpu_time, bool &success, double *host_q,
|
||||||
|
const int nlocal, double *boxlo, double *prd) {
|
||||||
|
CLCSMF.compute(ago,inum_full,nall,host_x,host_type,ilist,numj,
|
||||||
|
firstneigh,eflag,vflag,eatom,vatom,host_start,cpu_time,success,
|
||||||
|
host_q,nlocal,boxlo,prd);
|
||||||
|
}
|
||||||
|
|
||||||
|
double clcs_gpu_bytes() {
|
||||||
|
return CLCSMF.host_memory_usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
340
src/GPU/pair_born_coul_long_cs_gpu.cpp
Normal file
340
src/GPU/pair_born_coul_long_cs_gpu.cpp
Normal file
@ -0,0 +1,340 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
Contributing author: Trung Dac Nguyen (Northwestern)
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include "pair_born_coul_long_cs_gpu.h"
|
||||||
|
#include "atom.h"
|
||||||
|
#include "atom_vec.h"
|
||||||
|
#include "comm.h"
|
||||||
|
#include "force.h"
|
||||||
|
#include "neighbor.h"
|
||||||
|
#include "neigh_list.h"
|
||||||
|
#include "integrate.h"
|
||||||
|
#include "math_const.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "neigh_request.h"
|
||||||
|
#include "universe.h"
|
||||||
|
#include "update.h"
|
||||||
|
#include "domain.h"
|
||||||
|
#include "kspace.h"
|
||||||
|
#include "gpu_extra.h"
|
||||||
|
|
||||||
|
using namespace LAMMPS_NS;
|
||||||
|
using namespace MathConst;
|
||||||
|
|
||||||
|
#define EWALD_F 1.12837917
|
||||||
|
#define EWALD_P 9.95473818e-1
|
||||||
|
#define B0 -0.1335096380159268
|
||||||
|
#define B1 -2.57839507e-1
|
||||||
|
#define B2 -1.37203639e-1
|
||||||
|
#define B3 -8.88822059e-3
|
||||||
|
#define B4 -5.80844129e-3
|
||||||
|
#define B5 1.14652755e-1
|
||||||
|
|
||||||
|
#define EPSILON 1.0e-20
|
||||||
|
#define EPS_EWALD 1.0e-6
|
||||||
|
#define EPS_EWALD_SQR 1.0e-12
|
||||||
|
|
||||||
|
// External functions from cuda library for atom decomposition
|
||||||
|
|
||||||
|
int bornclcs_gpu_init(const int ntypes, double **cutsq, double **host_rhoinv,
|
||||||
|
double **host_born1, double **host_born2,
|
||||||
|
double **host_born3, double **host_a,
|
||||||
|
double **host_c, double **host_d,
|
||||||
|
double **sigma, 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, double **host_cut_ljsq,
|
||||||
|
double host_cut_coulsq, double *host_special_coul,
|
||||||
|
const double qqrd2e, const double g_ewald);
|
||||||
|
void bornclcs_gpu_clear();
|
||||||
|
int** bornclcs_gpu_compute_n(const int ago, const int inum_full, const int nall,
|
||||||
|
double **host_x, int *host_type, double *sublo,
|
||||||
|
double *subhi, tagint *tag, int **nspecial,
|
||||||
|
tagint **special, const bool eflag, const bool vflag,
|
||||||
|
const bool eatom, const bool vatom, int &host_start,
|
||||||
|
int **ilist, int **jnum, const double cpu_time,
|
||||||
|
bool &success, double *host_q, double *boxlo,
|
||||||
|
double *prd);
|
||||||
|
void bornclcs_gpu_compute(const int ago, const int inum_full, const int nall,
|
||||||
|
double **host_x, int *host_type, int *ilist, int *numj,
|
||||||
|
int **firstneigh, const bool eflag, const bool vflag,
|
||||||
|
const bool eatom, const bool vatom, int &host_start,
|
||||||
|
const double cpu_time, bool &success, double *host_q,
|
||||||
|
const int nlocal, double *boxlo, double *prd);
|
||||||
|
double bornclcs_gpu_bytes();
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
PairBornCoulLongCSGPU::PairBornCoulLongCSGPU(LAMMPS *lmp) :
|
||||||
|
PairBornCoulLongCS(lmp), gpu_mode(GPU_FORCE)
|
||||||
|
{
|
||||||
|
respa_enable = 0;
|
||||||
|
reinitflag = 0;
|
||||||
|
cpu_time = 0.0;
|
||||||
|
GPU_EXTRA::gpu_ready(lmp->modify, lmp->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
free all arrays
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
PairBornCoulLongCSGPU::~PairBornCoulLongCSGPU()
|
||||||
|
{
|
||||||
|
bornclcs_gpu_clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void PairBornCoulLongCSGPU::compute(int eflag, int vflag)
|
||||||
|
{
|
||||||
|
if (eflag || vflag) ev_setup(eflag,vflag);
|
||||||
|
else evflag = vflag_fdotr = 0;
|
||||||
|
|
||||||
|
int nall = atom->nlocal + atom->nghost;
|
||||||
|
int inum, host_start;
|
||||||
|
|
||||||
|
bool success = true;
|
||||||
|
int *ilist, *numneigh, **firstneigh;
|
||||||
|
if (gpu_mode != GPU_FORCE) {
|
||||||
|
inum = atom->nlocal;
|
||||||
|
firstneigh = bornclcs_gpu_compute_n(neighbor->ago, inum, nall, atom->x,
|
||||||
|
atom->type, domain->sublo, domain->subhi,
|
||||||
|
atom->tag, atom->nspecial, atom->special,
|
||||||
|
eflag, vflag, eflag_atom, vflag_atom,
|
||||||
|
host_start, &ilist, &numneigh, cpu_time,
|
||||||
|
success, atom->q, domain->boxlo,
|
||||||
|
domain->prd);
|
||||||
|
} else {
|
||||||
|
inum = list->inum;
|
||||||
|
ilist = list->ilist;
|
||||||
|
numneigh = list->numneigh;
|
||||||
|
firstneigh = list->firstneigh;
|
||||||
|
bornclcs_gpu_compute(neighbor->ago, inum, nall, atom->x, atom->type,
|
||||||
|
ilist, numneigh, firstneigh, eflag, vflag, eflag_atom,
|
||||||
|
vflag_atom, host_start, cpu_time, success, atom->q,
|
||||||
|
atom->nlocal, domain->boxlo, domain->prd);
|
||||||
|
}
|
||||||
|
if (!success)
|
||||||
|
error->one(FLERR,"Insufficient memory on accelerator");
|
||||||
|
|
||||||
|
if (host_start<inum) {
|
||||||
|
cpu_time = MPI_Wtime();
|
||||||
|
cpu_compute(host_start, inum, eflag, vflag, ilist, numneigh, firstneigh);
|
||||||
|
cpu_time = MPI_Wtime() - cpu_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
init specific to this pair style
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void PairBornCoulLongCSGPU::init_style()
|
||||||
|
{
|
||||||
|
if (!atom->q_flag)
|
||||||
|
error->all(FLERR,
|
||||||
|
"Pair style born/coul/long/cs/gpu requires atom attribute q");
|
||||||
|
if (force->newton_pair)
|
||||||
|
error->all(FLERR,
|
||||||
|
"Cannot use newton pair with born/coul/long/cs/gpu pair style");
|
||||||
|
|
||||||
|
// Repeat cutsq calculation because done after call to init_style
|
||||||
|
double maxcut = -1.0;
|
||||||
|
double cut;
|
||||||
|
for (int i = 1; i <= atom->ntypes; i++) {
|
||||||
|
for (int j = i; j <= atom->ntypes; j++) {
|
||||||
|
if (setflag[i][j] != 0 || (setflag[i][i] != 0 && setflag[j][j] != 0)) {
|
||||||
|
cut = init_one(i,j);
|
||||||
|
cut *= cut;
|
||||||
|
if (cut > maxcut)
|
||||||
|
maxcut = cut;
|
||||||
|
cutsq[i][j] = cutsq[j][i] = cut;
|
||||||
|
} else
|
||||||
|
cutsq[i][j] = cutsq[j][i] = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double cell_size = sqrt(maxcut) + neighbor->skin;
|
||||||
|
|
||||||
|
cut_coulsq = cut_coul * cut_coul;
|
||||||
|
|
||||||
|
// insure use of KSpace long-range solver, set g_ewald
|
||||||
|
|
||||||
|
if (force->kspace == NULL)
|
||||||
|
error->all(FLERR,"Pair style requires a KSpace style");
|
||||||
|
g_ewald = force->kspace->g_ewald;
|
||||||
|
|
||||||
|
int maxspecial=0;
|
||||||
|
if (atom->molecular)
|
||||||
|
maxspecial=atom->maxspecial;
|
||||||
|
int success = bornclcs_gpu_init(atom->ntypes+1, cutsq, rhoinv,
|
||||||
|
born1, born2, born3, a, c, d, sigma,
|
||||||
|
offset, force->special_lj, atom->nlocal,
|
||||||
|
atom->nlocal+atom->nghost, 300, maxspecial,
|
||||||
|
cell_size, gpu_mode, screen, cut_ljsq,
|
||||||
|
cut_coulsq, force->special_coul,
|
||||||
|
force->qqrd2e, g_ewald);
|
||||||
|
|
||||||
|
GPU_EXTRA::check_flag(success,error,world);
|
||||||
|
|
||||||
|
if (gpu_mode == GPU_FORCE) {
|
||||||
|
int irequest = neighbor->request(this,instance_me);
|
||||||
|
neighbor->requests[irequest]->half = 0;
|
||||||
|
neighbor->requests[irequest]->full = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
double PairBornCoulLongCSGPU::memory_usage()
|
||||||
|
{
|
||||||
|
double bytes = Pair::memory_usage();
|
||||||
|
return bytes + bornclcs_gpu_bytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void PairBornCoulLongCSGPU::cpu_compute(int start, int inum, int eflag,
|
||||||
|
int vflag, int *ilist, int *numneigh,
|
||||||
|
int **firstneigh)
|
||||||
|
{
|
||||||
|
int i,j,ii,jj,jnum,itable,itype,jtype;
|
||||||
|
double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair;
|
||||||
|
double fraction,table;
|
||||||
|
double r,rsq,rexp,r2inv,r6inv,forcecoul,forceborn,factor_coul,factor_lj;
|
||||||
|
double grij,expm2,prefactor,t,erfc,u;
|
||||||
|
int *jlist;
|
||||||
|
|
||||||
|
evdwl = ecoul = 0.0;
|
||||||
|
|
||||||
|
double **x = atom->x;
|
||||||
|
double **f = atom->f;
|
||||||
|
double *q = atom->q;
|
||||||
|
int *type = atom->type;
|
||||||
|
double *special_coul = force->special_coul;
|
||||||
|
double *special_lj = force->special_lj;
|
||||||
|
double qqrd2e = force->qqrd2e;
|
||||||
|
|
||||||
|
// loop over neighbors of my atoms
|
||||||
|
|
||||||
|
for (ii = start; ii < inum; ii++) {
|
||||||
|
i = ilist[ii];
|
||||||
|
qtmp = q[i];
|
||||||
|
xtmp = x[i][0];
|
||||||
|
ytmp = x[i][1];
|
||||||
|
ztmp = x[i][2];
|
||||||
|
itype = type[i];
|
||||||
|
jlist = firstneigh[i];
|
||||||
|
jnum = numneigh[i];
|
||||||
|
|
||||||
|
for (jj = 0; jj < jnum; jj++) {
|
||||||
|
j = jlist[jj];
|
||||||
|
factor_lj = special_lj[sbmask(j)];
|
||||||
|
factor_coul = special_coul[sbmask(j)];
|
||||||
|
j &= NEIGHMASK;
|
||||||
|
|
||||||
|
delx = xtmp - x[j][0];
|
||||||
|
dely = ytmp - x[j][1];
|
||||||
|
delz = ztmp - x[j][2];
|
||||||
|
rsq = delx*delx + dely*dely + delz*delz;
|
||||||
|
jtype = type[j];
|
||||||
|
|
||||||
|
if (rsq < cutsq[itype][jtype]) {
|
||||||
|
|
||||||
|
if (rsq < cut_coulsq) {
|
||||||
|
rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond;
|
||||||
|
r2inv = 1.0/rsq;
|
||||||
|
if (!ncoultablebits || rsq <= tabinnersq) {
|
||||||
|
r = sqrt(rsq);
|
||||||
|
prefactor = qqrd2e * qtmp*q[j];
|
||||||
|
if (factor_coul < 1.0) {
|
||||||
|
// When bonded parts are being calculated a minimal distance (EPS_EWALD)
|
||||||
|
// has to be added to the prefactor and erfc in order to make the
|
||||||
|
// used approximation functions for the Ewald correction valid
|
||||||
|
grij = g_ewald * (r+EPS_EWALD);
|
||||||
|
expm2 = exp(-grij*grij);
|
||||||
|
t = 1.0 / (1.0 + EWALD_P*grij);
|
||||||
|
u = 1.0 - t;
|
||||||
|
erfc = t * (1.+u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= (r+EPS_EWALD);
|
||||||
|
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - (1.0-factor_coul));
|
||||||
|
// Additionally r2inv needs to be accordingly modified since the later
|
||||||
|
// scaling of the overall force shall be consistent
|
||||||
|
r2inv = 1.0/(rsq + EPS_EWALD_SQR);
|
||||||
|
} else {
|
||||||
|
grij = g_ewald * r;
|
||||||
|
expm2 = exp(-grij*grij);
|
||||||
|
t = 1.0 / (1.0 + EWALD_P*grij);
|
||||||
|
u = 1.0 - t;
|
||||||
|
erfc = t * (1.+u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= r;
|
||||||
|
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
union_int_float_t rsq_lookup;
|
||||||
|
rsq_lookup.f = rsq;
|
||||||
|
itable = rsq_lookup.i & ncoulmask;
|
||||||
|
itable >>= ncoulshiftbits;
|
||||||
|
fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable];
|
||||||
|
table = ftable[itable] + fraction*dftable[itable];
|
||||||
|
forcecoul = qtmp*q[j] * table;
|
||||||
|
if (factor_coul < 1.0) {
|
||||||
|
table = ctable[itable] + fraction*dctable[itable];
|
||||||
|
prefactor = qtmp*q[j] * table;
|
||||||
|
forcecoul -= (1.0-factor_coul)*prefactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
forcecoul *= r2inv;
|
||||||
|
|
||||||
|
} else forcecoul = 0;
|
||||||
|
|
||||||
|
r2inv = 1.0/rsq;
|
||||||
|
r = sqrt(rsq);
|
||||||
|
if (rsq < cut_ljsq[itype][jtype]) {
|
||||||
|
r6inv = r2inv*r2inv*r2inv;
|
||||||
|
rexp = exp((sigma[itype][jtype]-r)*rhoinv[itype][jtype]);
|
||||||
|
forceborn = born1[itype][jtype]*r*rexp - born2[itype][jtype]*r6inv
|
||||||
|
+ born3[itype][jtype]*r2inv*r6inv;
|
||||||
|
} else forceborn = 0.0;
|
||||||
|
|
||||||
|
fpair = forcecoul + factor_lj*forceborn * r2inv;
|
||||||
|
|
||||||
|
f[i][0] += delx*fpair;
|
||||||
|
f[i][1] += dely*fpair;
|
||||||
|
f[i][2] += delz*fpair;
|
||||||
|
|
||||||
|
if (eflag) {
|
||||||
|
if (rsq < cut_coulsq) {
|
||||||
|
ecoul = prefactor*erfc;
|
||||||
|
if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor;
|
||||||
|
} else ecoul = 0.0;
|
||||||
|
if (rsq < cut_ljsq[itype][jtype]) {
|
||||||
|
evdwl = a[itype][jtype]*rexp - c[itype][jtype]*r6inv
|
||||||
|
+ d[itype][jtype]*r6inv*r2inv - offset[itype][jtype];
|
||||||
|
evdwl *= factor_lj;
|
||||||
|
} else evdwl = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (evflag) ev_tally_full(i,evdwl,ecoul,fpair,delx,dely,delz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
66
src/GPU/pair_born_coul_long_cs_gpu.h
Normal file
66
src/GPU/pair_born_coul_long_cs_gpu.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* -*- c++ -*- ----------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef PAIR_CLASS
|
||||||
|
|
||||||
|
PairStyle(born/coul/long/cs/gpu,PairBornCoulLongCSGPU)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifndef LMP_PAIR_BORN_COUL_LONG_CS_GPU_H
|
||||||
|
#define LMP_PAIR_BORN_COUL_LONG_CS_GPU_H
|
||||||
|
|
||||||
|
#include "pair_born_coul_long_cs.h"
|
||||||
|
|
||||||
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
|
class PairBornCoulLongCSGPU : public PairBornCoulLongCS {
|
||||||
|
public:
|
||||||
|
PairBornCoulLongCSGPU(LAMMPS *lmp);
|
||||||
|
~PairBornCoulLongCSGPU();
|
||||||
|
void cpu_compute(int, int, int, int, int *, int *, int **);
|
||||||
|
void compute(int, int);
|
||||||
|
void init_style();
|
||||||
|
double memory_usage();
|
||||||
|
|
||||||
|
enum { GPU_FORCE, GPU_NEIGH, GPU_HYB_NEIGH };
|
||||||
|
|
||||||
|
private:
|
||||||
|
int gpu_mode;
|
||||||
|
double cpu_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ERROR/WARNING messages:
|
||||||
|
|
||||||
|
E: Insufficient memory on accelerator
|
||||||
|
|
||||||
|
There is insufficient memory on one of the devices specified for the gpu
|
||||||
|
package
|
||||||
|
|
||||||
|
E: Pair style born/coul/long/cs/gpu requires atom attribute q
|
||||||
|
|
||||||
|
The atom style defined does not have this attribute.
|
||||||
|
|
||||||
|
E: Cannot use newton pair with born/coul/long/cs/gpu pair style
|
||||||
|
|
||||||
|
Self-explanatory.
|
||||||
|
|
||||||
|
E: Pair style requires a KSpace style
|
||||||
|
|
||||||
|
No kspace style is defined.
|
||||||
|
|
||||||
|
*/
|
||||||
320
src/GPU/pair_coul_long_cs_gpu.cpp
Normal file
320
src/GPU/pair_coul_long_cs_gpu.cpp
Normal file
@ -0,0 +1,320 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
Contributing author: Trung Nguyen (Northwestern)
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include "pair_coul_long_cs_gpu.h"
|
||||||
|
#include "atom.h"
|
||||||
|
#include "atom_vec.h"
|
||||||
|
#include "comm.h"
|
||||||
|
#include "force.h"
|
||||||
|
#include "neighbor.h"
|
||||||
|
#include "neigh_list.h"
|
||||||
|
#include "integrate.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "neigh_request.h"
|
||||||
|
#include "universe.h"
|
||||||
|
#include "update.h"
|
||||||
|
#include "domain.h"
|
||||||
|
#include "kspace.h"
|
||||||
|
#include "gpu_extra.h"
|
||||||
|
|
||||||
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
#define EWALD_F 1.12837917
|
||||||
|
#define EWALD_P 9.95473818e-1
|
||||||
|
#define B0 -0.1335096380159268
|
||||||
|
#define B1 -2.57839507e-1
|
||||||
|
#define B2 -1.37203639e-1
|
||||||
|
#define B3 -8.88822059e-3
|
||||||
|
#define B4 -5.80844129e-3
|
||||||
|
#define B5 1.14652755e-1
|
||||||
|
|
||||||
|
#define EPSILON 1.0e-20
|
||||||
|
#define EPS_EWALD 1.0e-6
|
||||||
|
#define EPS_EWALD_SQR 1.0e-12
|
||||||
|
|
||||||
|
// External functions from cuda library for atom decomposition
|
||||||
|
|
||||||
|
int clcs_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 clcs_gpu_reinit(const int ntypes, double **scale);
|
||||||
|
void clcs_gpu_clear();
|
||||||
|
int ** clcs_gpu_compute_n(const int ago, const int inum,
|
||||||
|
const int nall, double **host_x, int *host_type,
|
||||||
|
double *sublo, double *subhi, tagint *tag,
|
||||||
|
int **nspecial, tagint **special, const bool eflag,
|
||||||
|
const bool vflag, const bool eatom, const bool vatom,
|
||||||
|
int &host_start, int **ilist, int **jnum,
|
||||||
|
const double cpu_time, bool &success, double *host_q,
|
||||||
|
double *boxlo, double *prd);
|
||||||
|
void clcs_gpu_compute(const int ago, const int inum, const int nall,
|
||||||
|
double **host_x, int *host_type, int *ilist, int *numj,
|
||||||
|
int **firstneigh, const bool eflag, const bool vflag,
|
||||||
|
const bool eatom, const bool vatom, int &host_start,
|
||||||
|
const double cpu_time, bool &success, double *host_q,
|
||||||
|
const int nlocal, double *boxlo, double *prd);
|
||||||
|
double clcs_gpu_bytes();
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
PairCoulLongCSGPU::PairCoulLongCSGPU(LAMMPS *lmp) :
|
||||||
|
PairCoulLongCS(lmp), gpu_mode(GPU_FORCE)
|
||||||
|
{
|
||||||
|
respa_enable = 0;
|
||||||
|
cpu_time = 0.0;
|
||||||
|
GPU_EXTRA::gpu_ready(lmp->modify, lmp->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
free all arrays
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
PairCoulLongCSGPU::~PairCoulLongCSGPU()
|
||||||
|
{
|
||||||
|
clcs_gpu_clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void PairCoulLongCSGPU::compute(int eflag, int vflag)
|
||||||
|
{
|
||||||
|
if (eflag || vflag) ev_setup(eflag,vflag);
|
||||||
|
else evflag = vflag_fdotr = 0;
|
||||||
|
|
||||||
|
int nall = atom->nlocal + atom->nghost;
|
||||||
|
int inum, host_start;
|
||||||
|
|
||||||
|
bool success = true;
|
||||||
|
int *ilist, *numneigh, **firstneigh;
|
||||||
|
if (gpu_mode != GPU_FORCE) {
|
||||||
|
inum = atom->nlocal;
|
||||||
|
firstneigh = clcs_gpu_compute_n(neighbor->ago, inum, nall, atom->x,
|
||||||
|
atom->type, domain->sublo, domain->subhi,
|
||||||
|
atom->tag, atom->nspecial, atom->special,
|
||||||
|
eflag, vflag, eflag_atom, vflag_atom,
|
||||||
|
host_start, &ilist, &numneigh, cpu_time,
|
||||||
|
success, atom->q, domain->boxlo,
|
||||||
|
domain->prd);
|
||||||
|
} else {
|
||||||
|
inum = list->inum;
|
||||||
|
ilist = list->ilist;
|
||||||
|
numneigh = list->numneigh;
|
||||||
|
firstneigh = list->firstneigh;
|
||||||
|
clcs_gpu_compute(neighbor->ago, inum, nall, atom->x, atom->type,
|
||||||
|
ilist, numneigh, firstneigh, eflag, vflag, eflag_atom,
|
||||||
|
vflag_atom, host_start, cpu_time, success, atom->q,
|
||||||
|
atom->nlocal, domain->boxlo, domain->prd);
|
||||||
|
}
|
||||||
|
if (!success)
|
||||||
|
error->one(FLERR,"Insufficient memory on accelerator");
|
||||||
|
|
||||||
|
if (host_start<inum) {
|
||||||
|
cpu_time = MPI_Wtime();
|
||||||
|
cpu_compute(host_start, inum, eflag, vflag, ilist, numneigh, firstneigh);
|
||||||
|
cpu_time = MPI_Wtime() - cpu_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
init specific to this pair style
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void PairCoulLongCSGPU::init_style()
|
||||||
|
{
|
||||||
|
cut_respa = NULL;
|
||||||
|
|
||||||
|
if (!atom->q_flag)
|
||||||
|
error->all(FLERR,"Pair style coul/long/cs/gpu requires atom attribute q");
|
||||||
|
if (force->newton_pair)
|
||||||
|
error->all(FLERR,"Cannot use newton pair with coul/long/cs/gpu pair style");
|
||||||
|
|
||||||
|
// Call init_one calculation make sure scale is correct
|
||||||
|
for (int i = 1; i <= atom->ntypes; i++) {
|
||||||
|
for (int j = i; j <= atom->ntypes; j++) {
|
||||||
|
if (setflag[i][j] != 0 || (setflag[i][i] != 0 && setflag[j][j] != 0)) {
|
||||||
|
double cut = init_one(i,j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double cell_size = cut_coul + neighbor->skin;
|
||||||
|
|
||||||
|
cut_coulsq = cut_coul * cut_coul;
|
||||||
|
|
||||||
|
// insure use of KSpace long-range solver, set g_ewald
|
||||||
|
|
||||||
|
if (force->kspace == NULL)
|
||||||
|
error->all(FLERR,"Pair style requires a KSpace style");
|
||||||
|
g_ewald = force->kspace->g_ewald;
|
||||||
|
|
||||||
|
// setup force tables
|
||||||
|
|
||||||
|
if (ncoultablebits) init_tables(cut_coul,cut_respa);
|
||||||
|
|
||||||
|
int maxspecial=0;
|
||||||
|
if (atom->molecular)
|
||||||
|
maxspecial=atom->maxspecial;
|
||||||
|
int success = clcs_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);
|
||||||
|
|
||||||
|
GPU_EXTRA::check_flag(success,error,world);
|
||||||
|
|
||||||
|
if (gpu_mode == GPU_FORCE) {
|
||||||
|
int irequest = neighbor->request(this,instance_me);
|
||||||
|
neighbor->requests[irequest]->half = 0;
|
||||||
|
neighbor->requests[irequest]->full = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void PairCoulLongCSGPU::reinit()
|
||||||
|
{
|
||||||
|
Pair::reinit();
|
||||||
|
|
||||||
|
clcs_gpu_reinit(atom->ntypes+1, scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
double PairCoulLongCSGPU::memory_usage()
|
||||||
|
{
|
||||||
|
double bytes = Pair::memory_usage();
|
||||||
|
return bytes + clcs_gpu_bytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void PairCoulLongCSGPU::cpu_compute(int start, int inum, int eflag,
|
||||||
|
int vflag, int *ilist, int *numneigh,
|
||||||
|
int **firstneigh)
|
||||||
|
{
|
||||||
|
int i,j,ii,jj,jnum,itable,itype,jtype;
|
||||||
|
double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,ecoul,fpair;
|
||||||
|
double fraction,table;
|
||||||
|
double r,r2inv,forcecoul,factor_coul;
|
||||||
|
double grij,expm2,prefactor,t,erfc,u;
|
||||||
|
int *jlist;
|
||||||
|
double rsq;
|
||||||
|
|
||||||
|
ecoul = 0.0;
|
||||||
|
|
||||||
|
double **x = atom->x;
|
||||||
|
double **f = atom->f;
|
||||||
|
double *q = atom->q;
|
||||||
|
int *type = atom->type;
|
||||||
|
double *special_coul = force->special_coul;
|
||||||
|
double qqrd2e = force->qqrd2e;
|
||||||
|
|
||||||
|
// loop over neighbors of my atoms
|
||||||
|
|
||||||
|
for (ii = start; ii < inum; ii++) {
|
||||||
|
i = ilist[ii];
|
||||||
|
qtmp = q[i];
|
||||||
|
xtmp = x[i][0];
|
||||||
|
ytmp = x[i][1];
|
||||||
|
ztmp = x[i][2];
|
||||||
|
itype = type[i];
|
||||||
|
jlist = firstneigh[i];
|
||||||
|
jnum = numneigh[i];
|
||||||
|
|
||||||
|
for (jj = 0; jj < jnum; jj++) {
|
||||||
|
j = jlist[jj];
|
||||||
|
factor_coul = special_coul[sbmask(j)];
|
||||||
|
j &= NEIGHMASK;
|
||||||
|
|
||||||
|
delx = xtmp - x[j][0];
|
||||||
|
dely = ytmp - x[j][1];
|
||||||
|
delz = ztmp - x[j][2];
|
||||||
|
rsq = delx*delx + dely*dely + delz*delz;
|
||||||
|
jtype = type[j];
|
||||||
|
|
||||||
|
if (rsq < cut_coulsq) {
|
||||||
|
rsq += EPSILON; // Add Epsilon for case: r = 0; Interaction must be removed by special bond;
|
||||||
|
r2inv = 1.0/rsq;
|
||||||
|
if (!ncoultablebits || rsq <= tabinnersq) {
|
||||||
|
r = sqrt(rsq);
|
||||||
|
prefactor = qqrd2e * scale[itype][jtype] * qtmp*q[j];
|
||||||
|
if (factor_coul < 1.0) {
|
||||||
|
// When bonded parts are being calculated a minimal distance (EPS_EWALD)
|
||||||
|
// has to be added to the prefactor and erfc in order to make the
|
||||||
|
// used approximation functions for the Ewald correction valid
|
||||||
|
grij = g_ewald * (r+EPS_EWALD);
|
||||||
|
expm2 = exp(-grij*grij);
|
||||||
|
t = 1.0 / (1.0 + EWALD_P*grij);
|
||||||
|
u = 1.0 - t;
|
||||||
|
erfc = t * (1.+u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= (r+EPS_EWALD);
|
||||||
|
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2 - (1.0-factor_coul));
|
||||||
|
// Additionally r2inv needs to be accordingly modified since the later
|
||||||
|
// scaling of the overall force shall be consistent
|
||||||
|
r2inv = 1.0/(rsq + EPS_EWALD_SQR);
|
||||||
|
} else {
|
||||||
|
grij = g_ewald * r;
|
||||||
|
expm2 = exp(-grij*grij);
|
||||||
|
t = 1.0 / (1.0 + EWALD_P*grij);
|
||||||
|
u = 1.0 - t;
|
||||||
|
erfc = t * (1.+u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2;
|
||||||
|
prefactor /= r;
|
||||||
|
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
union_int_float_t rsq_lookup;
|
||||||
|
rsq_lookup.f = rsq;
|
||||||
|
itable = rsq_lookup.i & ncoulmask;
|
||||||
|
itable >>= ncoulshiftbits;
|
||||||
|
fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable];
|
||||||
|
table = ftable[itable] + fraction*dftable[itable];
|
||||||
|
forcecoul = scale[itype][jtype] * qtmp*q[j] * table;
|
||||||
|
if (factor_coul < 1.0) {
|
||||||
|
table = ctable[itable] + fraction*dctable[itable];
|
||||||
|
prefactor = scale[itype][jtype] * qtmp*q[j] * table;
|
||||||
|
forcecoul -= (1.0-factor_coul)*prefactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fpair = forcecoul * r2inv;
|
||||||
|
|
||||||
|
f[i][0] += delx*fpair;
|
||||||
|
f[i][1] += dely*fpair;
|
||||||
|
f[i][2] += delz*fpair;
|
||||||
|
|
||||||
|
if (eflag) {
|
||||||
|
if (rsq < cut_coulsq) {
|
||||||
|
if (!ncoultablebits || rsq <= tabinnersq)
|
||||||
|
ecoul = prefactor*erfc;
|
||||||
|
else {
|
||||||
|
table = etable[itable] + fraction*detable[itable];
|
||||||
|
ecoul = scale[itype][jtype] * qtmp*q[j] * table;
|
||||||
|
}
|
||||||
|
if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor;
|
||||||
|
} else ecoul = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (evflag) ev_tally_full(i,0.0,ecoul,fpair,delx,dely,delz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
67
src/GPU/pair_coul_long_cs_gpu.h
Normal file
67
src/GPU/pair_coul_long_cs_gpu.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/* -*- c++ -*- ----------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef PAIR_CLASS
|
||||||
|
|
||||||
|
PairStyle(coul/long/cs/gpu,PairCoulLongCSGPU)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifndef LMP_PAIR_COUL_LONG_CS_GPU_H
|
||||||
|
#define LMP_PAIR_COUL_LONG_CS_GPU_H
|
||||||
|
|
||||||
|
#include "pair_coul_long_cs.h"
|
||||||
|
|
||||||
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
|
class PairCoulLongCSGPU : public PairCoulLongCS {
|
||||||
|
public:
|
||||||
|
PairCoulLongCSGPU(LAMMPS *lmp);
|
||||||
|
~PairCoulLongCSGPU();
|
||||||
|
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 };
|
||||||
|
|
||||||
|
private:
|
||||||
|
int gpu_mode;
|
||||||
|
double cpu_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ERROR/WARNING messages:
|
||||||
|
|
||||||
|
E: Insufficient memory on accelerator
|
||||||
|
|
||||||
|
There is insufficient memory on one of the devices specified for the gpu
|
||||||
|
package
|
||||||
|
|
||||||
|
E: Pair style coul/long/cs/gpu requires atom attribute q
|
||||||
|
|
||||||
|
The atom style defined does not have these attributes.
|
||||||
|
|
||||||
|
E: Cannot use newton pair with coul/long/cs/gpu pair style
|
||||||
|
|
||||||
|
Self-explanatory.
|
||||||
|
|
||||||
|
E: Pair style requires a KSpace style
|
||||||
|
|
||||||
|
No kspace style is defined.
|
||||||
|
|
||||||
|
*/
|
||||||
@ -217,7 +217,7 @@ void PairLJExpandCoulLong::compute_inner()
|
|||||||
int i,j,ii,jj,inum,jnum,itype,jtype;
|
int i,j,ii,jj,inum,jnum,itype,jtype;
|
||||||
double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,fpair;
|
double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,fpair;
|
||||||
double rsq,r2inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj;
|
double rsq,r2inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj;
|
||||||
double rsw,rsq,rshift,rshiftsq,rshift2inv;
|
double rsw,r,rshift,rshiftsq,rshift2inv;
|
||||||
int *ilist,*jlist,*numneigh,**firstneigh;
|
int *ilist,*jlist,*numneigh,**firstneigh;
|
||||||
|
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
@ -306,8 +306,8 @@ void PairLJExpandCoulLong::compute_middle()
|
|||||||
{
|
{
|
||||||
int i,j,ii,jj,inum,jnum,itype,jtype;
|
int i,j,ii,jj,inum,jnum,itype,jtype;
|
||||||
double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,fpair;
|
double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,fpair;
|
||||||
double rsq,r2inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj;
|
double rsq,r,r2inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj;
|
||||||
double rsw,rsq,rshift,rshiftsq,rshift2inv;
|
double rsw,rshift,rshiftsq,rshift2inv;
|
||||||
int *ilist,*jlist,*numneigh,**firstneigh;
|
int *ilist,*jlist,*numneigh,**firstneigh;
|
||||||
|
|
||||||
double **x = atom->x;
|
double **x = atom->x;
|
||||||
|
|||||||
Reference in New Issue
Block a user