Xmipp  v3.23.11-Nereus
mpi_ml_align2d.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Authors: J.M. de la Rosa Trevin (jmdelarosa@cnb.csic.es)
3  *
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #ifndef MPI_ML_ALIGN2D_H_
27 #define MPI_ML_ALIGN2D_H_
28 
29 #include "parallel/xmipp_mpi.h"
32 
33 
37 
40 template<typename T>
42 {
43 protected:
46  //Reference to the program to be parallelized
47  T* program;
48 
49 public:
51  void readMpi(int argc, char **argv) {
52  if (node == nullptr)
53  {
54  node = new MpiNode(argc, argv);
55  created_node = true;
56  }
57  //The following makes the asumption that 'this' also
58  //inherits from an XmippProgram
59  if (!node->isMaster())
60  program->verbose = 0;
61  // Read subsequently to avoid problems in restart procedure
62  for (size_t proc = 0; proc < node->size; ++proc)
63  {
64  if (proc == node->rank)
65  program->read(argc, (const char **)argv);
66  node->barrierWait();
67  }
68  //Send "master" seed to slaves for same randomization
69  MPI_Bcast(&program->seed, 1, MPI_INT, 0, MPI_COMM_WORLD);
70  }
72  MpiML2DBase(T *prm);
74  MpiML2DBase(T *prm, MpiNode * node);
75 
76  MpiML2DBase(const MpiML2DBase &)=delete;
77  MpiML2DBase(const MpiML2DBase &&)=delete;
78 
81  if (created_node)
82  delete node;
83  }
84 
85  MpiML2DBase & operator =(const MpiML2DBase &)=delete;
86  MpiML2DBase & operator =(const MpiML2DBase &&)=delete;
87 
89  void sendDocfile(const MultidimArray<double> &data);
90 }
91 ;//end of class MpiML
92 
94 class MpiProgML2D: public ProgML2D, public MpiML2DBase<MpiProgML2D>
95 {
96 
97 public:
99  MpiProgML2D();
103  void setNumberOfLocalImages();
107  void produceSideInfo2();
109  void writeOutputFiles(const ModelML2D &model, OutputType outputType = OUT_FINAL);
111  void expectation();
113  void endIteration();
114  //Just for debugging
115  void printModel(const String &msg, const ModelML2D & model);
116  //Redefine usage, only master should print
117  virtual void usage(int verb = 0) const;
118 
119 }
120 ;//end of class MpiProgML2D
121 
122 
124 class MpiProgMLF2D: public ProgMLF2D, public MpiML2DBase<MpiProgMLF2D>
125 {
126 public:
128  MpiProgMLF2D();
134  void produceSideInfo();
135  void produceSideInfo2();
137  void writeOutputFiles(const ModelML2D &model, OutputType outputType = OUT_FINAL);
139  void expectation();
141  void endIteration();
142 }
143 ;//end of class MpiProgMLF2D
144 
146 #endif /* MPI_ML_ALIGN2D_H_ */
size_t size
Definition: xmipp_mpi.h:52
void sendDocfile(const MultidimArray< double > &data)
MpiNode * node
OutputType
Definition: ml2d.h:76
void barrierWait()
Definition: xmipp_mpi.cpp:171
void readMpi(int argc, char **argv)
for(j=1;j<=i__1;++j)
size_t rank
Definition: xmipp_mpi.h:52
MpiML2DBase & operator=(const MpiML2DBase &)=delete
MpiML2DBase(T *prm)
std::string String
Definition: xmipp_strings.h:34
Definition: ml2d.h:79
bool isMaster() const
Definition: xmipp_mpi.cpp:166
ProgClassifyCL2D * prm
Definition: ml2d.h:76