Lattice Microbes 2.5
This is for whole cell modeling
Loading...
Searching...
No Matches
lm_mpi.h
Go to the documentation of this file.
1/*
2 * University of Illinois Open Source License
3 * Copyright 2008-2018 Luthey-Schulten Group,
4 * All rights reserved.
5 *
6 * Developed by: Luthey-Schulten Group
7 * University of Illinois at Urbana-Champaign
8 * http://www.scs.uiuc.edu/~schulten
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy of
11 * this software and associated documentation files (the Software), to deal with
12 * the Software without restriction, including without limitation the rights to
13 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14 * of the Software, and to permit persons to whom the Software is furnished to
15 * do so, subject to the following conditions:
16 *
17 * - Redistributions of source code must retain the above copyright notice,
18 * this list of conditions and the following disclaimers.
19 *
20 * - Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimers in the documentation
22 * and/or other materials provided with the distribution.
23 *
24 * - Neither the names of the Luthey-Schulten Group, University of Illinois at
25 * Urbana-Champaign, nor the names of its contributors may be used to endorse or
26 * promote products derived from this Software without specific prior written
27 * permission.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
32 * THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
33 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
34 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35 * OTHER DEALINGS WITH THE SOFTWARE.
36 *
37 * Author(s): Elijah Roberts
38 */
39
40#ifndef LM_MPI_H_
41#define LM_MPI_H_
42
43#include <mpi.h>
44#include "core/Exceptions.h"
45
46void MPIErrorHandler(MPI_Comm *, int *rc, ...);
47
48namespace lm {
49
52class MPIException : public Exception
53{
54public:
55 int errorCode; // Error code thrown by MPI
56
59 MPIException(int error);
60};
61
64class MPI
65{
66public:
67 static int version; // MPI main version
68 static int subversion; // MPI minor version
69 static int threadSupport; // MPI level of thread support
70 static int worldSize; // Size of MPI groups in the simulation
71 static int worldRank; // Number of MPI processes in the simulation
72 static const int MASTER=0;
73
74 // MPI messages.
75 static const int MSG_RUN_SIMULATION = 1;
76 static const int MSG_SIMULATION_FINISHED = 2;
77 static const int MSG_OUTPUT_DATA_STATIC = 10;
78 static const int MSG_EXIT = 99;
79
80 static const int OUTPUT_DATA_STATIC_MAX_SIZE = 10*1024*1024;
81
85 static void init(int argc, char** argv);
87 static void printCapabilities();
89 static void finalize();
90};
91
92}
93
96#define MPI_EXCEPTION_CHECK(mpi_call) {int _mpi_ret_=mpi_call; if (_mpi_ret_ != MPI_SUCCESS) throw lm::MPIException(_mpi_ret_);}
97
98
99#endif /*LM_MPI_H_*/
Exception(const char *message="")
Create an Exception.
Definition Exceptions.h:62
int errorCode
Definition lm_mpi.h:55
MPIException(int error)
Create the MPIException.
Definition lm_mpi.cpp:49
Handles the MPI capabilities and properties of the simulation.
Definition lm_mpi.h:65
static const int MASTER
Definition lm_mpi.h:72
static int version
Definition lm_mpi.h:67
static const int MSG_OUTPUT_DATA_STATIC
Definition lm_mpi.h:77
static const int MSG_EXIT
Definition lm_mpi.h:78
static const int MSG_SIMULATION_FINISHED
Definition lm_mpi.h:76
static int worldSize
Definition lm_mpi.h:70
static const int OUTPUT_DATA_STATIC_MAX_SIZE
Definition lm_mpi.h:80
static int worldRank
Definition lm_mpi.h:71
static void printCapabilities()
Print the capabilities of the current processing device.
Definition lm_mpi.cpp:82
static void finalize()
Close and cleanup the MPI runtime.
Definition lm_mpi.cpp:100
static void init(int argc, char **argv)
Initialize the MPI runtime.
Definition lm_mpi.cpp:64
static int threadSupport
Definition lm_mpi.h:69
static const int MSG_RUN_SIMULATION
Definition lm_mpi.h:75
static int subversion
Definition lm_mpi.h:68
void MPIErrorHandler(MPI_Comm *, int *rc,...)
Definition Capsule.cpp:46