LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - MultiThreadedVisResampler.h (source / functions) Hit Total Coverage
Test: casa_coverage.info Lines: 0 19 0.0 %
Date: 2023-10-25 08:47:59 Functions: 0 9 0.0 %

          Line data    Source code
       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             : 
      32             : #include <synthesis/TransformMachines/VisibilityResamplerBase.h>
      33             : #include <synthesis/MeasurementComponents/ResamplerWorklet.h>
      34             : #include <synthesis/TransformMachines/CFStore.h>
      35             : #include <synthesis/TransformMachines/VBStore.h>
      36             : #include <synthesis/MeasurementComponents/MThWorkIDEnum.h>
      37             : #include <stdcasa/UtilJ.h>
      38             : #include <msvis/MSVis/VisBuffer.h>
      39             : #include <casacore/casa/Arrays/Array.h>
      40             : #include <casacore/casa/Arrays/Vector.h>
      41             : 
      42             : #include <casacore/casa/Logging/LogIO.h>
      43             : #include <casacore/casa/Logging/LogSink.h>
      44             : #include <casacore/casa/Logging/LogMessage.h>
      45             : #define DEFAULTNOOFCORES -1
      46             : #define FTMachineNumThreadsEnvVar "ftmachine_num_threads"
      47             : namespace casa { //# NAMESPACE CASA - BEGIN
      48             :   class MultiThreadedVisibilityResampler: public VisibilityResamplerBase
      49             :   {
      50             :   public: 
      51             :     //    enum VBLoader {NOONE=-1, DATATOGRID=0, GRIDTODATA, RESIDUALCALC};
      52             :      MultiThreadedVisibilityResampler():
      53             :       resamplers_p(), doubleGriddedData_p(), singleGriddedData_p(), 
      54             :       sumwt_p(), gridderWorklets_p(), vbsVec_p(), visResamplerCtor_p(), 
      55             :       whoLoadedVB_p(MThWorkID::NOONE), currentVBS_p(0)
      56             :     {
      57             :       nelements_p = SynthesisUtils::getenv(FTMachineNumThreadsEnvVar, 1);
      58             :       if (nelements_p < 0) nelements_p = 1;
      59             :       //      nelements_p=DEFAULTNOOFCORES;
      60             :     };
      61             : 
      62             :     MultiThreadedVisibilityResampler(const casacore::Bool& doublePrecision, 
      63             :                                      const casacore::Int& n=DEFAULTNOOFCORES);
      64             : 
      65             :     MultiThreadedVisibilityResampler(const casacore::Bool& doublePrecision, 
      66             :                                      casacore::CountedPtr<VisibilityResamplerBase>& visResampler, 
      67             :                                      const casacore::Int& n=DEFAULTNOOFCORES);
      68           0 :     virtual ~MultiThreadedVisibilityResampler()
      69           0 :     {
      70           0 :       cleanup();
      71           0 :       nelements_p=0;
      72           0 :       currentVBS_p=0;
      73           0 :     }
      74             : 
      75           0 :     MultiThreadedVisibilityResampler(const MultiThreadedVisibilityResampler& other) : VisibilityResamplerBase() {copy(other);};
      76             : 
      77             :     // This version will make a clone with shared data buffers (the
      78             :     // complex grids and the sum-of-weights arrays).
      79           0 :     MultiThreadedVisibilityResampler* clone()
      80             :     {
      81             :       //Allocate a new instance, and copy the internals.
      82             :       MultiThreadedVisibilityResampler *clonedCopy;
      83           0 :       clonedCopy = new MultiThreadedVisibilityResampler(*this);
      84             :       // Now reset the data buffers with independent buffers (arrays of size 0)
      85           0 :       clonedCopy->allocateDataBuffers();
      86           0 :       return clonedCopy;
      87             :     };
      88             : 
      89             :     MultiThreadedVisibilityResampler& operator=(const MultiThreadedVisibilityResampler& other);
      90             : 
      91             :     void cleanup();
      92             :     void releaseBuffers();
      93             : 
      94             :     void copy(const MultiThreadedVisibilityResampler& other);
      95             : 
      96           0 :     virtual casacore::Int nelements() {return nelements_p;};
      97             :     virtual void setParams(const casacore::Vector<casacore::Double>& uvwScale, const casacore::Vector<casacore::Double>& offset,
      98             :                            const casacore::Vector<casacore::Double>& dphase);
      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           0 :     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             :     //
     116           0 :     virtual void DataToGrid(casacore::Array<casacore::DComplex>& griddedData,  
     117             :                             VBStore& vbs, 
     118             :                             casacore::Matrix<casacore::Double>& sumwt,
     119             :                             const casacore::Bool& dopsf,casacore::Bool /*useConjFreqCF*/=false)
     120           0 :     {DataToGridImpl_p(griddedData, vbs, sumwt,dopsf);}
     121             : 
     122           0 :     virtual void DataToGrid(casacore::Array<casacore::Complex>& griddedData, 
     123             :                             VBStore& vbs, 
     124             :                             casacore::Matrix<casacore::Double>& sumwt,
     125             :                             const casacore::Bool& dopsf,casacore::Bool /*useConjFreqCF*/=false)
     126             :     {
     127           0 :       DataToGridImpl_p(griddedData, vbs, sumwt,dopsf);
     128           0 :     }
     129             : 
     130             :     //
     131             :     // This is the gather operation on griddedData for nelements > 1
     132             :     //
     133             :     void GatherGrids(casacore::Array<casacore::DComplex>& griddedData, casacore::Matrix<casacore::Double>& sumwt);
     134             :     void GatherGrids(casacore::Array<casacore::Complex>& griddedData, casacore::Matrix<casacore::Double>& sumwt);
     135             :     void initializePutBuffers(const casacore::Array<casacore::DComplex>& griddedData,
     136             :                               const casacore::Matrix<casacore::Double>& sumwt);
     137             :     void initializePutBuffers(const casacore::Array<casacore::Complex>& griddedData,
     138             :                               const casacore::Matrix<casacore::Double>& sumwt);
     139           0 :     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);
     168             :     void makeInfrastructureContainers();
     169             :     casacore::Double allocateDataBuffers();
     170             :     void startThreads();
     171             :     void scatter(casacore::Matrix<VBStore>& vbsStores,const VBStore& vbs);
     172             : 
     173             :     casacore::Int nelements_p;
     174             :     casacore::Bool doublePrecision_p;
     175             :     casacore::Vector<casacore::CountedPtr<VisibilityResamplerBase> > resamplers_p;
     176             :     casacore::Vector<casacore::CountedPtr<casacore::Array<casacore::DComplex> > > doubleGriddedData_p;
     177             :     casacore::Vector<casacore::CountedPtr<casacore::Array<casacore::Complex> > > singleGriddedData_p;
     178             :     casacore::Vector<casacore::CountedPtr<casacore::Matrix<casacore::Double> > > sumwt_p;
     179             :     casacore::Vector<casacore::CountedPtr<ResamplerWorklet> > gridderWorklets_p;
     180             :     //    casacore::Vector<VBStore> vbsVec_p;
     181             :     casacore::Matrix<VBStore> vbsVec_p;
     182             : 
     183             :     casacore::CountedPtr<ThreadCoordinator<casacore::Int> > threadClerk_p;
     184             :     casacore::Bool threadStarted_p;
     185             :     casa::utilj::DeltaThreadTimes tSetupG, tSendDataG, tWaitForWorkG, tOutsideG;
     186             :     casa::utilj::DeltaThreadTimes tSetupDG, tSendDataDG, tWaitForWorkDG, tOutsideDG;
     187             :     casa::utilj::ThreadTimes t4G_p,t4DG_p;
     188             :     //    async::Mutex *mutexForResamplers_p;
     189             :     casacore::CountedPtr<VisibilityResamplerBase> visResamplerCtor_p;
     190             :     casacore::Int whoLoadedVB_p;
     191             :     casacore::Int currentVBS_p;
     192             :  };
     193             : }; //# NAMESPACE CASA - END
     194             : 
     195             : #endif // 

Generated by: LCOV version 1.16