00001 // -*- mode: c++ -*- 00002 //# ParallelImagerFactory.h: Factory for ParallelImager instances 00003 //# Copyright (C) 2016 00004 //# Associated Universities, Inc. Washington DC, USA. 00005 //# 00006 //# This library is free software; you can redistribute it and/or modify it 00007 //# under the terms of the GNU Library General Public License as published by 00008 //# the Free Software Foundation; either version 2 of the License, or (at your 00009 //# option) any later version. 00010 //# 00011 //# This library is distributed in the hope that it will be useful, but WITHOUT 00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00014 //# License for more details. 00015 //# 00016 //# You should have received a copy of the GNU Library General Public License 00017 //# along with this library; if not, write to the Free Software Foundation, 00018 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00019 //# 00020 //# Correspondence concerning AIPS++ should be addressed as follows: 00021 //# Internet email: aips2-request@nrao.edu. 00022 //# Postal address: AIPS++ Project Office 00023 //# National Radio Astronomy Observatory 00024 //# 520 Edgemont Road 00025 //# Charlottesville, VA 22903-2475 USA 00026 //# 00027 #ifndef PARALLEL_IMAGER_FACTORY_H_ 00028 #define PARALLEL_IMAGER_FACTORY_H_ 00029 00030 #include <synthesis/ImagerObjects/MPIGlue.h> 00031 #include <synthesis/ImagerObjects/ParallelImager.h> 00032 00033 namespace casa { 00034 00035 00041 class ParallelImagerFactory { 00042 public: 00043 00057 static ParallelImager *make(MPI_Comm task_comm, 00058 Record clean_params, 00059 Record selection_params, 00060 Record image_params, 00061 Record grid_params, 00062 Record weight_params, 00063 Record normalization_params, 00064 Record deconvolution_params, 00065 Record iteration_params); 00066 00067 private: 00068 // Convenience method for creating communicator for normalization 00069 // components. Significantly, return the null communicator when 'niter' 00070 // value is less than 1, which provides the indication to 00071 // SynthesisNormalizerMixin that the normalization component is not 00072 // required. 00073 static MPI_Comm normalization_comm(MPI_Comm comm, int niter) { 00074 MPI_Comm result; 00075 if (niter > 0 && comm != MPI_COMM_NULL) MPI_Comm_dup(comm, &result); 00076 else result = MPI_COMM_NULL; 00077 return result; 00078 } 00079 00080 // Convenience method for duplicating communicators (incl. MPI_COMM_NULL) 00081 static MPI_Comm dup_valid_comm(MPI_Comm comm) { 00082 MPI_Comm result; 00083 if (comm != MPI_COMM_NULL) MPI_Comm_dup(comm, &result); 00084 else result = MPI_COMM_NULL; 00085 return result; 00086 } 00087 }; 00088 00089 } // namespace casa 00090 00091 #endif // PARALLEL_IMAGER_FACTORY_H_