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

This commit is contained in:
sjplimp
2016-07-01 23:27:26 +00:00
parent 8366b35459
commit 9656958169
245 changed files with 4890 additions and 4832 deletions

View File

@ -9,7 +9,7 @@
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
__________________________________________________________________________
begin :
begin :
email : nguyentd@ornl.gov
***************************************************************************/
@ -34,35 +34,35 @@ using namespace LAMMPS_AL;
extern Device<PRECISION,ACC_PRECISION> device;
template <class numtyp, class acctyp>
TableT::Table() : BaseAtomic<numtyp,acctyp>(),
TableT::Table() : BaseAtomic<numtyp,acctyp>(),
_allocated(false), _compiled_styles(false) {
}
template <class numtyp, class acctyp>
TableT::~Table() {
TableT::~Table() {
clear();
}
template <class numtyp, class acctyp>
int TableT::bytes_per_atom(const int max_nbors) const {
return this->bytes_per_atom_atomic(max_nbors);
}
template <class numtyp, class acctyp>
int TableT::init(const int ntypes,
int TableT::init(const int ntypes,
double **host_cutsq, double ***host_table_coeffs,
double **host_table_data,
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,
const double gpu_split, FILE *_screen,
int tabstyle, int ntables, int tablength) {
int success;
success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,
gpu_split,_screen,table,"k_table");
if (success!=0)
return success;
k_pair_linear.set_function(*(this->pair_program),"k_table_linear");
k_pair_linear_fast.set_function(*(this->pair_program),"k_table_linear_fast");
k_pair_spline.set_function(*(this->pair_program),"k_table_spline");
@ -80,38 +80,38 @@ int TableT::init(const int ntypes,
shared_types=true;
}
_lj_types=lj_types;
_tabstyle = tabstyle;
_ntables = ntables;
if (tabstyle != BITMAP) _tablength = tablength;
else _tablength = 1 << tablength;
// Allocate a host write buffer for data initialization
UCL_H_Vec<int> host_write_int(lj_types*lj_types,*(this->ucl_device),
UCL_WRITE_ONLY);
for (int i=0; i<lj_types*lj_types; i++)
for (int i=0; i<lj_types*lj_types; i++)
host_write_int[i] = 0;
tabindex.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
nshiftbits.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
nmask.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
for (int ix=1; ix<ntypes; ix++)
for (int iy=1; iy<ntypes; iy++)
for (int iy=1; iy<ntypes; iy++)
host_write_int[ix*lj_types+iy] = (int)host_table_coeffs[ix][iy][0]; // tabindex
ucl_copy(tabindex,host_write_int,false);
for (int ix=1; ix<ntypes; ix++)
for (int iy=1; iy<ntypes; iy++)
for (int iy=1; iy<ntypes; iy++)
host_write_int[ix*lj_types+iy] = (int)host_table_coeffs[ix][iy][1]; // nshiftbits
ucl_copy(nshiftbits,host_write_int,false);
for (int ix=1; ix<ntypes; ix++)
for (int iy=1; iy<ntypes; iy++)
for (int iy=1; iy<ntypes; iy++)
host_write_int[ix*lj_types+iy] = (int)host_table_coeffs[ix][iy][2]; // nmask
ucl_copy(nmask,host_write_int,false);
UCL_H_Vec<numtyp4> host_write(lj_types*lj_types,*(this->ucl_device),
UCL_WRITE_ONLY);
@ -151,7 +151,7 @@ int TableT::init(const int ntypes,
host_write2[n*_tablength+k].z = host_table_data[n][6*k+2]; // f
host_write2[n*_tablength+k].w = (numtyp)0;
}
}
}
}
ucl_copy(coeff3,host_write2,false);
@ -166,21 +166,21 @@ int TableT::init(const int ntypes,
for (int n=0; n<_ntables; n++) {
if (tabstyle == LINEAR) {
for (int k=0; k<_tablength-1; k++) {
host_write2[n*_tablength+k].x = (numtyp)0;
host_write2[n*_tablength+k].x = (numtyp)0;
host_write2[n*_tablength+k].y = host_table_data[n][6*k+3]; // de
host_write2[n*_tablength+k].z = host_table_data[n][6*k+4]; // df
host_write2[n*_tablength+k].w = (numtyp)0;
}
} else if (tabstyle == SPLINE) {
for (int k=0; k<_tablength; k++) {
host_write2[n*_tablength+k].x = (numtyp)0;
host_write2[n*_tablength+k].x = (numtyp)0;
host_write2[n*_tablength+k].y = host_table_data[n][6*k+3]; // e2
host_write2[n*_tablength+k].z = host_table_data[n][6*k+4]; // f2
host_write2[n*_tablength+k].w = (numtyp)0;
}
} else if (tabstyle == BITMAP) {
for (int k=0; k<_tablength; k++) {
host_write2[n*_tablength+k].x = (numtyp)0;
host_write2[n*_tablength+k].x = (numtyp)0;
host_write2[n*_tablength+k].y = host_table_data[n][6*k+3]; // de
host_write2[n*_tablength+k].z = host_table_data[n][6*k+4]; // df
host_write2[n*_tablength+k].w = host_table_data[n][6*k+5]; // drsq
@ -188,12 +188,12 @@ int TableT::init(const int ntypes,
}
}
ucl_copy(coeff4,host_write2,false);
UCL_H_Vec<numtyp> host_rsq(lj_types*lj_types,*(this->ucl_device),
UCL_WRITE_ONLY);
cutsq.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
this->atom->type_pack1(ntypes,lj_types,cutsq,host_rsq,host_cutsq);
UCL_H_Vec<double> dview;
sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY);
dview.view(host_special_lj,4,*(this->ucl_device));
@ -220,7 +220,7 @@ void TableT::clear() {
coeff3.clear();
coeff4.clear();
sp_lj.clear();
if (_compiled_styles) {
k_pair_linear_fast.clear();
k_pair_linear.clear();
@ -230,7 +230,7 @@ void TableT::clear() {
k_pair_bitmap.clear();
_compiled_styles=false;
}
this->clear_atomic();
}
@ -256,7 +256,7 @@ void TableT::loop(const bool _eflag, const bool _vflag) {
vflag=1;
else
vflag=0;
int GX=static_cast<int>(ceil(static_cast<double>(this->ans->inum())/
(BX/this->_threads_per_atom)));
@ -269,67 +269,67 @@ void TableT::loop(const bool _eflag, const bool _vflag) {
this->k_pair_fast.run(&this->atom->x, &tabindex, &coeff2, &coeff3,
&coeff4, &cutsq, &sp_lj, &this->nbor->dev_nbor,
&this->_nbor_data->begin(), &this->ans->force,
&this->ans->engv, &eflag, &vflag, &ainum,
&this->ans->engv, &eflag, &vflag, &ainum,
&nbor_pitch, &this->_threads_per_atom, &_tablength);
} else if (_tabstyle == LINEAR) {
this->k_pair_linear_fast.set_size(GX,BX);
this->k_pair_linear_fast.run(&this->atom->x, &tabindex, &coeff2,
this->k_pair_linear_fast.run(&this->atom->x, &tabindex, &coeff2,
&coeff3, &coeff4, &cutsq, &sp_lj,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&this->ans->force, &this->ans->engv,
&eflag, &vflag, &ainum, &nbor_pitch,
&eflag, &vflag, &ainum, &nbor_pitch,
&this->_threads_per_atom, &_tablength);
} else if (_tabstyle == SPLINE) {
this->k_pair_spline_fast.set_size(GX,BX);
this->k_pair_spline_fast.run(&this->atom->x, &tabindex, &coeff2,
this->k_pair_spline_fast.run(&this->atom->x, &tabindex, &coeff2,
&coeff3, &coeff4, &cutsq, &sp_lj,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&this->ans->force, &this->ans->engv,
&eflag, &vflag, &ainum, &nbor_pitch,
&eflag, &vflag, &ainum, &nbor_pitch,
&this->_threads_per_atom, &_tablength);
} else if (_tabstyle == BITMAP) {
this->k_pair_bitmap_fast.set_size(GX,BX);
this->k_pair_bitmap_fast.run(&this->atom->x, &tabindex, &nshiftbits,
&nmask, &coeff2, &coeff3, &coeff4, &cutsq,
&sp_lj, &this->nbor->dev_nbor,
&sp_lj, &this->nbor->dev_nbor,
&this->_nbor_data->begin(), &this->ans->force,
&this->ans->engv, &eflag, &vflag,
&ainum, &nbor_pitch,
&ainum, &nbor_pitch,
&this->_threads_per_atom, &_tablength);
}
}
} else {
if (_tabstyle == LOOKUP) {
this->k_pair.set_size(GX,BX);
this->k_pair.run(&this->atom->x, &tabindex, &coeff2, &coeff3,
&coeff4, &_lj_types, &cutsq, &sp_lj,
this->k_pair.run(&this->atom->x, &tabindex, &coeff2, &coeff3,
&coeff4, &_lj_types, &cutsq, &sp_lj,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&this->ans->force, &this->ans->engv, &eflag,
&this->ans->force, &this->ans->engv, &eflag,
&vflag, &ainum, &nbor_pitch, &this->_threads_per_atom,
&_tablength);
} else if (_tabstyle == LINEAR) {
this->k_pair_linear.set_size(GX,BX);
this->k_pair_linear.run(&this->atom->x, &tabindex, &coeff2, &coeff3,
&coeff4, &_lj_types, &cutsq, &sp_lj,
&coeff4, &_lj_types, &cutsq, &sp_lj,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&this->ans->force, &this->ans->engv, &eflag,
&vflag, &ainum, &nbor_pitch,
&vflag, &ainum, &nbor_pitch,
&this->_threads_per_atom, &_tablength);
} else if (_tabstyle == SPLINE) {
this->k_pair_spline.set_size(GX,BX);
this->k_pair_spline.run(&this->atom->x, &tabindex, &coeff2, &coeff3,
&coeff4, &_lj_types, &cutsq, &sp_lj,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&coeff4, &_lj_types, &cutsq, &sp_lj,
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
&this->ans->force, &this->ans->engv, &eflag,
&vflag, &ainum, &nbor_pitch,
&vflag, &ainum, &nbor_pitch,
&this->_threads_per_atom, &_tablength);
} else if (_tabstyle == BITMAP) {
this->k_pair_bitmap.set_size(GX,BX);
this->k_pair_bitmap.run(&this->atom->x, &tabindex, &nshiftbits,
this->k_pair_bitmap.run(&this->atom->x, &tabindex, &nshiftbits,
&nmask, &coeff2, &coeff3, &coeff4, &_lj_types,
&cutsq, &sp_lj, &this->nbor->dev_nbor,
&this->_nbor_data->begin(), &this->ans->force,
&this->ans->engv, &eflag, &vflag, &ainum,
&nbor_pitch, &this->_threads_per_atom,
&nbor_pitch, &this->_threads_per_atom,
&_tablength);
}
}