convert all b*/omp pair styles

This commit is contained in:
Axel Kohlmeyer
2011-10-14 00:50:54 -04:00
parent 5344894bec
commit 8416aba5cf
4 changed files with 65 additions and 81 deletions

View File

@ -36,7 +36,6 @@ void PairBuckCoulCutOMP::compute(int eflag, int vflag)
{
if (eflag || vflag) {
ev_setup(eflag,vflag);
ev_setup_thr(this);
} else evflag = vflag_fdotr = 0;
const int nall = atom->nlocal + atom->nghost;
@ -44,40 +43,35 @@ void PairBuckCoulCutOMP::compute(int eflag, int vflag)
const int inum = list->inum;
#if defined(_OPENMP)
#pragma omp parallel default(shared)
#pragma omp parallel default(none) shared(eflag,vflag)
#endif
{
int ifrom, ito, tid;
double **f;
f = loop_setup_thr(atom->f, ifrom, ito, tid, inum, nall, nthreads);
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
ThrData *thr = fix->get_thr(tid);
ev_setup_thr(eflag, vflag, nall, eatom, vatom, thr);
if (evflag) {
if (eflag) {
if (force->newton_pair) eval<1,1,1>(f, ifrom, ito, tid);
else eval<1,1,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<1,1,1>(ifrom, ito, thr);
else eval<1,1,0>(ifrom, ito, thr);
} else {
if (force->newton_pair) eval<1,0,1>(f, ifrom, ito, tid);
else eval<1,0,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<1,0,1>(ifrom, ito, thr);
else eval<1,0,0>(ifrom, ito, thr);
}
} else {
if (force->newton_pair) eval<0,0,1>(f, ifrom, ito, tid);
else eval<0,0,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<0,0,1>(ifrom, ito, thr);
else eval<0,0,0>(ifrom, ito, thr);
}
// reduce per thread forces into global force array.
data_reduce_thr(&(atom->f[0][0]), nall, nthreads, 3, tid);
reduce_thr(eflag, vflag, thr);
} // end of omp parallel region
// reduce per thread energy and virial, if requested.
if (evflag) ev_reduce_thr(this);
if (vflag_fdotr) virial_fdotr_compute();
}
/* ---------------------------------------------------------------------- */
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
void PairBuckCoulCutOMP::eval(double **f, int iifrom, int iito, int tid)
void PairBuckCoulCutOMP::eval(int iifrom, int iito, ThrData * const thr)
{
int i,j,ii,jj,jnum,itype,jtype;
double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair;
@ -86,8 +80,9 @@ void PairBuckCoulCutOMP::eval(double **f, int iifrom, int iito, int tid)
evdwl = ecoul = 0.0;
double **x = atom->x;
double *q = atom->q;
const double * const * const x = atom->x;
double * const * const f = thr->get_f();
const double * const q = atom->q;
int *type = atom->type;
int nlocal = atom->nlocal;
double *special_coul = force->special_coul;
@ -162,7 +157,7 @@ void PairBuckCoulCutOMP::eval(double **f, int iifrom, int iito, int tid)
} else evdwl = 0.0;
if (EVFLAG) ev_tally_thr(this, i,j,nlocal,NEWTON_PAIR,
evdwl,ecoul,fpair,delx,dely,delz,tid);
evdwl,ecoul,fpair,delx,dely,delz,thr);
}
}
f[i][0] += fxtmp;

View File

@ -44,7 +44,6 @@ void PairBuckCoulLongOMP::compute(int eflag, int vflag)
{
if (eflag || vflag) {
ev_setup(eflag,vflag);
ev_setup_thr(this);
} else evflag = vflag_fdotr = 0;
const int nall = atom->nlocal + atom->nghost;
@ -52,40 +51,37 @@ void PairBuckCoulLongOMP::compute(int eflag, int vflag)
const int inum = list->inum;
#if defined(_OPENMP)
#pragma omp parallel default(shared)
#pragma omp parallel default(none) shared(eflag,vflag)
#endif
{
int ifrom, ito, tid;
double **f;
f = loop_setup_thr(atom->f, ifrom, ito, tid, inum, nall, nthreads);
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
ThrData *thr = fix->get_thr(tid);
ev_setup_thr(eflag, vflag, nall, eatom, vatom, thr);
if (evflag) {
if (eflag) {
if (force->newton_pair) eval<1,1,1>(f, ifrom, ito, tid);
else eval<1,1,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<1,1,1>(ifrom, ito, thr);
else eval<1,1,0>(ifrom, ito, thr);
} else {
if (force->newton_pair) eval<1,0,1>(f, ifrom, ito, tid);
else eval<1,0,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<1,0,1>(ifrom, ito, thr);
else eval<1,0,0>(ifrom, ito, thr);
}
} else {
if (force->newton_pair) eval<0,0,1>(f, ifrom, ito, tid);
else eval<0,0,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<0,0,1>(ifrom, ito, thr);
else eval<0,0,0>(ifrom, ito, thr);
}
// reduce per thread forces into global force array.
data_reduce_thr(&(atom->f[0][0]), nall, nthreads, 3, tid);
reduce_thr(eflag, vflag, thr);
} // end of omp parallel region
// reduce per thread energy and virial, if requested.
if (evflag) ev_reduce_thr(this);
if (vflag_fdotr) virial_fdotr_compute();
}
/* ---------------------------------------------------------------------- */
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
void PairBuckCoulLongOMP::eval(double **f, int iifrom, int iito, int tid)
void PairBuckCoulLongOMP::eval(int iifrom, int iito, ThrData * const thr)
{
int i,j,ii,jj,jnum,itype,jtype;
double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair;
@ -95,8 +91,9 @@ void PairBuckCoulLongOMP::eval(double **f, int iifrom, int iito, int tid)
evdwl = ecoul = 0.0;
double **x = atom->x;
double *q = atom->q;
const double * const * const x = atom->x;
double * const * const f = thr->get_f();
const double * const q = atom->q;
int *type = atom->type;
int nlocal = atom->nlocal;
double *special_coul = force->special_coul;
@ -178,7 +175,7 @@ void PairBuckCoulLongOMP::eval(double **f, int iifrom, int iito, int tid)
} else evdwl = 0.0;
if (EVFLAG) ev_tally_thr(this, i,j,nlocal,NEWTON_PAIR,
evdwl,ecoul,fpair,delx,dely,delz,tid);
evdwl,ecoul,fpair,delx,dely,delz,thr);
}
}
f[i][0] += fxtmp;

View File

@ -45,7 +45,6 @@ void PairBuckCoulOMP::compute(int eflag, int vflag)
{
if (eflag || vflag) {
ev_setup(eflag,vflag);
ev_setup_thr(this);
} else evflag = vflag_fdotr = 0;
const int nall = atom->nlocal + atom->nghost;
@ -53,53 +52,50 @@ void PairBuckCoulOMP::compute(int eflag, int vflag)
const int inum = list->inum;
#if defined(_OPENMP)
#pragma omp parallel default(shared)
#pragma omp parallel default(none) shared(eflag,vflag)
#endif
{
int ifrom, ito, tid;
double **f;
f = loop_setup_thr(atom->f, ifrom, ito, tid, inum, nall, nthreads);
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
ThrData *thr = fix->get_thr(tid);
ev_setup_thr(eflag, vflag, nall, eatom, vatom, thr);
if (evflag) {
if (eflag) {
if (force->newton_pair) eval<1,1,1>(f, ifrom, ito, tid);
else eval<1,1,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<1,1,1>(ifrom, ito, thr);
else eval<1,1,0>(ifrom, ito, thr);
} else {
if (force->newton_pair) eval<1,0,1>(f, ifrom, ito, tid);
else eval<1,0,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<1,0,1>(ifrom, ito, thr);
else eval<1,0,0>(ifrom, ito, thr);
}
} else {
if (force->newton_pair) eval<0,0,1>(f, ifrom, ito, tid);
else eval<0,0,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<0,0,1>(ifrom, ito, thr);
else eval<0,0,0>(ifrom, ito, thr);
}
// reduce per thread forces into global force array.
data_reduce_thr(&(atom->f[0][0]), nall, nthreads, 3, tid);
reduce_thr(eflag, vflag, thr);
} // end of omp parallel region
// reduce per thread energy and virial, if requested.
if (evflag) ev_reduce_thr(this);
if (vflag_fdotr) virial_fdotr_compute();
}
/* ---------------------------------------------------------------------- */
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
void PairBuckCoulOMP::eval(double **f, int iifrom, int iito, int tid)
void PairBuckCoulOMP::eval(int iifrom, int iito, ThrData * const thr)
{
double evdwl,ecoul,fpair;
evdwl = ecoul = 0.0;
double **x = atom->x;
double *q = atom->q;
const double * const * const x = atom->x;
double * const * const f = thr->get_f();
const double * const q = atom->q;
int *type = atom->type;
int nlocal = atom->nlocal;
double *special_coul = force->special_coul;
double *special_lj = force->special_lj;
double qqrd2e = force->qqrd2e;
double *x0 = x[0];
const double *x0 = x[0];
double *f0 = f[0], *fi = f0;
int *ilist = list->ilist;
@ -129,7 +125,7 @@ void PairBuckCoulOMP::eval(double **f, int iifrom, int iito, int tid)
ni = sbmask(j);
j &= NEIGHMASK;
{ register double *xj = x0+(j+(j<<1));
{ const register double *xj = x0+(j+(j<<1));
d[0] = xi[0] - xj[0]; // pair vector
d[1] = xi[1] - xj[1];
d[2] = xi[2] - xj[2]; }
@ -214,7 +210,7 @@ void PairBuckCoulOMP::eval(double **f, int iifrom, int iito, int tid)
}
if (EVFLAG) ev_tally_thr(this,i,j,nlocal,NEWTON_PAIR,
evdwl,ecoul,fpair,d[0],d[1],d[2],tid);
evdwl,ecoul,fpair,d[0],d[1],d[2],thr);
}
}
}

View File

@ -36,7 +36,6 @@ void PairBuckOMP::compute(int eflag, int vflag)
{
if (eflag || vflag) {
ev_setup(eflag,vflag);
ev_setup_thr(this);
} else evflag = vflag_fdotr = 0;
const int nall = atom->nlocal + atom->nghost;
@ -44,38 +43,34 @@ void PairBuckOMP::compute(int eflag, int vflag)
const int inum = list->inum;
#if defined(_OPENMP)
#pragma omp parallel default(shared)
#pragma omp parallel default(none) shared(eflag,vflag)
#endif
{
int ifrom, ito, tid;
double **f;
f = loop_setup_thr(atom->f, ifrom, ito, tid, inum, nall, nthreads);
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
ThrData *thr = fix->get_thr(tid);
ev_setup_thr(eflag, vflag, nall, eatom, vatom, thr);
if (evflag) {
if (eflag) {
if (force->newton_pair) eval<1,1,1>(f, ifrom, ito, tid);
else eval<1,1,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<1,1,1>(ifrom, ito, thr);
else eval<1,1,0>(ifrom, ito, thr);
} else {
if (force->newton_pair) eval<1,0,1>(f, ifrom, ito, tid);
else eval<1,0,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<1,0,1>(ifrom, ito, thr);
else eval<1,0,0>(ifrom, ito, thr);
}
} else {
if (force->newton_pair) eval<0,0,1>(f, ifrom, ito, tid);
else eval<0,0,0>(f, ifrom, ito, tid);
if (force->newton_pair) eval<0,0,1>(ifrom, ito, thr);
else eval<0,0,0>(ifrom, ito, thr);
}
// reduce per thread forces into global force array.
data_reduce_thr(&(atom->f[0][0]), nall, nthreads, 3, tid);
reduce_thr(eflag, vflag, thr);
} // end of omp parallel region
// reduce per thread energy and virial, if requested.
if (evflag) ev_reduce_thr(this);
if (vflag_fdotr) virial_fdotr_compute();
}
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
void PairBuckOMP::eval(double **f, int iifrom, int iito, int tid)
void PairBuckOMP::eval(int iifrom, int iito, ThrData * const thr)
{
int i,j,ii,jj,jnum,itype,jtype;
double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair;
@ -84,7 +79,8 @@ void PairBuckOMP::eval(double **f, int iifrom, int iito, int tid)
evdwl = 0.0;
double **x = atom->x;
const double * const * const x = atom->x;
double * const * const f = thr->get_f();
int *type = atom->type;
int nlocal = atom->nlocal;
double *special_lj = force->special_lj;
@ -145,7 +141,7 @@ void PairBuckOMP::eval(double **f, int iifrom, int iito, int tid)
}
if (EVFLAG) ev_tally_thr(this, i,j,nlocal,NEWTON_PAIR,
evdwl,0.0,fpair,delx,dely,delz,tid);
evdwl,0.0,fpair,delx,dely,delz,thr);
}
}
f[i][0] += fxtmp;