casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiThreadedVisResampler.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //# MultiThreadedVisResampler.h: Definition of the MultiThreadedVisibilityResampler class
3 //# Copyright (C) 1997,1998,1999,2000,2001,2002,2003
4 //# Associated Universities, Inc. Washington DC, USA.
5 //#
6 //# This library is free software; you can redistribute it and/or modify it
7 //# under the terms of the GNU Library General Public License as published by
8 //# the Free Software Foundation; either version 2 of the License, or (at your
9 //# option) any later version.
10 //#
11 //# This library is distributed in the hope that it will be useful, but WITHOUT
12 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 //# License for more details.
15 //#
16 //# You should have received a copy of the GNU Library General Public License
17 //# along with this library; if not, write to the Free Software Foundation,
18 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 //#
20 //# Correspondence concerning AIPS++ should be addressed as follows:
21 //# Internet email: aips2-request@nrao.edu.
22 //# Postal address: AIPS++ Project Office
23 //# National Radio Astronomy Observatory
24 //# 520 Edgemont Road
25 //# Charlottesville, VA 22903-2475 USA
26 //#
27 //# $Id$
28 
29 #ifndef SYNTHESIS_MULTITHREADEDVISIBILITYRESAMPLER_H
30 #define SYNTHESIS_MULTITHREADEDVISIBILITYRESAMPLER_H
31 
37 #include <msvis/MSVis/UtilJ.h>
38 #include <msvis/MSVis/VisBuffer.h>
39 #include <casa/Arrays/Array.h>
40 #include <casa/Arrays/Vector.h>
41 
42 #include <casa/Logging/LogIO.h>
43 #include <casa/Logging/LogSink.h>
45 #define DEFAULTNOOFCORES -1
46 #define FTMachineNumThreadsEnvVar "ftmachine_num_threads"
47 namespace casa { //# NAMESPACE CASA - BEGIN
49  {
50  public:
51  // enum VBLoader {NOONE=-1, DATATOGRID=0, GRIDTODATA, RESIDUALCALC};
55  whoLoadedVB_p(MThWorkID::NOONE), currentVBS_p(0)
56  {
58  if (nelements_p < 0) nelements_p = 1;
59  // nelements_p=DEFAULTNOOFCORES;
60  };
61 
62  MultiThreadedVisibilityResampler(const casacore::Bool& doublePrecision,
64 
65  MultiThreadedVisibilityResampler(const casacore::Bool& doublePrecision,
69  {
70  cleanup();
71  nelements_p=0;
72  currentVBS_p=0;
73  }
74 
76 
77  // This version will make a clone with shared data buffers (the
78  // complex grids and the sum-of-weights arrays).
80  {
81  //Allocate a new instance, and copy the internals.
83  clonedCopy = new MultiThreadedVisibilityResampler(*this);
84  // Now reset the data buffers with independent buffers (arrays of size 0)
85  clonedCopy->allocateDataBuffers();
86  return clonedCopy;
87  };
88 
90 
91  void cleanup();
92  void releaseBuffers();
93 
94  void copy(const MultiThreadedVisibilityResampler& other);
95 
96  virtual casacore::Int nelements() {return nelements_p;};
97  virtual void setParams(const casacore::Vector<casacore::Double>& uvwScale, const casacore::Vector<casacore::Double>& offset,
99 
100  virtual void setMaps(const casacore::Vector<casacore::Int>& chanMap, const casacore::Vector<casacore::Int>& polMap);
101  virtual void setCFMaps(const casacore::Vector<casacore::Int>& cfMap, const casacore::Vector<casacore::Int>& conjCFMap);
102  virtual void setFreqMaps(const casacore::Matrix<casacore::Double>& spwChanFreqs, const casacore::Matrix<casacore::Double>& spwChanConjFreqs);
103 
104  virtual void setConvFunc(const CFStore& cfs);
105  virtual void setPATolerance(const double& dPA) {paTolerance_p = dPA;}
106  void init(const casacore::Bool& doublePrecision);
107  //
108  //------------------------------------------------------------------------------
109  //
110  // Re-sample the griddedData on the VisBuffer (a.k.a gridding).
111  //
112  // In this class, these just call the private templated version.
113  // The first variant grids onto a double precision grid while the
114  // second one does it on a single precision grid.
115  //
117  VBStore& vbs,
119  const casacore::Bool& dopsf,casacore::Bool /*useConjFreqCF*/=false)
120  {DataToGridImpl_p(griddedData, vbs, sumwt,dopsf);}
121 
122  virtual void DataToGrid(casacore::Array<casacore::Complex>& griddedData,
123  VBStore& vbs,
125  const casacore::Bool& dopsf,casacore::Bool /*useConjFreqCF*/=false)
126  {
127  DataToGridImpl_p(griddedData, vbs, sumwt,dopsf);
128  }
129 
130  //
131  // This is the gather operation on griddedData for nelements > 1
132  //
139  void initializeDataBuffers(VBStore& /*vbs*/) {};
140 
141  //
142  //------------------------------------------------------------------------------
143  //
144  // Re-sample VisBuffer to a regular grid (griddedData) (a.k.a. de-gridding)
145  //
146  virtual void GridToData(VBStore& vbs, const casacore::Array<casacore::Complex>& griddedData);
147  // virtual void GridToData(VBStore& vbs, casacore::Array<casacore::Complex>& griddedData);
148 
149  virtual void ComputeResiduals(VBStore& vbs);
150  //
151  //------------------------------------------------------------------------------
152  //----------------------------Private parts-------------------------------------
153  //------------------------------------------------------------------------------
154  //
155  private:
156  template <class T>
157  void DataToGridImpl_p(casacore::Array<T>& griddedData, VBStore& vb,
158  casacore::Matrix<casacore::Double>& sumwt,const casacore::Bool& dopsf,casacore::Bool useConjFreqCF=false);
159  // template <class T>
160  // void GatherGrids_p(const casacore::Array<T>& griddedData,
161  // const casacore::Matrix<casacore::Double>& sumwt);
162 
163  // template <class T>
164  // void initializeBuffers(const casacore::Array<T>& griddedData,
165  // const casacore::Matrix<casacore::Double>& sumwt);
166 
167  void allocateBuffers(casacore::Bool newDataBuffers=true);
170  void startThreads();
171  void scatter(casacore::Matrix<VBStore>& vbsStores,const VBStore& vbs);
172 
180  // casacore::Vector<VBStore> vbsVec_p;
182 
188  // async::Mutex *mutexForResamplers_p;
192  };
193 }; //# NAMESPACE CASA - END
194 
195 #endif //
virtual void setCFMaps(const casacore::Vector< casacore::Int > &cfMap, const casacore::Vector< casacore::Int > &conjCFMap)
int Int
Definition: aipstype.h:50
casacore::Vector< casacore::CountedPtr< casacore::Array< casacore::Complex > > > singleGriddedData_p
virtual void setConvFunc(const CFStore &cfs)
void GatherGrids(casacore::Array< casacore::DComplex > &griddedData, casacore::Matrix< casacore::Double > &sumwt)
This is the gather operation on griddedData for nelements &gt; 1.
void initializePutBuffers(const casacore::Array< casacore::DComplex > &griddedData, const casacore::Matrix< casacore::Double > &sumwt)
void init(const casacore::Bool &doublePrecision)
Forward looking genealogical baggage – required for the MultiThreadedVisibilityResampler.
MultiThreadedVisibilityResampler(const MultiThreadedVisibilityResampler &other)
#define DEFAULTNOOFCORES
-*- C++ -*-
casacore::Matrix< VBStore > vbsVec_p
casacore::Vector&lt;VBStore&gt; vbsVec_p;
virtual void DataToGrid(casacore::Array< casacore::DComplex > &griddedData, VBStore &vbs, casacore::Matrix< casacore::Double > &sumwt, const casacore::Bool &dopsf, casacore::Bool=false)
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
void DataToGridImpl_p(casacore::Array< T > &griddedData, VBStore &vb, casacore::Matrix< casacore::Double > &sumwt, const casacore::Bool &dopsf, casacore::Bool useConjFreqCF=false)
-------------------------—Private parts----------------------------------—
double Double
Definition: aipstype.h:55
virtual void setPATolerance(const double &dPA)
MultiThreadedVisibilityResampler * clone()
This version will make a clone with shared data buffers (the complex grids and the sum-of-weights arr...
void allocateBuffers(casacore::Bool newDataBuffers=true)
template &lt;class t&gt;=&quot;&quot;&gt; void GatherGrids_p(const casacore::Array&lt;T&gt;&amp; griddedData, const casacore::Matr...
virtual void setParams(const casacore::Vector< casacore::Double > &uvwScale, const casacore::Vector< casacore::Double > &offset, const casacore::Vector< casacore::Double > &dphase)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void GridToData(VBStore &vbs, const casacore::Array< casacore::Complex > &griddedData)
casacore::Vector< casacore::CountedPtr< casacore::Array< casacore::DComplex > > > doubleGriddedData_p
virtual void DataToGrid(casacore::Array< casacore::Complex > &griddedData, VBStore &vbs, casacore::Matrix< casacore::Double > &sumwt, const casacore::Bool &dopsf, casacore::Bool=false)
virtual void setMaps(const casacore::Vector< casacore::Int > &chanMap, const casacore::Vector< casacore::Int > &polMap)
MultiThreadedVisibilityResampler & operator=(const MultiThreadedVisibilityResampler &other)
casacore::Vector< casacore::CountedPtr< ResamplerWorklet > > gridderWorklets_p
virtual void setFreqMaps(const casacore::Matrix< casacore::Double > &spwChanFreqs, const casacore::Matrix< casacore::Double > &spwChanConjFreqs)
casacore::Vector< casacore::CountedPtr< casacore::Matrix< casacore::Double > > > sumwt_p
casacore::Vector< casacore::CountedPtr< VisibilityResamplerBase > > resamplers_p
virtual void ComputeResiduals(VBStore &vbs)
virtual void GridToData(VBStore&amp; vbs, casacore::Array&lt;casacore::Complex&gt;&amp; griddedData); ...
casacore::CountedPtr< VisibilityResamplerBase > visResamplerCtor_p
async::Mutex *mutexForResamplers_p;
#define FTMachineNumThreadsEnvVar
MultiThreadedVisibilityResampler()
enum VBLoader {NOONE=-1, DATATOGRID=0, GRIDTODATA, RESIDUALCALC};
casacore::CountedPtr< ThreadCoordinator< casacore::Int > > threadClerk_p
void scatter(casacore::Matrix< VBStore > &vbsStores, const VBStore &vbs)
void copy(const MultiThreadedVisibilityResampler &other)
T getenv(const char *name, const T defaultVal)