Only transfer data arrays that are needed in each kernel
This commit is contained in:
@ -350,8 +350,7 @@ int** BaseAmoebaT::precompute(const int ago, const int inum_full, const int nall
|
|||||||
const bool eflag_in, const bool vflag_in,
|
const bool eflag_in, const bool vflag_in,
|
||||||
const bool eatom, const bool vatom, int &host_start,
|
const bool eatom, const bool vatom, int &host_start,
|
||||||
int **&ilist, int **&jnum, const double cpu_time,
|
int **&ilist, int **&jnum, const double cpu_time,
|
||||||
bool &success, double *host_q, double *boxlo,
|
bool &success, double *host_q, double *boxlo, double *prd) {
|
||||||
double *prd) {
|
|
||||||
acc_timers();
|
acc_timers();
|
||||||
if (eatom) _eflag=2;
|
if (eatom) _eflag=2;
|
||||||
else if (eflag_in) _eflag=1;
|
else if (eflag_in) _eflag=1;
|
||||||
@ -509,7 +508,7 @@ int** BaseAmoebaT::compute_udirect2b(const int ago, const int inum_full,
|
|||||||
int** firstneigh = nullptr;
|
int** firstneigh = nullptr;
|
||||||
|
|
||||||
cast_extra_data(host_amtype, host_amgroup, host_rpole, host_uind, host_uinp, host_pval);
|
cast_extra_data(host_amtype, host_amgroup, host_rpole, host_uind, host_uinp, host_pval);
|
||||||
atom->add_extra_data();
|
atom->add_extra_data();
|
||||||
|
|
||||||
// ------------------- Resize _fieldp array ------------------------
|
// ------------------- Resize _fieldp array ------------------------
|
||||||
|
|
||||||
@ -647,30 +646,34 @@ void BaseAmoebaT::cast_extra_data(int* amtype, int* amgroup, double** rpole,
|
|||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int nstride = 4;
|
int nstride = 4;
|
||||||
for (int i = 0; i < _nall; i++) {
|
if (rpole) {
|
||||||
int idx = n+i*nstride;
|
for (int i = 0; i < _nall; i++) {
|
||||||
pextra[idx] = rpole[i][0];
|
int idx = n+i*nstride;
|
||||||
pextra[idx+1] = rpole[i][1];
|
pextra[idx] = rpole[i][0];
|
||||||
pextra[idx+2] = rpole[i][2];
|
pextra[idx+1] = rpole[i][1];
|
||||||
pextra[idx+3] = rpole[i][3];
|
pextra[idx+2] = rpole[i][2];
|
||||||
}
|
pextra[idx+3] = rpole[i][3];
|
||||||
|
}
|
||||||
|
|
||||||
n += nstride*_nall;
|
n += nstride*_nall;
|
||||||
for (int i = 0; i < _nall; i++) {
|
for (int i = 0; i < _nall; i++) {
|
||||||
int idx = n+i*nstride;
|
int idx = n+i*nstride;
|
||||||
pextra[idx] = rpole[i][4];
|
pextra[idx] = rpole[i][4];
|
||||||
pextra[idx+1] = rpole[i][5];
|
pextra[idx+1] = rpole[i][5];
|
||||||
pextra[idx+2] = rpole[i][6];
|
pextra[idx+2] = rpole[i][6];
|
||||||
pextra[idx+3] = rpole[i][8];
|
pextra[idx+3] = rpole[i][8];
|
||||||
}
|
}
|
||||||
|
|
||||||
n += nstride*_nall;
|
n += nstride*_nall;
|
||||||
for (int i = 0; i < _nall; i++) {
|
for (int i = 0; i < _nall; i++) {
|
||||||
int idx = n+i*nstride;
|
int idx = n+i*nstride;
|
||||||
pextra[idx] = rpole[i][9];
|
pextra[idx] = rpole[i][9];
|
||||||
pextra[idx+1] = rpole[i][12];
|
pextra[idx+1] = rpole[i][12];
|
||||||
pextra[idx+2] = (numtyp)amtype[i];
|
pextra[idx+2] = (numtyp)amtype[i];
|
||||||
pextra[idx+3] = (numtyp)amgroup[i];
|
pextra[idx+3] = (numtyp)amgroup[i];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
n += 2*nstride*_nall;
|
||||||
}
|
}
|
||||||
|
|
||||||
n += nstride*_nall;
|
n += nstride*_nall;
|
||||||
|
|||||||
@ -314,23 +314,12 @@ int** HippoT::compute_dispersion_real(const int ago, const int inum_full,
|
|||||||
const double cpu_time, bool &success,
|
const double cpu_time, bool &success,
|
||||||
const double aewald, const double off2_disp,
|
const double aewald, const double off2_disp,
|
||||||
double *host_q, double *boxlo, double *prd) {
|
double *host_q, double *boxlo, double *prd) {
|
||||||
// reallocate per-atom arrays, transfer data from the host
|
|
||||||
// and build the neighbor lists if needed
|
|
||||||
// NOTE:
|
|
||||||
// For now we invoke precompute() again here,
|
|
||||||
// to be able to turn on/off the udirect2b kernel (which comes before this)
|
|
||||||
// We only need to cast necesary data arrays from host to device here
|
|
||||||
// because the neighbor lists are rebuilt and other per-atom arrays
|
|
||||||
// (x, type) are ready on the device.
|
|
||||||
|
|
||||||
int** firstneigh = nullptr;
|
// cast necessary data arrays from host to device
|
||||||
firstneigh = this->precompute(ago, inum_full, nall, host_x, host_type,
|
|
||||||
host_amtype, host_amgroup, host_rpole,
|
this->cast_extra_data(host_amtype, host_amgroup, host_rpole,
|
||||||
nullptr, nullptr, nullptr, sublo, subhi, tag,
|
nullptr, nullptr, nullptr);
|
||||||
nspecial, special, nspecial15, special15,
|
this->atom->add_extra_data();
|
||||||
eflag_in, vflag_in, eatom, vatom,
|
|
||||||
host_start, ilist, jnum, cpu_time,
|
|
||||||
success, host_q, boxlo, prd);
|
|
||||||
|
|
||||||
this->_off2_disp = off2_disp;
|
this->_off2_disp = off2_disp;
|
||||||
this->_aewald = aewald;
|
this->_aewald = aewald;
|
||||||
@ -344,7 +333,7 @@ int** HippoT::compute_dispersion_real(const int ago, const int inum_full,
|
|||||||
|
|
||||||
this->hd_balancer.stop_timer();
|
this->hd_balancer.stop_timer();
|
||||||
|
|
||||||
return firstneigh; // nbor->host_jlist.begin()-host_start;
|
return nullptr; // nbor->host_jlist.begin()-host_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -407,25 +396,11 @@ int** HippoT::compute_multipole_real(const int ago, const int inum_full,
|
|||||||
const double aewald, const double felec,
|
const double aewald, const double felec,
|
||||||
const double off2_mpole, double *host_q,
|
const double off2_mpole, double *host_q,
|
||||||
double *boxlo, double *prd, void **tep_ptr) {
|
double *boxlo, double *prd, void **tep_ptr) {
|
||||||
// reallocate per-atom arrays, transfer data from the host
|
|
||||||
// and build the neighbor lists if needed
|
|
||||||
// NOTE:
|
|
||||||
// For now we invoke precompute() again here,
|
|
||||||
// to be able to turn on/off the udirect2b kernel (which comes before this)
|
|
||||||
// Once all the kernels are ready, precompute() is needed only once
|
|
||||||
// in the first kernel in a time step.
|
|
||||||
// We only need to cast uind and uinp from host to device here
|
|
||||||
// if the neighbor lists are rebuilt and other per-atom arrays
|
|
||||||
// (x, type, amtype, amgroup, rpole) are ready on the device.
|
|
||||||
|
|
||||||
int** firstneigh = nullptr;
|
// cast necessary data arrays from host to device
|
||||||
firstneigh = this->precompute(ago, inum_full, nall, host_x, host_type,
|
|
||||||
host_amtype, host_amgroup, host_rpole,
|
this->cast_extra_data(nullptr, nullptr, nullptr, nullptr, nullptr, host_pval);
|
||||||
nullptr, nullptr, host_pval, sublo, subhi, tag,
|
this->atom->add_extra_data();
|
||||||
nspecial, special, nspecial15, special15,
|
|
||||||
eflag_in, vflag_in, eatom, vatom,
|
|
||||||
host_start, ilist, jnum, cpu_time,
|
|
||||||
success, host_q, boxlo, prd);
|
|
||||||
|
|
||||||
// ------------------- Resize _tep array ------------------------
|
// ------------------- Resize _tep array ------------------------
|
||||||
|
|
||||||
@ -451,7 +426,7 @@ int** HippoT::compute_multipole_real(const int ago, const int inum_full,
|
|||||||
|
|
||||||
this->_tep.update_host(this->_max_tep_size*4,false);
|
this->_tep.update_host(this->_max_tep_size*4,false);
|
||||||
|
|
||||||
return firstneigh; // nbor->host_jlist.begin()-host_start;
|
return nullptr; // nbor->host_jlist.begin()-host_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -516,17 +491,11 @@ int** HippoT::compute_udirect2b(const int ago, const int inum_full,
|
|||||||
const double aewald, const double off2_polar,
|
const double aewald, const double off2_polar,
|
||||||
double *host_q, double *boxlo, double *prd,
|
double *host_q, double *boxlo, double *prd,
|
||||||
void** fieldp_ptr) {
|
void** fieldp_ptr) {
|
||||||
// reallocate per-atom arrays, transfer data from the host
|
|
||||||
// and build the neighbor lists if needed
|
|
||||||
|
|
||||||
int** firstneigh = nullptr;
|
// all the necessary data arrays are already copied from host to device
|
||||||
firstneigh = this->precompute(ago, inum_full, nall, host_x, host_type,
|
|
||||||
host_amtype, host_amgroup, host_rpole,
|
this->cast_extra_data(nullptr, nullptr, nullptr, host_uind, host_uinp, host_pval);
|
||||||
host_uind, host_uinp, host_pval, sublo, subhi, tag,
|
this->atom->add_extra_data();
|
||||||
nspecial, special, nspecial15, special15,
|
|
||||||
eflag_in, vflag_in, eatom, vatom,
|
|
||||||
host_start, ilist, jnum, cpu_time,
|
|
||||||
success, host_q, boxlo, prd);
|
|
||||||
|
|
||||||
// ------------------- Resize _fieldp array ------------------------
|
// ------------------- Resize _fieldp array ------------------------
|
||||||
|
|
||||||
@ -544,7 +513,7 @@ int** HippoT::compute_udirect2b(const int ago, const int inum_full,
|
|||||||
|
|
||||||
this->_fieldp.update_host(this->_max_fieldp_size*8,false);
|
this->_fieldp.update_host(this->_max_fieldp_size*8,false);
|
||||||
|
|
||||||
return firstneigh; //nbor->host_jlist.begin()-host_start;
|
return nullptr; //nbor->host_jlist.begin()-host_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -608,17 +577,11 @@ int** HippoT::compute_umutual2b(const int ago, const int inum_full,
|
|||||||
const double aewald, const double off2_polar,
|
const double aewald, const double off2_polar,
|
||||||
double *host_q, double *boxlo, double *prd,
|
double *host_q, double *boxlo, double *prd,
|
||||||
void** fieldp_ptr) {
|
void** fieldp_ptr) {
|
||||||
// reallocate per-atom arrays, transfer extra data from the host
|
|
||||||
// and build the neighbor lists if needed
|
|
||||||
|
|
||||||
int** firstneigh = nullptr;
|
// cast necessary data arrays from host to device
|
||||||
firstneigh = this->precompute(ago, inum_full, nall, host_x, host_type,
|
|
||||||
host_amtype, host_amgroup, host_rpole,
|
this->cast_extra_data(nullptr, nullptr, nullptr, host_uind, host_uinp, nullptr);
|
||||||
host_uind, host_uinp, host_pval, sublo, subhi, tag,
|
this->atom->add_extra_data();
|
||||||
nspecial, special, nspecial15, special15,
|
|
||||||
eflag_in, vflag_in, eatom, vatom,
|
|
||||||
host_start, ilist, jnum, cpu_time,
|
|
||||||
success, host_q, boxlo, prd);
|
|
||||||
|
|
||||||
// ------------------- Resize _fieldp array ------------------------
|
// ------------------- Resize _fieldp array ------------------------
|
||||||
|
|
||||||
@ -636,7 +599,7 @@ int** HippoT::compute_umutual2b(const int ago, const int inum_full,
|
|||||||
|
|
||||||
this->_fieldp.update_host(this->_max_fieldp_size*8,false);
|
this->_fieldp.update_host(this->_max_fieldp_size*8,false);
|
||||||
|
|
||||||
return firstneigh; //nbor->host_jlist.begin()-host_start;
|
return nullptr; //nbor->host_jlist.begin()-host_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -698,23 +661,12 @@ int** HippoT::compute_polar_real(const int ago, const int inum_full,
|
|||||||
const double aewald, const double felec,
|
const double aewald, const double felec,
|
||||||
const double off2_polar, double *host_q,
|
const double off2_polar, double *host_q,
|
||||||
double *boxlo, double *prd, void **tep_ptr) {
|
double *boxlo, double *prd, void **tep_ptr) {
|
||||||
// reallocate per-atom arrays, transfer data from the host
|
|
||||||
// and build the neighbor lists if needed
|
|
||||||
// NOTE:
|
|
||||||
// For now we invoke precompute() again here,
|
|
||||||
// to be able to turn on/off the udirect2b kernel (which comes before this)
|
|
||||||
// We only need to cast uind and uinp from host to device here
|
|
||||||
// if the neighbor lists are rebuilt and other per-atom arrays
|
|
||||||
// (x, type, amtype, amgroup, rpole) are ready on the device.
|
|
||||||
|
|
||||||
int** firstneigh = nullptr;
|
// cast necessary data arrays from host to device
|
||||||
firstneigh = this->precompute(ago, inum_full, nall, host_x, host_type,
|
|
||||||
host_amtype, host_amgroup, host_rpole,
|
//this->cast_extra_data(host_amtype, host_amgroup, host_rpole, host_uind, host_uinp, host_pval);
|
||||||
host_uind, host_uinp, host_pval, sublo, subhi, tag,
|
this->cast_extra_data(nullptr, nullptr, nullptr, host_uind, host_uinp, nullptr);
|
||||||
nspecial, special, nspecial15, special15,
|
this->atom->add_extra_data();
|
||||||
eflag_in, vflag_in, eatom, vatom,
|
|
||||||
host_start, ilist, jnum, cpu_time,
|
|
||||||
success, host_q, boxlo, prd);
|
|
||||||
|
|
||||||
// ------------------- Resize _tep array ------------------------
|
// ------------------- Resize _tep array ------------------------
|
||||||
|
|
||||||
@ -740,7 +692,7 @@ int** HippoT::compute_polar_real(const int ago, const int inum_full,
|
|||||||
|
|
||||||
this->_tep.update_host(this->_max_tep_size*4,false);
|
this->_tep.update_host(this->_max_tep_size*4,false);
|
||||||
|
|
||||||
return firstneigh; // nbor->host_jlist.begin()-host_start;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user