ensure that local per-thread storage is completely cleared in hybrid styles.

This commit is contained in:
Axel Kohlmeyer 2020-06-24 17:24:47 -04:00
parent 3e39b8c62d
commit 5a2704efc2
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
2 changed files with 24 additions and 0 deletions

View File

@ -108,6 +108,18 @@ void AngleHybrid::compute(int eflag, int vflag)
ev_init(eflag,vflag); ev_init(eflag,vflag);
// need to clear per-thread storage here, when using multiple threads
// with thread-enabled substyles to avoid uninitlialized data access.
const int nthreads = comm->nthreads;
if (comm->nthreads > 1) {
const int nall = atom->nlocal + atom->nghost;
if (eflag_atom)
memset(&eatom[0],0,nall*nthreads*sizeof(double));
if (vflag_atom)
memset(&vatom[0][0],0,6*nall*nthreads*sizeof(double));
}
for (m = 0; m < nstyles; m++) { for (m = 0; m < nstyles; m++) {
neighbor->nanglelist = nanglelist[m]; neighbor->nanglelist = nanglelist[m];
neighbor->anglelist = anglelist[m]; neighbor->anglelist = anglelist[m];

View File

@ -108,6 +108,18 @@ void BondHybrid::compute(int eflag, int vflag)
ev_init(eflag,vflag); ev_init(eflag,vflag);
// need to clear per-thread storage once here, when using multiple threads
// with thread-enabled substyles to avoid uninitlialized data access.
const int nthreads = comm->nthreads;
if (nthreads > 1) {
const int nall = atom->nlocal + atom->nghost;
if (eflag_atom)
memset(&eatom[0],0,nall*nthreads*sizeof(double));
if (vflag_atom)
memset(&vatom[0][0],0,6*nall*nthreads*sizeof(double));
}
for (m = 0; m < nstyles; m++) { for (m = 0; m < nstyles; m++) {
neighbor->nbondlist = nbondlist[m]; neighbor->nbondlist = nbondlist[m];
neighbor->bondlist = bondlist[m]; neighbor->bondlist = bondlist[m];