Source
xxxxxxxxxx
//# ParallelImagerFactory.cc: Factory for ParallelImager instances
//# Copyright (C) 2016
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
using namespace casacore;
namespace casa {
ParallelImager *
ParallelImagerFactory::make(MPI_Comm task_comm,
Record clean_params,
Record selection_params,
Record image_params,
Record grid_params,
Record weight_params,
Record normalization_params,
Record deconvolution_params,
Record iteration_params)
{
ParallelImager *result;
ParallelImagerParams params(selection_params, image_params, grid_params,
weight_params, normalization_params,
deconvolution_params, iteration_params);
int niter = iteration_params.asInt("niter");
bool calculate_psf = clean_params.asBool("calcpsf");
bool calculate_residual = clean_params.asBool("calcres");
const std::string &save_model = clean_params.asString("savemodel");
bool interactive = iteration_params.asBool("interactive");
int rank;
MPI_Comm_rank(task_comm, &rank);
int size;
MPI_Comm_size(task_comm, &size);
bool is_worker = !interactive || rank > 0 || size == 1;
MPI_Comm worker_comm;
MPI_Comm_split(task_comm, is_worker ? 1 : MPI_UNDEFINED, 0, &worker_comm);
bool has_non_worker = interactive && size > 1;
int num_workers = size - (has_non_worker ? 1 : 0);