git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14265 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2015-11-18 18:23:45 +00:00
parent e3c4db746c
commit f6c76f4623
9 changed files with 568 additions and 582 deletions

View File

@ -33,10 +33,10 @@ TersoffT::Tersoff() : BaseThree<numtyp,acctyp>(), _allocated(false) {
}
template <class numtyp, class acctyp>
TersoffT::~Tersoff() {
TersoffT::~Tersoff() {
clear();
}
template <class numtyp, class acctyp>
int TersoffT::bytes_per_atom(const int max_nbors) const {
return this->bytes_per_atom_atomic(max_nbors);
@ -45,11 +45,11 @@ int TersoffT::bytes_per_atom(const int max_nbors) const {
template <class numtyp, class acctyp>
int TersoffT::init(const int ntypes, const int nlocal, const int nall, const int max_nbors,
const double cell_size, const double gpu_split, FILE *_screen,
int* host_map, const int nelements, int*** host_elem2param, const int nparams,
int* host_map, const int nelements, int*** host_elem2param, const int nparams,
const double* lam1, const double* lam2, const double* lam3,const double* powermint,
const double* biga, const double* bigb, const double* bigr, const double* bigd,
const double* c1, const double* c2, const double* c3, const double* c4,
const double* c, const double* d, const double* h, const double* gamma,
const double* biga, const double* bigb, const double* bigr, const double* bigd,
const double* c1, const double* c2, const double* c3, const double* c4,
const double* c, const double* d, const double* h, const double* gamma,
const double* beta, const double* powern, const double* host_cutsq)
{
int success;
@ -62,11 +62,7 @@ int TersoffT::init(const int ntypes, const int nlocal, const int nall, const int
int ef_nall=nall;
if (ef_nall==0)
ef_nall=2000;
_max_zij_size=static_cast<int>(static_cast<double>(ef_nall)*1.10);
_zetaij.alloc(_max_zij_size*max_nbors,*(this->ucl_device),UCL_READ_WRITE);
zeta_tex.get_texture(*(this->pair_program),"zeta_tex");
zeta_tex.bind_float(_zetaij,1);
_zetaij.alloc(ef_nall*max_nbors,*(this->ucl_device),UCL_READ_WRITE);
k_zeta.set_function(*(this->pair_program),"k_tersoff_zeta");
@ -87,74 +83,74 @@ int TersoffT::init(const int ntypes, const int nlocal, const int nall, const int
UCL_WRITE_ONLY);
for (int i=0; i<nparams; i++) {
dview[i].x=(numtyp)0;
dview[i].x=(numtyp)0;
dview[i].y=(numtyp)0;
dview[i].z=(numtyp)0;
dview[i].z=(numtyp)0;
dview[i].w=(numtyp)0;
}
// pack coefficients into arrays
ts1.alloc(nparams,*(this->ucl_device),UCL_READ_ONLY);
for (int i=0; i<nparams; i++) {
dview[i].x=static_cast<numtyp>(lam1[i]);
dview[i].y=static_cast<numtyp>(lam2[i]);
dview[i].z=static_cast<numtyp>(lam3[i]);
dview[i].w=static_cast<numtyp>(powermint[i]);
}
ucl_copy(ts1,dview,false);
ts1_tex.get_texture(*(this->pair_program),"ts1_tex");
ts1_tex.bind_float(ts1,4);
ts2.alloc(nparams,*(this->ucl_device),UCL_READ_ONLY);
for (int i=0; i<nparams; i++) {
dview[i].x=static_cast<numtyp>(biga[i]);
dview[i].y=static_cast<numtyp>(bigb[i]);
dview[i].z=static_cast<numtyp>(bigr[i]);
dview[i].w=static_cast<numtyp>(bigd[i]);
}
ucl_copy(ts2,dview,false);
ts2_tex.get_texture(*(this->pair_program),"ts2_tex");
ts2_tex.bind_float(ts2,4);
ts3.alloc(nparams,*(this->ucl_device),UCL_READ_ONLY);
for (int i=0; i<nparams; i++) {
dview[i].x=static_cast<numtyp>(c1[i]);
dview[i].y=static_cast<numtyp>(c2[i]);
dview[i].z=static_cast<numtyp>(c3[i]);
dview[i].w=static_cast<numtyp>(c4[i]);
}
ucl_copy(ts3,dview,false);
ts3_tex.get_texture(*(this->pair_program),"ts3_tex");
ts3_tex.bind_float(ts3,4);
ts4.alloc(nparams,*(this->ucl_device),UCL_READ_ONLY);
for (int i=0; i<nparams; i++) {
dview[i].x=static_cast<numtyp>(c[i]);
dview[i].y=static_cast<numtyp>(d[i]);
dview[i].z=static_cast<numtyp>(h[i]);
dview[i].w=static_cast<numtyp>(gamma[i]);
}
ucl_copy(ts4,dview,false);
ts4_tex.get_texture(*(this->pair_program),"ts4_tex");
ts4_tex.bind_float(ts4,4);
ts5.alloc(nparams,*(this->ucl_device),UCL_READ_ONLY);
for (int i=0; i<nparams; i++) {
dview[i].x=static_cast<numtyp>(beta[i]);
dview[i].y=static_cast<numtyp>(powern[i]);
dview[i].z=(numtyp)0;
dview[i].w=(numtyp)0;
}
ucl_copy(ts5,dview,false);
ts5_tex.get_texture(*(this->pair_program),"ts5_tex");
ts5_tex.bind_float(ts5,4);
@ -227,11 +223,11 @@ double TersoffT::host_memory_usage() const {
// Copy nbor list from host if necessary and then calculate forces, virials,..
// ---------------------------------------------------------------------------
template <class numtyp, class acctyp>
void TersoffT::compute(const int f_ago, const int nlocal, const int nall,
void TersoffT::compute(const int f_ago, const int nlocal, const int nall,
const int nlist, double **host_x, int *host_type,
int *ilist, int *numj, int **firstneigh,
int *ilist, int *numj, int **firstneigh,
const bool eflag, const bool vflag, const bool eatom,
const bool vatom, int &host_start,
const bool vatom, int &host_start,
const double cpu_time, bool &success) {
this->acc_timers();
if (nlist==0) {
@ -254,6 +250,7 @@ void TersoffT::compute(const int f_ago, const int nlocal, const int nall,
this->reset_nbors(nall, inum, nlist, ilist, numj, firstneigh, success);
if (!success)
return;
_max_nbors = this->nbor->max_nbor_loop(nlist,numj,ilist);
}
this->atom->cast_x_data(host_x,host_type);
@ -261,24 +258,28 @@ void TersoffT::compute(const int f_ago, const int nlocal, const int nall,
this->atom->add_x_data(host_x,host_type);
// re-allocate zetaij if necessary
if (nall>_max_zij_size) {
_max_nbors = this->nbor->max_nbor_loop(nlist,numj,ilist);
_max_zij_size=static_cast<int>(static_cast<double>(nall)*1.10);
_zetaij.resize(_max_nbors*_max_zij_size);
zeta_tex.bind_float(_zetaij,1);
if (nall*_max_nbors > _zetaij.cols()) {
int _nmax=static_cast<int>(static_cast<double>(nall)*1.10);
_zetaij.resize(_max_nbors*_nmax);
}
int _eflag;
if (eflag)
_eflag=1;
else
_eflag=0;
int ainum=nall;
int nbor_pitch=this->nbor->nbor_pitch();
int BX=this->block_pair();
int GX=static_cast<int>(ceil(static_cast<double>(ainum)/
(BX/this->_threads_per_atom)));
int GX=static_cast<int>(ceil(static_cast<double>(ainum)/
(BX/(JTHREADS*KTHREADS))));
this->k_zeta.set_size(GX,BX);
this->k_zeta.run(&this->atom->x, &ts1, &ts2, &ts4, &cutsq,
this->k_zeta.run(&this->atom->x, &ts1, &ts2, &ts3, &ts4, &ts5, &cutsq,
&map, &elem2param, &_nelements, &_nparams, &_zetaij,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&nall, &ainum, &nbor_pitch, &this->_threads_per_atom);
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&_eflag, &nall, &ainum, &nbor_pitch, &this->_threads_per_atom);
int evatom=0;
if (eatom || vatom)
@ -303,7 +304,7 @@ template <class numtyp, class acctyp>
int ** TersoffT::compute(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,
int **nspecial, tagint **special, const bool eflag,
const bool vflag, const bool eatom,
const bool vatom, int &host_start,
int **ilist, int **jnum,
@ -317,7 +318,7 @@ int ** TersoffT::compute(const int ago, const int inum_full,
this->zero_timers();
return NULL;
}
this->hd_balancer.balance(cpu_time);
int inum=this->hd_balancer.get_gpu_count(ago,inum_full);
this->ans->inum(inum);
@ -325,7 +326,7 @@ int ** TersoffT::compute(const int ago, const int inum_full,
this->ans2->inum(inum);
#endif
host_start=inum;
// Build neighbor list on GPU if necessary
if (ago==0) {
_max_nbors = this->build_nbor_list(inum, inum_full-inum, nall, host_x, host_type,
@ -342,23 +343,28 @@ int ** TersoffT::compute(const int ago, const int inum_full,
*jnum=this->nbor->host_acc.begin();
// re-allocate zetaij if necessary
if (nall>_max_zij_size) {
_max_zij_size=static_cast<int>(static_cast<double>(nall)*1.10);
_zetaij.resize(_max_nbors*_max_zij_size);
zeta_tex.bind_float(_zetaij,1);
if (nall*_max_nbors > _zetaij.cols()) {
int _nmax=static_cast<int>(static_cast<double>(nall)*1.10);
_zetaij.resize(_max_nbors*_nmax);
}
int _eflag;
if (eflag)
_eflag=1;
else
_eflag=0;
int ainum=nall;
int nbor_pitch=this->nbor->nbor_pitch();
int BX=this->block_pair();
int GX=static_cast<int>(ceil(static_cast<double>(ainum)/
(BX/this->_threads_per_atom)));
int GX=static_cast<int>(ceil(static_cast<double>(ainum)/
(BX/(JTHREADS*KTHREADS))));
this->k_zeta.set_size(GX,BX);
this->k_zeta.run(&this->atom->x, &ts1, &ts2, &ts4, &cutsq, &map,
&elem2param, &_nelements, &_nparams, &_zetaij,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&nall, &ainum, &nbor_pitch, &this->_threads_per_atom);
this->k_zeta.run(&this->atom->x, &ts1, &ts2, &ts3, &ts4, &ts5, &cutsq,
&map, &elem2param, &_nelements, &_nparams, &_zetaij,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&_eflag, &nall, &ainum, &nbor_pitch, &this->_threads_per_atom);
int evatom=0;
if (eatom || vatom)
@ -374,7 +380,7 @@ int ** TersoffT::compute(const int ago, const int inum_full,
this->device->add_ans_object(this->ans2);
#endif
this->hd_balancer.stop_timer();
return this->nbor->host_jlist.begin()-host_start;
}
@ -403,21 +409,21 @@ void TersoffT::loop(const bool _eflag, const bool _vflag, const int evatom) {
this->time_pair.start();
this->k_pair.set_size(GX,BX);
this->k_pair.run(&this->atom->x, &ts1, &ts2, &cutsq,
this->k_pair.run(&this->atom->x, &ts1, &ts2, &cutsq,
&map, &elem2param, &_nelements, &_nparams,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&this->ans->force, &this->ans->engv,
&eflag, &vflag, &ainum, &nbor_pitch,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&this->ans->force, &this->ans->engv,
&eflag, &vflag, &ainum, &nbor_pitch,
&this->_threads_per_atom);
BX=this->block_size();
GX=static_cast<int>(ceil(static_cast<double>(this->ans->inum())/
(BX/(KTHREADS*JTHREADS))));
(BX/(KTHREADS*JTHREADS))));
this->k_three_center.set_size(GX,BX);
this->k_three_center.run(&this->atom->x, &ts1, &ts2, &ts3, &ts4, &ts5, &cutsq,
this->k_three_center.run(&this->atom->x, &ts1, &ts2, &ts4, &cutsq,
&map, &elem2param, &_nelements, &_nparams, &_zetaij,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum,
&nbor_pitch, &this->_threads_per_atom, &evatom);
Answer<numtyp,acctyp> *end_ans;
@ -428,20 +434,19 @@ void TersoffT::loop(const bool _eflag, const bool _vflag, const int evatom) {
#endif
if (evatom!=0) {
this->k_three_end_vatom.set_size(GX,BX);
this->k_three_end_vatom.run(&this->atom->x, &ts1, &ts2, &ts3, &ts4, &ts5, &cutsq,
&map, &elem2param, &_nelements, &_nparams, &_zetaij,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
this->k_three_end_vatom.run(&this->atom->x, &ts1, &ts2, &ts4, &cutsq,
&map, &elem2param, &_nelements, &_nparams, &_zetaij,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum,
&nbor_pitch, &this->_threads_per_atom);
} else {
this->k_three_end.set_size(GX,BX);
this->k_three_end.run(&this->atom->x, &ts1, &ts2, &ts3, &ts4, &ts5, &cutsq,
&map, &elem2param, &_nelements, &_nparams, &_zetaij,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum,
this->k_three_end.run(&this->atom->x, &ts1, &ts2, &ts4, &cutsq,
&map, &elem2param, &_nelements, &_nparams, &_zetaij,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&end_ans->force, &end_ans->engv, &eflag, &vflag, &ainum,
&nbor_pitch, &this->_threads_per_atom);
}
this->time_pair.stop();