23#include "rheolef/environment.h"
24#ifndef _RHEOLEF_HAVE_MPI
32environment::~environment()
42# if (MPI_VERSION >= 2)
43# ifndef MPI_Errhandler_set
44# define MPI_Errhandler_set MPI_Comm_set_errhandler
47# define MPI_Attr_get MPI_Comm_get_attr
56 MPI_Initialized(&flag);
65 : _rheolef_has_init(false), _oldcw(0)
70 status = MPI_Init (&argc, &argv);
72 int obtained_thread_level;
73 status = MPI_Init_thread (&argc, &argv, opt.
thread_level, &obtained_thread_level);
75 warning_macro (
"mpi_init: obtained thread level="<<obtained_thread_level <<
" while asking for thread level="<<opt.
thread_level);
78 check_macro (status == MPI_SUCCESS,
"mpi init failed");
80 if (!_rheolef_has_init) {
81#ifdef _RHEOLEF_HAVE_OBSOLETE_MPI_V1
82 MPI_Errhandler_set (MPI_COMM_WORLD, MPI_ERRORS_RETURN);
84 MPI_Comm_set_errhandler (MPI_COMM_WORLD, MPI_ERRORS_RETURN);
86 _rheolef_has_init =
true;
92 boost::mpi::detail::mpi_datatype_cache().clear();
98 MPI_Abort(MPI_COMM_WORLD, errcode);
104 MPI_Attr_get(MPI_COMM_WORLD, MPI_TAG_UB, &max_tag_value, &found);
106 return *max_tag_value - _num_reserved_tags;
116 MPI_Attr_get(MPI_COMM_WORLD, MPI_HOST, &host, &found);
117 if (!found || *host == MPI_PROC_NULL) {
118 return boost::optional<int>();
127 MPI_Attr_get(MPI_COMM_WORLD, MPI_IO, &io, &found);
128 if (!found || *io == MPI_PROC_NULL) {
129 return boost::optional<int>();
136 char name[MPI_MAX_PROCESSOR_NAME];
138 MPI_Get_processor_name(name, &len);
139 return std::string(name, len);
static std::string processor_name()
static bool initialized()
static boost::optional< int > io_rank()
environment(int &argc, char **&argv, const environment_option_type &opt=environment_option_type())
static boost::optional< int > host_rank()
static void abort(int errcode)
static int collectives_tag()
#define assert_macro(ok_condition, message)
#define warning_macro(message)
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
This file is part of Rheolef.
static const int no_thread