LCOV - code coverage report
Current view: top level - synthesis/ImagerObjects - ParallelImagerFactory.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 8 0.0 %
Date: 2024-11-06 17:42:47 Functions: 0 2 0.0 %

          Line data    Source code
       1             : // -*- mode: c++ -*-
       2             : //# ParallelImagerFactory.h: Factory for ParallelImager instances
       3             : //# Copyright (C) 2016
       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             : #ifndef PARALLEL_IMAGER_FACTORY_H_
      28             : #define PARALLEL_IMAGER_FACTORY_H_
      29             : 
      30             : #include <synthesis/ImagerObjects/MPIGlue.h>
      31             : #include <synthesis/ImagerObjects/ParallelImager.h>
      32             : 
      33             : namespace casa {
      34             : 
      35             : 
      36             : /**
      37             :  * Factory class for ParallelImager instances. Instances of this class are used
      38             :  * to create the appropriate ParallelImager instance for a set of given
      39             :  * parameters.
      40             :  */
      41             : class ParallelImagerFactory {
      42             : public:
      43             : 
      44             :         /**
      45             :          * Make a ParallelImager for the given set of parameters. Decide whether to
      46             :          * instantiate a parallel continuum, parallel cube or serial imager, and
      47             :          * create an appropriate instance of that type. This method does not spawn
      48             :          * any processes, it just creates the imager instance for the current
      49             :          * process given the communicator 'task_comm' and the values provided by the
      50             :          * other parameters. The method works in a serial CASA environment through
      51             :          * the definitions provided by MPIGlue.h. The various imaging component
      52             :          * communicators required by ParallelImagerMixin are created by this method;
      53             :          * they are expected to be freed by the returned instance at an appropriate
      54             :          * time. No reference to 'task_comm' is maintained by the returned instance,
      55             :          * allowing the caller to use 'task_comm' freely after this method returns.
      56             :          */
      57             :         static ParallelImager *make(MPI_Comm task_comm,
      58             :                                     casacore::Record clean_params,
      59             :                                     casacore::Record selection_params,
      60             :                                     casacore::Record image_params,
      61             :                                     casacore::Record grid_params,
      62             :                                     casacore::Record weight_params,
      63             :                                     casacore::Record normalization_params,
      64             :                                     casacore::Record deconvolution_params,
      65             :                                     casacore::Record iteration_params);
      66             : 
      67             : private:
      68             :         // Convenience method for creating communicator for normalization
      69             :         // components. Significantly, return the null communicator when 'niter'
      70             :         // value is less than 1, which provides the indication to
      71             :         // SynthesisNormalizerMixin that the normalization component is not
      72             :         // required.
      73           0 :         static MPI_Comm normalization_comm(MPI_Comm comm, int niter) {
      74             :                 MPI_Comm result;
      75           0 :                 if (niter > 0 && comm != MPI_COMM_NULL) MPI_Comm_dup(comm, &result);
      76           0 :                 else result = MPI_COMM_NULL;
      77           0 :                 return result;
      78             :         }
      79             : 
      80             :         // Convenience method for duplicating communicators (incl. MPI_COMM_NULL)
      81           0 :         static MPI_Comm dup_valid_comm(MPI_Comm comm) {
      82             :                 MPI_Comm result;
      83           0 :                 if (comm != MPI_COMM_NULL) MPI_Comm_dup(comm, &result);
      84           0 :                 else result = MPI_COMM_NULL;
      85           0 :                 return result;
      86             :         }
      87             : };
      88             : 
      89             : } // namespace casa
      90             : 
      91             : #endif // PARALLEL_IMAGER_FACTORY_H_

Generated by: LCOV version 1.16