casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SynthesisDeconvolverMixin.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 //# SynthesisDeconvolverMixin.h: Mixin for using SynthesisDeconvolver class in
3 //# parallel imaging framework
4 //# (ParallelImagerMixin)
5 //# Copyright (C) 2016
6 //# Associated Universities, Inc. Washington DC, USA.
7 //#
8 //# This library is free software; you can redistribute it and/or modify it
9 //# under the terms of the GNU Library General Public License as published by
10 //# the Free Software Foundation; either version 2 of the License, or (at your
11 //# option) any later version.
12 //#
13 //# This library is distributed in the hope that it will be useful, but WITHOUT
14 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
16 //# License for more details.
17 //#
18 //# You should have received a copy of the GNU Library General Public License
19 //# along with this library; if not, write to the Free Software Foundation,
20 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
21 //#
22 //# Correspondence concerning AIPS++ should be addressed as follows:
23 //# Internet email: aips2-request@nrao.edu.
24 //# Postal address: AIPS++ Project Office
25 //# National Radio Astronomy Observatory
26 //# 520 Edgemont Road
27 //# Charlottesville, VA 22903-2475 USA
28 //#
29 #ifndef SYNTHESIS_DECONVOLVER_MIXIN_H_
30 #define SYNTHESIS_DECONVOLVER_MIXIN_H_
31 
32 #include <casa/Containers/Record.h>
35 #include <memory>
36 #include <algorithm>
37 #include <vector>
38 
39 namespace casa {
40 
45 template<class T>
47  : public T {
48 
49 private:
50  std::vector< std::shared_ptr<SynthesisDeconvolver> > deconvolvers;
51 
53 
54 protected:
55  void
57  std::vector<SynthesisParamsDeconv> &deconv_pars) {
58  // Create all deconvolver components on rank 0 of comm. TODO: Could we
59  // distribute deconvolvers in a round-robin fashion across processes in
60  // comm?
61 
63  if (T::effective_rank(comm) == 0) {
64  size_t num_fields = deconv_pars.size();
65  for (size_t i = 0; i < num_fields; ++i) {
67  sd->setupDeconvolution(deconv_pars[i]);
68  deconvolvers.push_back(
69  std::shared_ptr<SynthesisDeconvolver>(sd));
70  }
71  }
72  };
73 
74  void
76  deconvolvers.clear();
77  };
78 
79 public:
80  void
82  std::vector<casacore::Record> init_records;
83  for (auto sd : deconvolvers)
84  init_records.push_back(sd->initMinorCycle());
85  T::merge_initialization_records(init_records);
86  controls = T::get_minor_cycle_controls();
87  };
88 
89  void
91  std::vector<casacore::Record> exec_records;
92  for (auto sd : deconvolvers)
93  exec_records.push_back(sd->executeMinorCycle(controls));
94  T::merge_execution_records(exec_records);
95  };
96 
97  void
99  for (auto sd : deconvolvers)
100  sd->restore();
101  };
102 };
103 
104 } // namespace casa
105 
106 #endif // SYNTHESIS_DECONVOLVER_MIXIN_H_
int MPI_Comm
Definition: MPIGlue.h:59
Simple mixin class to put SynthesisDeconvolver into ParallelImagerMixin framework.
Forward declarations.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
std::vector< std::shared_ptr< SynthesisDeconvolver > > deconvolvers
void setup_deconvolver(MPI_Comm comm, std::vector< SynthesisParamsDeconv > &deconv_pars)
void setupDeconvolution(const SynthesisParamsDeconv &decpars)
Copy constructor and assignment operator.