add allocation and reduction for per-atom stress with OpenMP
This commit is contained in:
@ -58,6 +58,7 @@
|
|||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "omp_compat.h"
|
||||||
#include "suffix.h"
|
#include "suffix.h"
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace ReaxFF;
|
using namespace ReaxFF;
|
||||||
@ -236,7 +237,21 @@ void PairReaxFFOMP::compute(int eflag, int vflag)
|
|||||||
api->system->n = atom->nlocal; // my atoms
|
api->system->n = atom->nlocal; // my atoms
|
||||||
api->system->N = atom->nlocal + atom->nghost; // mine + ghosts
|
api->system->N = atom->nlocal + atom->nghost; // mine + ghosts
|
||||||
api->system->bigN = static_cast<int> (atom->natoms); // all atoms in the system
|
api->system->bigN = static_cast<int> (atom->natoms); // all atoms in the system
|
||||||
|
const int nall = api->system->N;
|
||||||
|
|
||||||
|
#if defined(_OPENMP)
|
||||||
|
#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(eflag,vflag)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if defined(_OPENMP)
|
||||||
|
int tid = omp_get_thread_num();
|
||||||
|
#else
|
||||||
|
int tid = 0;
|
||||||
|
#endif
|
||||||
|
ThrData *thr = fix->get_thr(tid);
|
||||||
|
thr->timer(Timer::START);
|
||||||
|
ev_setup_thr(eflag, vflag, api->system->N, eatom, vatom, nullptr, thr);
|
||||||
|
}
|
||||||
// setup data structures
|
// setup data structures
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
@ -253,6 +268,27 @@ void PairReaxFFOMP::compute(int eflag, int vflag)
|
|||||||
Compute_ForcesOMP(api->system,api->control,api->data,api->workspace,&api->lists);
|
Compute_ForcesOMP(api->system,api->control,api->data,api->workspace,&api->lists);
|
||||||
read_reax_forces(vflag);
|
read_reax_forces(vflag);
|
||||||
|
|
||||||
|
const int nthreads = comm->nthreads;
|
||||||
|
#if defined(_OPENMP)
|
||||||
|
#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(vflag)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if defined(_OPENMP)
|
||||||
|
int tid = omp_get_thread_num();
|
||||||
|
#else
|
||||||
|
int tid = 0;
|
||||||
|
#endif
|
||||||
|
ThrData *thr = fix->get_thr(tid);
|
||||||
|
thr->timer(Timer::PAIR);
|
||||||
|
|
||||||
|
// the pair style reduces energy and forces directly. so only reduce virial/
|
||||||
|
// per-atom virial and per-atom centroid virial are the same for two-body
|
||||||
|
// many-body pair styles not yet implemented
|
||||||
|
if (vflag & (VIRIAL_ATOM | VIRIAL_CENTROID)) {
|
||||||
|
data_reduce_thr(&(vatom[0][0]), nall , nthreads, 6, tid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(_OPENMP)
|
#if defined(_OPENMP)
|
||||||
#pragma omp parallel for schedule(static)
|
#pragma omp parallel for schedule(static)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user