LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - ResamplerWorklet.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 72 0.0 %
Date: 2024-10-29 13:38:20 Functions: 0 9 0.0 %

          Line data    Source code
       1             : // -*- C++ -*-
       2             : //# ResamplerWorklet.cc: Implementation of the ResamplerWorklet 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: casa-feedback@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             : #include <synthesis/TransformMachines/SynthesisError.h>
      30             : #include <synthesis/TransformMachines/Utils.h>
      31             : #include <synthesis/TransformMachines/VisibilityResampler.h>
      32             : #include <synthesis/MeasurementComponents/ResamplerWorklet.h>
      33             : #include <synthesis/MeasurementComponents/MThWorkIDEnum.h>
      34             : #include <synthesis/Utilities/ThreadCoordinator.h>
      35             : //#include <synthesis/Utilities/ThreadTimers.h>
      36             : #include <fstream>
      37             : #include <sys/syscall.h>
      38             : 
      39             : using namespace casacore;
      40             : namespace casa{
      41           0 :   ResamplerWorklet& ResamplerWorklet::operator=(const ResamplerWorklet& other)
      42             :   {
      43           0 :     myResampler_p = other.myResampler_p;
      44           0 :     myVBStore_p = other.myVBStore_p;
      45           0 :     myGriddedDataDouble_p = other.myGriddedDataDouble_p;
      46           0 :     myGriddedDataSingle_p = other.myGriddedDataSingle_p;
      47           0 :     mySumWt_p = other.mySumWt_p;
      48           0 :     myThreadClerk_p = other.myThreadClerk_p;
      49           0 :     myID_p = other.myID_p;
      50           0 :     myPID_p = other.myPID_p;
      51           0 :     myTID_p = other.myTID_p;
      52           0 :     mySkyFTGrid_p = other.mySkyFTGrid_p;
      53           0 :     return *this;
      54             :   }
      55             :   
      56           0 :   void ResamplerWorklet::initThread(Int& id, 
      57             :                                     CountedPtr<ThreadCoordinator<Int> >& threadClerk,
      58             :                                     VisibilityResamplerBase* resampler)
      59             :   {
      60             :     //      LogIO log_p(LogOrigin("ResamplerWorklet","initThread"));
      61           0 :       setID(id);
      62           0 :       myThreadClerk_p = threadClerk;
      63           0 :       myResampler_p = resampler;
      64           0 :   }
      65           0 :   void ResamplerWorklet::initToVis(VBStore* vbs, const Array<Complex>* skyFTGrid) 
      66             :   {
      67             :     //    LogIO log_p(LogOrigin("ResamplerWorklet","initToVis"));
      68           0 :     myVBStore_p = vbs;
      69           0 :     mySkyFTGrid_p = skyFTGrid;
      70           0 :   }
      71           0 :   void ResamplerWorklet::initToSky(VBStore* vbs,Array<DComplex>* griddedData, Matrix<Double>* sumwt) 
      72             :   {
      73             :     //    LogIO log_p(LogOrigin("ResamplerWorklet","init (double precision)"));
      74           0 :     myVBStore_p = vbs;
      75           0 :     myGriddedDataDouble_p = griddedData;
      76           0 :     mySumWt_p = sumwt;
      77           0 :   }
      78           0 :   void ResamplerWorklet::initToSky(VBStore* vbs,Array<Complex>* griddedData, Matrix<Double>* sumwt) 
      79             :   {
      80             :     //    LogIO log_p(LogOrigin("ResamplerWorklet","init (single precision)"));
      81           0 :     myVBStore_p = vbs;
      82           0 :     myGriddedDataSingle_p = griddedData;
      83           0 :     mySumWt_p = sumwt;
      84           0 :   }
      85           0 :   void ResamplerWorklet::init(Int& id, 
      86             :                               CountedPtr<ThreadCoordinator<Int> >& threadClerk,
      87             :                               VisibilityResamplerBase* resampler, VBStore* vbs,
      88             :                               Array<DComplex>* griddedData, Matrix<Double>* sumwt,
      89             :                               Array<Complex>* skyFTGrid)
      90             :     {
      91             :       //      LogIO log_p(LogOrigin("ResamplerWorklet","init (double precision)"));
      92             : 
      93           0 :       setID(id);
      94           0 :       myThreadClerk_p = threadClerk;
      95           0 :       myResampler_p = resampler;
      96           0 :       myVBStore_p = vbs;
      97           0 :       myGriddedDataDouble_p = griddedData;
      98           0 :       mySumWt_p = sumwt;
      99           0 :       mySkyFTGrid_p = skyFTGrid;
     100             :       //      log_p << "Gridder worklet # " << id << " ready." << LogIO::POST;
     101           0 :     };
     102           0 :   void ResamplerWorklet::init(Int& id, 
     103             :                               CountedPtr<ThreadCoordinator<Int> >& threadClerk,
     104             :                               VisibilityResamplerBase* resampler, VBStore* vbs,
     105             :                               Array<Complex>* griddedData, Matrix<Double>* sumwt,
     106             :                               Array<Complex>* skyFTGrid)
     107             :     {
     108             :       //      LogIO log_p(LogOrigin("ResamplerWorklet","init (single precision)"));
     109             : 
     110           0 :       setID(id);
     111           0 :       myThreadClerk_p = threadClerk;
     112           0 :       myResampler_p = resampler;
     113           0 :       myVBStore_p = vbs;
     114           0 :       myGriddedDataSingle_p = griddedData;
     115           0 :       mySumWt_p = sumwt;
     116           0 :       mySkyFTGrid_p = skyFTGrid;
     117             :       //      log_p << "Gridder worklet # " << id << " ready." << LogIO::POST;
     118           0 :     };
     119             : 
     120           0 :   void ResamplerWorklet::setPID()
     121             :   {
     122           0 :     LogIO log_p(LogOrigin("ResamplerWorklet","setPID"));
     123           0 :     myTID_p = gettid_p (); myPID_p = getpid ();
     124             :     log_p << "Worklet # " << myID_p << " Activated. " 
     125             :           << "PID = " << myPID_p << " TID = " << myTID_p
     126           0 :           << LogIO::POST;
     127           0 :   }
     128           0 :   void* ResamplerWorklet::run()
     129             :   {
     130           0 :     LogIO log_p(LogOrigin("ResamplerWorklet","run"));
     131             : 
     132           0 :     setPID();
     133             :     //    DT tCycleG, tWaitG, tWorkG,tCycleDG, tWaitDG, tWorkDG, tWorkR, tWaitR, tCycleR;
     134             : 
     135             :     //    T t1,t2,t3;
     136             :     Int *doDataToGrid;
     137             :     while(true)
     138             :       {
     139             :         //      Timers t1 = Timers::getTime();
     140             :         //      Bool *doDataToGrid;
     141           0 :         doDataToGrid = myThreadClerk_p->waitForWork(this);
     142           0 :         if (doDataToGrid == NULL) break;
     143             : 
     144             :         // Timers t2G=Timers::getTime();
     145             :         // Timers t2DG=Timers::getTime();
     146             :         // Timers t2R=Timers::getTime();
     147             :         //      if (*doDataToGrid==1)   // Gridding work
     148           0 :         if (*doDataToGrid==MThWorkID::DATATOGRID)   // Gridding work
     149             :           {
     150             :             //      cerr << myID_p << " " << myVBStore_p->beginRow_p << " " << myVBStore_p->endRow_p << endl;
     151             :             //      t2G=Timers::getTime();
     152           0 :             if (myGriddedDataDouble_p != NULL)
     153           0 :               myResampler_p->DataToGrid(*myGriddedDataDouble_p, *myVBStore_p, 
     154           0 :                                         *mySumWt_p, myVBStore_p->dopsf_p);
     155             :             else
     156           0 :               myResampler_p->DataToGrid(*myGriddedDataSingle_p, *myVBStore_p, 
     157           0 :                                         *mySumWt_p, myVBStore_p->dopsf_p);
     158             :           }
     159             :         //      else if (*doDataToGrid == 0)                      // De-gridding work
     160           0 :         else if (*doDataToGrid == MThWorkID::GRIDTODATA)                      // De-gridding work
     161             :           {
     162             :             //      t2DG=Timers::getTime();
     163           0 :             myResampler_p->GridToData(*myVBStore_p, *mySkyFTGrid_p);
     164             :           }
     165             :         //      else if (*doDataToGrid == 2)
     166           0 :         else if (*doDataToGrid == MThWorkID::RESIDUALCALC)
     167             :           {
     168             :             //      t2R=Timers::getTime();
     169           0 :             myResampler_p->ComputeResiduals(*myVBStore_p);
     170             :           }
     171             :           
     172             :         //      Timers t3=Timers::getTime();
     173             : 
     174             :         // if (*doDataToGrid==1)
     175             :         //   {
     176             :         //     tWaitG += t2G - t1;
     177             :         //     tWorkG += t3 - t2G;
     178             :         //     tCycleG += t3 - t1;
     179             :         //   }
     180             :         // else if (*doDataToGrid == 2)
     181             :         //   {
     182             :         //     tWaitDG += t2DG - t1;
     183             :         //     tWorkDG += t3 - t2DG;
     184             :         //     tCycleDG += t3 - t1;
     185             :         //   }
     186             :         // else
     187             :         //   {
     188             :         //     tWaitR += t2R - t1;
     189             :         //     tWorkR +=  t3 - t2R;
     190             :         //     tCycleR += t3 -t1;
     191             :         //   }
     192             :       }
     193           0 :     log_p << "Alveeda from Workelet # " << myID_p << LogIO::POST;
     194             :     //    doDataToGrid = myThreadClerk_p->waitForWork(this);
     195             :     //    terminate();
     196             : 
     197             :     // log_p << "GWait="  << tWaitG.formatAverage().c_str() << " "
     198             :     //    << "GWork="  << tWorkG.formatAverage().c_str() << " "
     199             :     //    << "GTotal=" << tCycleG.formatAverage().c_str()
     200             :     //    << LogIO::POST;
     201             :     // log_p << "DGWait="  << tWaitDG.formatAverage().c_str() << " "
     202             :     //    << "DGWork="  << tWorkDG.formatAverage().c_str() << " "
     203             :     //    << "DGTotal=" << tCycleDG.formatAverage().c_str()
     204             :     //    << LogIO::POST;
     205             :     // log_p << "RWait="  << tWaitR.formatAverage().c_str() << " "
     206             :     //    << "RWork="  << tWorkR.formatAverage().c_str() << " "
     207             :     //    << "RTotal=" << tCycleR.formatAverage().c_str()
     208             :     //    << LogIO::POST;
     209           0 :     return NULL;
     210           0 :   }
     211             : };

Generated by: LCOV version 1.16