casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IterationControl.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 //# IterationControl.h: Iteration control for parallel imaging framework
3 //# (ParallelImagerMixin)
4 //# Copyright (C) 2016
5 //# Associated Universities, Inc. Washington DC, USA.
6 //#
7 //# This library is free software; you can redistribute it and/or modify it
8 //# under the terms of the GNU Library General Public License as published by
9 //# the Free Software Foundation; either version 2 of the License, or (at your
10 //# option) any later version.
11 //#
12 //# This library is distributed in the hope that it will be useful, but WITHOUT
13 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 //# License for more details.
16 //#
17 //# You should have received a copy of the GNU Library General Public License
18 //# along with this library; if not, write to the Free Software Foundation,
19 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20 //#
21 //# Correspondence concerning AIPS++ should be addressed as follows:
22 //# Internet email: aips2-request@nrao.edu.
23 //# Postal address: AIPS++ Project Office
24 //# National Radio Astronomy Observatory
25 //# 520 Edgemont Road
26 //# Charlottesville, VA 22903-2475 USA
27 //#
28 #ifndef ITERATION_CONTROL_H_
29 #define ITERATION_CONTROL_H_
30 
31 #include <casa/Containers/Record.h>
33 #if ! defined(WITHOUT_DBUS)
35 #endif
37 
38 #include <memory>
39 
40 namespace casa {
41 
43 
44 private:
45 #if ! defined(WITHOUT_DBUS)
46  std::unique_ptr<DistributedSynthesisIterBot> it;
47 #endif
48 protected:
49  void
52  // Instantiate an iterbot. Use DistributedSynthesisIterBot when
53  // interaction with new GUI works; for now,
54  // DistributedSynthesisIterBotWithOldGUI works.
55 #if ! defined(WITHOUT_DBUS)
56  it = std::unique_ptr<DistributedSynthesisIterBot>(
58  it->setupIteration(iter_pars);
59 #endif
60  };
61 
62  void
64 #if ! defined(WITHOUT_DBUS)
65  it.reset();
66 #endif
67  }
68 
69 public:
70  void
72 #if ! defined(WITHOUT_DBUS)
73  it->endMajorCycle();
74 #endif
75  };
76 
79 #if ! defined(WITHOUT_DBUS)
80  return it->getSubIterBot();
81 #else
82  return casacore::Record( );
83 #endif
84  };
85 
86  void
88 #if ! defined(WITHOUT_DBUS)
89  it->endMinorCycle(recs);
90 #endif
91  };
92 
93  void
95 #if ! defined(WITHOUT_DBUS)
96  it->startMinorCycle(recs);
97 #endif
98  };
99 
100  bool
102 #if ! defined(WITHOUT_DBUS)
103  return it->cleanComplete() > 0;
104 #else
105  return false;
106 #endif
107  };
108 
111 #if ! defined(WITHOUT_DBUS)
112  return it->getIterationSummary();
113 #else
114  return casacore::Record( );
115 #endif
116  };
117 
118  static int effective_rank(MPI_Comm comm) {
119  int result;
120  if (comm != MPI_COMM_NULL)
121  MPI_Comm_rank(comm, &result);
122  else
123  result = -1;
124  return result;
125  }
126 
127  static int effective_size(MPI_Comm comm) {
128  int result;
129  if (comm != MPI_COMM_NULL)
130  MPI_Comm_size(comm, &result);
131  else
132  result = 0;
133  return result;
134  }
135 };
136 
137 } // namespace casa
138 
139 #endif // ITERATION_CONTROL_H_
#define MPI_COMM_NULL
Definition: MPIGlue.h:67
A 1-D Specialization of the Array class.
int MPI_Comm
Definition: MPIGlue.h:59
static int effective_rank(MPI_Comm comm)
#define MPI_Comm_size(c, sp)
Definition: MPIGlue.h:71
void merge_initialization_records(const casacore::Vector< casacore::Record > &recs)
#define MPI_Comm_rank(c, rp)
Definition: MPIGlue.h:75
std::unique_ptr< DistributedSynthesisIterBot > it
A hierarchical collection of named fields of various types.
Definition: Record.h:180
void merge_execution_records(const casacore::Vector< casacore::Record > &recs)
static int effective_size(MPI_Comm comm)
casacore::Record get_minor_cycle_controls()
casacore::Record get_summary()
void setup_iteration_controller(MPI_Comm comm, casacore::Record &iter_pars)