criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
MPIUtil.H
Go to the documentation of this file.
1
10#ifndef _MPIUTIL_H_
11#define _MPIUTIL_H_
12
13#include <array>
14#include <cstddef>
15#include <iostream>
16#include <string>
17#include <vector>
18#ifdef ENABLE_MPI
19# include "mpi.h"
20#endif
21#include "../Core/CRPacket.H"
22#include "../Core/FieldQty.H"
23#include "../Utils/ErrCodes.H"
24#include "../Utils/RealTensor2.H"
25#include "../Utils/Types.H"
26#include "../Utils/Vec3.H"
27
28namespace criptic {
29
33 namespace MPIUtil {
34
36 // MPI descripton variables that exist even if MPI is disabled
38 extern int nRank;
39 extern int myRank;
40 extern bool IOProc;
41 extern int log2nRank;
42 constexpr int IORank = 0;
45 // MPI functions; if MPI is disabled, these are still defined, but
46 // the MPI parts of them do nothing
48
58 void setup(int *argc, char **argv[]);
59
68 void haltRun(std::string msg, errCodes errcode);
69
75 void barrier();
76
83 void shutdown();
84
85#ifdef ENABLE_MPI
87 // Variables and types that are defined if this is an MPI run
89
90 // Global variables that define MPI data types
91 extern MPI_Datatype MPI_Real;
93 extern MPI_Datatype MPI_RealVec;
95 extern MPI_Datatype MPI_RealTensor2;
97 extern MPI_Datatype MPI_Idx;
99 extern MPI_Datatype MPI_CRPacket;
100 extern MPI_Datatype MPI_CRSource;
101 extern MPI_Datatype MPI_FieldQty;
102 extern MPI_Datatype MPI_FieldQtyGrad;
103 extern MPI_Datatype MPI_RealMechArr;
105 extern MPI_Datatype MPI_FillReq;
107 extern MPI_Datatype MPI_FillResp;
111 // Tag numbers
113
117 typedef enum {
120 tagFillReq = 8192,
121 tagFillResp = 16384
123
125 // Data structures
127
155
162 typedef struct {
164 std::array<IdxType,
167 std::array<FieldQty,
171 std::array<FieldQtyGrad,
176 } fillResponse;
177
178#endif
179 // ifdef ENABLE_MPI
180 }
181}
182
183#endif
184// _MPIUTIL_H_
#define TREE_LEAF_SIZE
Maximum number of packets per leaf in the CR tree.
Definition Definitions.H:76
Class to hold and compute gradients of field quantities.
Definition FieldQty.H:293
Class to hold and compute field quantities.
Definition FieldQty.H:53
Class that represents a rank 2 tensor.
Definition RealTensor2.H:34
constexpr int IORank
Definition MPIUtil.H:42
MPI_Datatype MPI_FieldQty
Definition MPIUtil.cpp:28
MPI_Datatype MPI_FillReq
Definition MPIUtil.cpp:31
MPI_Datatype MPI_FieldQtyGrad
Definition MPIUtil.cpp:29
MPI_Datatype MPI_CRSource
Definition MPIUtil.cpp:27
void barrier()
Barrier between MPI ranks.
Definition MPIUtil.cpp:302
int log2nRank
Definition MPIUtil.cpp:19
int nRank
Definition MPIUtil.cpp:16
void setup(int *argc, char **argv[])
Initial MPI setup.
Definition MPIUtil.cpp:40
MPI_Datatype MPI_Real
Definition MPIUtil.cpp:22
MPI_Datatype MPI_FillResp
Definition MPIUtil.cpp:32
MPI_Datatype MPI_RealVec
Definition MPIUtil.cpp:23
void shutdown()
Shut down communications for normal exit.
Definition MPIUtil.cpp:309
int myRank
Definition MPIUtil.cpp:17
void haltRun(std::string msg, errCodes errcode)
Halt a run because an error has occurred.
Definition MPIUtil.cpp:287
MPI_Datatype MPI_RealTensor2
Definition MPIUtil.cpp:24
MPI_Datatype MPI_Idx
Definition MPIUtil.cpp:25
mpiTags
Tag numbers for different types of MPI messages.
Definition MPIUtil.H:117
@ tagHDF5IO
Definition MPIUtil.H:118
@ tagFillReq
Definition MPIUtil.H:120
@ tagWorkDone
Definition MPIUtil.H:119
@ tagFillResp
Definition MPIUtil.H:121
MPI_Datatype MPI_CRPacket
Definition MPIUtil.cpp:26
MPI_Datatype MPI_RealMechArr
Definition MPIUtil.cpp:30
bool IOProc
Definition MPIUtil.cpp:18
The primary namespace for criptic objects.
Definition AdvancePacket.H:25
errCodes
List of error return codes.
Definition ErrCodes.H:22
Vec3< Real > RealVec
Definition Vec3.H:615
std::vector< Real >::size_type IdxType
Definition Types.H:45
double Real
Definition Types.H:38
Struture to hold data representing a search request.
Definition MPIUtil.H:135
RealTensor2 h2InvGrad
Definition MPIUtil.H:138
IdxType count
Definition MPIUtil.H:136
RealTensor2 h2Inv
Definition MPIUtil.H:137
std::array< IdxType, TREE_LEAF_SIZE > idx
Definition MPIUtil.H:142
int nrank
Definition MPIUtil.H:140
Real hScale
Definition MPIUtil.H:139
std::array< FieldQty, TREE_LEAF_SIZE > qMin
Definition MPIUtil.H:151
std::array< RealVec, TREE_LEAF_SIZE > x
Definition MPIUtil.H:145
std::array< Real, TREE_LEAF_SIZE > R
Definition MPIUtil.H:148
Struture to hold data representing a response to a request.
Definition MPIUtil.H:162
std::array< FieldQtyGrad, TREE_LEAF_SIZE > qGrad
Definition MPIUtil.H:172
std::array< FieldQty, TREE_LEAF_SIZE > q
Definition MPIUtil.H:168
IdxType count
Definition MPIUtil.H:163
std::array< IdxType, TREE_LEAF_SIZE > idx
Definition MPIUtil.H:165