www.cemf.ir
processors.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 #ifndef __processors_H__
21 #define __processors_H__
22 
23 
24 
25 namespace pFlow
26 {
27  // - Forward
28  bool checkMPI
29  (
30  const char* funcName,
31  int error,
32  bool forceAbort,
33  const char* fileName,
34  int lineNumebr
35  );
36 }
37 
38 // - Macro for automating line and file logs
39 #define CheckMPI(caller, fAbort)\
40  pFlow::checkMPI(#caller, (caller), fAbort, __FILE__, __LINE__);
41 
42 
43 namespace pFlow
44 {
45 
52 {
53 private:
54 
56  static inline
57  bool initProcessorsCelled_ = false;
58 
60  static inline
61  int globalRank_ = 0;
62 
64  static inline
65  int globalSize_ = 1;
66 
67  static inline
68  int argc_ = 0;
69 
70  static inline
71  char** argv_ = nullptr;
72 
73 public:
74 
76  static
77  void initProcessors(int argc, char *argv[]);
78 
80  static
81  void finalizeProcessors();
82 
84  processors();
85 
87  ~processors();
88 
90  static inline
92  {
93  return 0;
94  }
95 
97  static inline
99  {
100  return processors::globalSize()>1;
101  }
102 
103  static inline
104  const char* globalRunTypeName()
105  {
106  if(globalParallel())
107  {
108  return "MPI";
109  }
110  else
111  {
112  return "regular";
113  }
114  }
116  static
117  bool isInitialized();
118 
120  static
121  bool isFinalized();
122 
124  static inline
126  {
128  }
129 
131  static inline
133  {
134  return globalSize_;
135  }
136 
138  static inline
140  {
141  return globalRank_;
142  }
143 
144  static inline
145  int argc()
146  {
147  return argc_;
148  }
149 
150  static inline
151  char** argv()
152  {
153  return argv_;
154  }
155 
157  static
158  void abort(int error);
159 
160 /*#ifdef pFlow_Build_MPI
161  static inline
162  auto worldCommunicator()
163  {
164  return pFlow::MPI::CommWorld;
165  }
166 #endif*/
167 
168 }; //processors
169 
170 
171 } // pFlow
172 
173 #endif //__processors_H__
pFlow::processors::processors
processors()
Constructor.
Definition: processors.cpp:105
pFlow::processors::globalSize_
static int globalSize_
The global size of all processors.
Definition: processors.hpp:65
pFlow::checkMPI
bool checkMPI(const char *funcName, int error, bool forceAbort, const char *fileName, int lineNumebr)
Definition: processors.cpp:165
pFlow::processors::initProcessors
static void initProcessors(int argc, char *argv[])
Initialize MPI processors.
Definition: processors.cpp:42
pFlow::processors::~processors
~processors()
Destructor.
Definition: processors.cpp:119
pFlow::processors::finalizeProcessors
static void finalizeProcessors()
Finalize MPI processors.
Definition: processors.cpp:88
pFlow::processors::globalMaster
static bool globalMaster()
Is this processor the master processor?
Definition: processors.hpp:125
pFlow::processors::globalRank
static int globalRank()
Rank of the processor in the global MPI.
Definition: processors.hpp:139
pFlow::processors
This class holds the information about the global execution world and number of processors in communi...
Definition: processors.hpp:51
pFlow::processors::globalParallel
static bool globalParallel()
Is this a parallel MPI run.
Definition: processors.hpp:98
pFlow
Definition: demGeometry.hpp:27
pFlow::processors::isFinalized
static bool isFinalized()
Is MPI finalized?
Definition: processors.cpp:135
pFlow::processors::globalSize
static int globalSize()
Global size of processors.
Definition: processors.hpp:132
pFlow::processors::globalMasterNo
static int globalMasterNo()
Master processors number (globaly in MPI).
Definition: processors.hpp:91
pFlow::processors::argc
static int argc()
Definition: processors.hpp:145
pFlow::processors::argv
static char ** argv()
Definition: processors.hpp:151
pFlow::processors::argc_
static int argc_
Definition: processors.hpp:68
pFlow::processors::globalRunTypeName
static const char * globalRunTypeName()
Definition: processors.hpp:104
pFlow::processors::globalRank_
static int globalRank_
Global rank of the current processor.
Definition: processors.hpp:61
pFlow::processors::initProcessorsCelled_
static bool initProcessorsCelled_
Is the static member initProcessors is called.
Definition: processors.hpp:57
pFlow::processors::abort
static void abort(int error)
Abort MPI run or regular run.
Definition: processors.cpp:147
pFlow::processors::argv_
static char ** argv_
Definition: processors.hpp:71
pFlow::processors::isInitialized
static bool isInitialized()
Is MPI initialized?
Definition: processors.cpp:123