1 /* -*- c++ -*- ----------------------------------------------------------
2    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
3    https://www.lammps.org/, Sandia National Laboratories
4    Steve Plimpton, sjplimp@sandia.gov
5 
6    Copyright (2003) Sandia Corporation.  Under the terms of Contract
7    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
8    certain rights in this software.  This software is distributed under
9    the GNU General Public License.
10 
11    See the README file in the top-level LAMMPS directory.
12 ------------------------------------------------------------------------- */
13 
14 #ifdef FIX_CLASS
15 // clang-format off
16 FixStyle(OMP,FixOMP);
17 // clang-format on
18 #else
19 
20 #ifndef LMP_FIX_OMP_H
21 #define LMP_FIX_OMP_H
22 
23 #include "fix.h"
24 
25 namespace LAMMPS_NS {
26 
27 class ThrData;
28 
29 class FixOMP : public Fix {
30   friend class ThrOMP;
31   friend class RespaOMP;
32 
33  public:
34   FixOMP(class LAMMPS *, int, char **);
35   virtual ~FixOMP();
36   virtual int setmask();
37   virtual void init();
38   virtual void setup(int);
min_setup(int flag)39   virtual void min_setup(int flag) { setup(flag); }
40   virtual void pre_force(int);
41 
setup_pre_force(int vflag)42   virtual void setup_pre_force(int vflag) { pre_force(vflag); }
min_setup_pre_force(int vflag)43   virtual void min_setup_pre_force(int vflag) { pre_force(vflag); }
min_pre_force(int vflag)44   virtual void min_pre_force(int vflag) { pre_force(vflag); }
setup_pre_force_respa(int vflag,int)45   virtual void setup_pre_force_respa(int vflag, int) { pre_force(vflag); }
pre_force_respa(int vflag,int,int)46   virtual void pre_force_respa(int vflag, int, int) { pre_force(vflag); }
47 
48   virtual double memory_usage();
49 
50  protected:
51   ThrData **thr;
52   void *last_omp_style;      // pointer to the style that needs
53                              // to do the general force reduction
54   void *last_pair_hybrid;    // pointer to the pair style that needs
55                              // to call virial_fdot_compute()
56   // signal that an /omp style did the force reduction. needed by respa/omp
did_reduce()57   void did_reduce() { _reduced = true; }
58 
59  public:
get_thr(int tid)60   ThrData *get_thr(int tid) { return thr[tid]; }
get_nthr()61   int get_nthr() const { return _nthr; }
62 
get_neighbor()63   bool get_neighbor() const { return _neighbor; }
get_mixed()64   bool get_mixed() const { return _mixed; }
get_reduced()65   bool get_reduced() const { return _reduced; }
66 
67  private:
68   int _nthr;                    // number of currently active ThrData objects
69   bool _neighbor;               // en/disable threads for neighbor list construction
70   bool _mixed;                  // whether to prefer mixed precision compute kernels
71   bool _reduced;                // whether forces have been reduced for this step
72   bool _pair_compute_flag;      // whether pair_compute is called
73   bool _kspace_compute_flag;    // whether kspace_compute is called
74 
75   void set_neighbor_omp();
76 };
77 
78 }    // namespace LAMMPS_NS
79 
80 #endif
81 #endif
82