IterationControl.h

Go to the documentation of this file.
00001 /* -*- mode: c++ -*- */
00002 //# IterationControl.h: Iteration control for parallel imaging framework
00003 //#                     (ParallelImagerMixin)
00004 //# Copyright (C) 2016
00005 //# Associated Universities, Inc. Washington DC, USA.
00006 //#
00007 //# This library is free software; you can redistribute it and/or modify it
00008 //# under the terms of the GNU Library General Public License as published by
00009 //# the Free Software Foundation; either version 2 of the License, or (at your
00010 //# option) any later version.
00011 //#
00012 //# This library is distributed in the hope that it will be useful, but WITHOUT
00013 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00015 //# License for more details.
00016 //#
00017 //# You should have received a copy of the GNU Library General Public License
00018 //# along with this library; if not, write to the Free Software Foundation,
00019 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00020 //#
00021 //# Correspondence concerning AIPS++ should be addressed as follows:
00022 //#        Internet email: aips2-request@nrao.edu.
00023 //#        Postal address: AIPS++ Project Office
00024 //#                        National Radio Astronomy Observatory
00025 //#                        520 Edgemont Road
00026 //#                        Charlottesville, VA 22903-2475 USA
00027 //#
00028 #ifndef ITERATION_CONTROL_H_
00029 #define ITERATION_CONTROL_H_
00030 
00031 #include <casa/Containers/Record.h>
00032 #include <synthesis/ImagerObjects/MPIGlue.h>
00033 #include <synthesis/ImagerObjects/DistributedSynthesisIterBot.h>
00034 #include <synthesis/ImagerObjects/ParallelImager.h>
00035 
00036 #include <memory>
00037 
00038 namespace casa {
00039 
00040 class IterationControl {
00041 
00042 private:
00043         std::unique_ptr<DistributedSynthesisIterBot> it;
00044 
00045 protected:
00046         void
00047         setup_iteration_controller(MPI_Comm comm, Record &iter_pars) {
00048                 teardown_iteration_controller();
00049                 // Instantiate an iterbot. Use DistributedSynthesisIterBot when
00050                 // interaction with new GUI works; for now,
00051                 // DistributedSynthesisIterBotWithOldGUI works.
00052                 it = std::unique_ptr<DistributedSynthesisIterBot>(
00053                         new DistributedSynthesisIterBotWithOldGUI(comm));
00054                 it->setupIteration(iter_pars);
00055         };
00056 
00057         void
00058         teardown_iteration_controller() {
00059                 it.reset();
00060         }
00061 
00062 public:
00063         void
00064         end_major_cycle() {
00065                 it->endMajorCycle();
00066         };
00067 
00068         Record
00069         get_minor_cycle_controls() {
00070                 return it->getSubIterBot();
00071         };
00072 
00073         void
00074         merge_execution_records(const Vector<Record> &recs) {
00075                 it->endMinorCycle(recs);
00076         };
00077 
00078         void
00079         merge_initialization_records(const Vector<Record> &recs) {
00080                 it->startMinorCycle(recs);
00081         };
00082 
00083         bool
00084         is_clean_complete() {
00085                 return it->cleanComplete() > 0;
00086         };
00087 
00088         Record
00089         get_summary() {
00090                 return it->getIterationSummary();
00091         };
00092 
00093         static int effective_rank(MPI_Comm comm) {
00094                 int result;
00095                 if (comm != MPI_COMM_NULL)
00096                         MPI_Comm_rank(comm, &result);
00097                 else
00098                         result = -1;
00099                 return result;
00100         }
00101 
00102         static int effective_size(MPI_Comm comm) {
00103                 int result;
00104                 if (comm != MPI_COMM_NULL)
00105                         MPI_Comm_size(comm, &result);
00106                 else
00107                         result = 0;
00108                 return result;
00109         }
00110 };
00111 
00112 } // namespace casa
00113 
00114 #endif // ITERATION_CONTROL_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1