From e9bcde4b587fb59d4a7f29bbce4dfa1d7071eebe Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 6 Mar 2022 04:48:37 -0500 Subject: [PATCH] more openmp neighbor list function to Neighbor class --- src/OPENMP/fix_omp.cpp | 23 +---------------------- src/OPENMP/fix_omp.h | 2 -- src/neighbor.cpp | 11 +++++++++++ src/neighbor.h | 5 ++++- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/OPENMP/fix_omp.cpp b/src/OPENMP/fix_omp.cpp index ec5b1d5be0..6be7f7c1fc 100644 --- a/src/OPENMP/fix_omp.cpp +++ b/src/OPENMP/fix_omp.cpp @@ -277,7 +277,7 @@ void FixOMP::init() #undef CheckStyleForOMP #undef CheckHybridForOMP - set_neighbor_omp(); + neighbor->set_omp_neighbor(_neighbor ? 1 : 0); // diagnostic output if (comm->me == 0) { @@ -293,27 +293,6 @@ void FixOMP::init() /* ---------------------------------------------------------------------- */ -void FixOMP::set_neighbor_omp() -{ - // select or deselect multi-threaded neighbor - // list build depending on setting in package omp. - // NOTE: since we are at the top of the list of - // fixes, we cannot adjust neighbor lists from - // other fixes. those have to be re-implemented - // as /omp fix styles. :-( - - const int neigh_omp = _neighbor ? 1 : 0; - const int nrequest = neighbor->nrequest; - - // flag *all* neighbor list requests as OPENMP threaded, - // but skip lists already flagged as INTEL threaded - for (int i = 0; i < nrequest; ++i) - if (! neighbor->requests[i]->intel) - neighbor->requests[i]->omp = neigh_omp; -} - -/* ---------------------------------------------------------------------- */ - void FixOMP::setup(int) { // we are post the force compute in setup. turn on timers diff --git a/src/OPENMP/fix_omp.h b/src/OPENMP/fix_omp.h index af57abc85c..b6e0e516f4 100644 --- a/src/OPENMP/fix_omp.h +++ b/src/OPENMP/fix_omp.h @@ -71,8 +71,6 @@ class FixOMP : public Fix { bool _reduced; // whether forces have been reduced for this step bool _pair_compute_flag; // whether pair_compute is called bool _kspace_compute_flag; // whether kspace_compute is called - - void set_neighbor_omp(); }; } // namespace LAMMPS_NS diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 68e8112745..2f1310b29d 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -2111,7 +2111,18 @@ NeighRequest *Neighbor::add_request(Command *requestor, const char *style, int f return req; } +// set neighbor list request OpenMP flag + +void Neighbor::set_omp_neighbor(int flag) +{ + // flag *all* neighbor list requests as OPENMP threaded, + // but skip lists already flagged as INTEL threaded + for (int i = 0; i < nrequest; ++i) + if (!requests[i]->intel) requests[i]->omp = flag; +} + /* report if there is a neighbor list with the intel flag set */ + bool Neighbor::has_intel_request() const { return (((nrequest > 0) && (requests[0]->intel > 0)) diff --git a/src/neighbor.h b/src/neighbor.h index b98e48dd66..d116b479ba 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -133,6 +133,9 @@ class Neighbor : protected Pointers { NeighRequest *add_request(class Compute *, int); NeighRequest *add_request(class Command *, const char *, int); + // set neighbor list request OpenMP flag + void set_omp_neighbor(int); + // report if we have INTEL package neighbor lists bool has_intel_request() const; @@ -141,8 +144,8 @@ class Neighbor : protected Pointers { void setup_bins(); // setup bins based on box and cutoff virtual void build(int); // build all perpetual neighbor lists virtual void build_topology(); // pairwise topology neighbor lists - void build_one(class NeighList *list, int preflag = 0); // create a one-time pairwise neigh list + void build_one(class NeighList *list, int preflag = 0); void set(int, char **); // set neighbor style and skin distance void reset_timestep(bigint); // reset of timestep counter void modify_params(int, char **); // modify params that control builds