HOPS
HOPS class reference
MHO_MBDelaySearchOpenMP.hh
Go to the documentation of this file.
1 #ifndef MHO_MBDelaySearchOpenMP_HH__
2 #define MHO_MBDelaySearchOpenMP_HH__
3 
4 #include <vector>
5 
6 #ifdef _OPENMP
7  #include <omp.h>
8 #else
9 //stubs so code compiles without OpenMP; pragmas are silently ignored
10 inline int omp_get_max_threads()
11 {
12  return 1;
13 }
14 
15 inline int omp_get_thread_num()
16 {
17  return 0;
18 }
19 #endif
20 
21 #include "MHO_MBDelaySearch.hh"
22 
23 namespace hops
24 {
25 
38 {
39  public:
41  virtual ~MHO_MBDelaySearchOpenMP();
42 
43  //only available for this class
44  void SetNThreadsOpenMP(int n_threads)
45  {
46  int max_threads = omp_get_max_threads();
47  if(n_threads <= 0)
48  {
49  //default value of -1 triggers max threads
50  fNThreads = max_threads;
51  }
52  else
53  {
54  fNThreads = std::min(max_threads, n_threads);
55  }
56  };
57 
58  protected:
60 
61  virtual bool InitializeImpl(const XArgType* in) override;
62  virtual bool ExecuteImpl(const XArgType* in) override;
63 
64  //per-thread argmax accumulator; alignas(64) + _pad prevents false sharing across cache lines
65  struct alignas(64) LocalMax
66  {
67  double val = -0.0;
68  int mbd_bin = -1;
69  int sbd_bin = -1;
70  int dr_bin = -1;
71  double n_points = 0.0;
72  char _pad[32]; //pad struct to one full 64-byte cache line
73  };
74 
75  int fNThreads;
76  std::vector< LocalMax > fThreadMaxima;
77  std::vector< visibility_type > fPerThreadSBDWorkspace;
78  std::vector< visibility_type > fPerThreadSBDDrData;
79  std::vector< MHO_DelayRate > fPerThreadDelayRateCalc;
80  std::vector< mbd_dr_type > fPerThreadSearchBuffer;
81  std::vector< FFT_2D_ENGINE_TYPE > fPerThreadBatchedFFTEngine;
82  std::vector< std::vector< double > > fPerThreadSmoothScratch; //per-thread scratch for apply_dr_boxcar_smooth
83 };
84 
85 } // namespace hops
86 
87 #endif
int omp_get_max_threads()
Definition: MHO_MBDelaySearchOpenMP.hh:10
int omp_get_thread_num()
Definition: MHO_MBDelaySearchOpenMP.hh:15
Class MHO_MBDelaySearchOpenMP.
Definition: MHO_MBDelaySearchOpenMP.hh:38
char _pad[32]
Definition: MHO_MBDelaySearchOpenMP.hh:72
std::vector< mbd_dr_type > fPerThreadSearchBuffer
Definition: MHO_MBDelaySearchOpenMP.hh:80
virtual bool ExecuteImpl(const XArgType *in) override
Inspects a single const array.
Definition: MHO_MBDelaySearchOpenMP.cc:167
std::vector< visibility_type > fPerThreadSBDDrData
Definition: MHO_MBDelaySearchOpenMP.hh:78
std::vector< std::vector< double > > fPerThreadSmoothScratch
Definition: MHO_MBDelaySearchOpenMP.hh:82
std::vector< LocalMax > fThreadMaxima
Definition: MHO_MBDelaySearchOpenMP.hh:76
void SetNThreadsOpenMP(int n_threads)
Definition: MHO_MBDelaySearchOpenMP.hh:44
int sbd_bin
Definition: MHO_MBDelaySearchOpenMP.hh:69
double n_points
Definition: MHO_MBDelaySearchOpenMP.hh:71
int mbd_bin
Definition: MHO_MBDelaySearchOpenMP.hh:68
std::vector< visibility_type > fPerThreadSBDWorkspace
Definition: MHO_MBDelaySearchOpenMP.hh:77
std::vector< MHO_DelayRate > fPerThreadDelayRateCalc
Definition: MHO_MBDelaySearchOpenMP.hh:79
int dr_bin
Definition: MHO_MBDelaySearchOpenMP.hh:70
double val
Definition: MHO_MBDelaySearchOpenMP.hh:67
std::vector< FFT_2D_ENGINE_TYPE > fPerThreadBatchedFFTEngine
Definition: MHO_MBDelaySearchOpenMP.hh:81
MHO_MBDelaySearchOpenMP()
Definition: MHO_MBDelaySearchOpenMP.cc:6
virtual ~MHO_MBDelaySearchOpenMP()
Definition: MHO_MBDelaySearchOpenMP.cc:12
int fNThreads
Definition: MHO_MBDelaySearchOpenMP.hh:75
virtual bool InitializeImpl(const XArgType *in) override
initializes inspection for a single const array of type XArgType.
Definition: MHO_MBDelaySearchOpenMP.cc:14
Definition: MHO_MBDelaySearchOpenMP.hh:66
Class MHO_MBDelaySearch.
Definition: MHO_MBDelaySearch.hh:41
#define min(a, b)
Definition: max555.c:9
Definition: MHO_AdhocFlagging.hh:18
MHO_TableContainer< visibility_element_type, baseline_axis_pack > visibility_type
Definition: MHO_BaselineContainers.hh:52