1
/***************************************************************************
4
Trung Dac Nguyen (ORNL)
6
Class for acceleration of the mie pair style.
8
__________________________________________________________________________
9
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
10
__________________________________________________________________________
13
email : nguyentd@ornl.gov
14
***************************************************************************/
18
#elif defined(USE_CUDART)
21
#include "mie_cubin.h"
26
using namespace LAMMPS_AL;
27
#define MieT Mie<numtyp, acctyp>
29
extern Device<PRECISION,ACC_PRECISION> device;
31
template <class numtyp, class acctyp>
32
MieT::Mie() : BaseAtomic<numtyp,acctyp>(), _allocated(false) {
35
template <class numtyp, class acctyp>
40
template <class numtyp, class acctyp>
41
int MieT::bytes_per_atom(const int max_nbors) const {
42
return this->bytes_per_atom_atomic(max_nbors);
45
template <class numtyp, class acctyp>
46
int MieT::init(const int ntypes, double **host_cutsq,
47
double **host_mie1, double **host_mie2,
48
double **host_mie3, double **host_mie4,
49
double **host_gamA, double **host_gamR,
50
double **host_offset, double *host_special_lj,
51
const int nlocal, const int nall, const int max_nbors,
52
const int maxspecial, const double cell_size,
53
const double gpu_split, FILE *_screen) {
55
success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split,
60
// If atom type constants fit in shared memory use fast kernel
63
int max_shared_types=this->device->max_shared_types();
64
if (lj_types<=max_shared_types && this->_block_size>=max_shared_types) {
65
lj_types=max_shared_types;
70
// Allocate a host write buffer for data initialization
71
UCL_H_Vec<numtyp> host_write(lj_types*lj_types*32,*(this->ucl_device),
74
for (int i=0; i<lj_types*lj_types; i++)
77
mie1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
78
this->atom->type_pack4(ntypes,lj_types,mie1,host_write,host_mie1,host_mie2,
81
mie3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
82
this->atom->type_pack4(ntypes,lj_types,mie3,host_write,host_mie3,host_mie4,
83
host_offset,host_cutsq);
85
UCL_H_Vec<double> dview;
86
sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY);
87
dview.view(host_special_lj,4,*(this->ucl_device));
88
ucl_copy(sp_lj,dview,false);
91
this->_max_bytes=mie1.row_bytes()+mie3.row_bytes()+sp_lj.row_bytes();
95
template <class numtyp, class acctyp>
104
this->clear_atomic();
107
template <class numtyp, class acctyp>
108
double MieT::host_memory_usage() const {
109
return this->host_memory_usage_atomic()+sizeof(Mie<numtyp,acctyp>);
112
// ---------------------------------------------------------------------------
113
// Calculate energies, forces, and torques
114
// ---------------------------------------------------------------------------
115
template <class numtyp, class acctyp>
116
void MieT::loop(const bool _eflag, const bool _vflag) {
117
// Compute the block size and grid size to keep all cores busy
118
const int BX=this->block_size();
130
int GX=static_cast<int>(ceil(static_cast<double>(this->ans->inum())/
131
(BX/this->_threads_per_atom)));
133
int ainum=this->ans->inum();
134
int nbor_pitch=this->nbor->nbor_pitch();
135
this->time_pair.start();
137
this->k_pair_fast.set_size(GX,BX);
138
this->k_pair_fast.run(&this->atom->x, &mie1, &mie3, &sp_lj,
139
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
140
&this->ans->force, &this->ans->engv, &eflag, &vflag,
141
&ainum, &nbor_pitch, &this->_threads_per_atom);
143
this->k_pair.set_size(GX,BX);
144
this->k_pair.run(&this->atom->x, &mie1, &mie3, &_lj_types, &sp_lj,
145
&this->nbor->dev_nbor, &this->_nbor_data->begin(),
146
&this->ans->force, &this->ans->engv, &eflag, &vflag,
147
&ainum, &nbor_pitch, &this->_threads_per_atom);
149
this->time_pair.stop();
152
template class Mie<PRECISION,ACC_PRECISION>;