23 #include "rheolef/distributed.h"
24 #ifndef _RHEOLEF_HAVE_MPI
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
54 bool environment::initialized() {
56 MPI_Initialized(&flag);
59 bool environment::finalized() {
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);
74 if (obtained_thread_level != opt.thread_level) {
75 warning_macro (
"mpi_init: obtained thread level="<<obtained_thread_level <<
" while asking for thread level="<<opt.thread_level);
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;
91 if (_rheolef_has_init && !finalized()) {
92 boost::mpi::detail::mpi_datatype_cache().clear();
96 void environment::abort(
int errcode)
98 MPI_Abort(MPI_COMM_WORLD, errcode);
100 int environment::max_tag()
104 MPI_Attr_get(MPI_COMM_WORLD, MPI_TAG_UB, &max_tag_value, &found);
105 assert_macro (found != 0,
"MPI_Attr_get: error");
106 return *max_tag_value - _num_reserved_tags;
108 int environment::collectives_tag()
110 return max_tag() + 1;
112 boost::optional<int> environment::host_rank()
116 MPI_Attr_get(MPI_COMM_WORLD, MPI_HOST, &host, &found);
117 if (!found || *host == MPI_PROC_NULL) {
118 return boost::optional<int>();
123 boost::optional<int> environment::io_rank()
127 MPI_Attr_get(MPI_COMM_WORLD, MPI_IO, &io, &found);
128 if (!found || *io == MPI_PROC_NULL) {
129 return boost::optional<int>();
134 std::string environment::processor_name()
136 char name[MPI_MAX_PROCESSOR_NAME];
138 MPI_Get_processor_name(
name, &len);
139 return std::string(
name, len);
environment(int &argc, char **&argv, const environment_option_type &opt=environment_option_type())
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