libMesh
Loading...
Searching...
No Matches
libmesh_call_mpi.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19#ifndef LIBMESH_CALL_MPI_H
20#define LIBMESH_CALL_MPI_H
21
22// libMesh Includes
23#include "libmesh/libmesh_common.h"
24
25#ifdef LIBMESH_HAVE_MPI
26
30#define libmesh_mpi_var(var) var
31
35#ifndef NDEBUG
36#define libmesh_assert_mpi_success(error_code) \
37 do \
38 { \
39 if (error_code != MPI_SUCCESS) \
40 { \
41 char libmesh_mpi_error_string[MPI_MAX_ERROR_STRING+1]; \
42 int libmesh_mpi_error_string_len; \
43 MPI_Error_string(error_code, libmesh_mpi_error_string, \
44 &libmesh_mpi_error_string_len); \
45 libmesh_assert_equal_to_msg(error_code, MPI_SUCCESS, \
46 libmesh_mpi_error_string); \
47 } \
48 } \
49 while (0)
50
51#else
52
53#define libmesh_assert_mpi_success(error_code) ((void) 0)
54
55#endif
56
57
58
59// Only catch MPI return values when asserts are active.
60#ifndef NDEBUG
61#define libmesh_call_mpi(mpi_call) \
62 do \
63 { \
64 unsigned int libmesh_mpi_error_code = mpi_call; \
65 libmesh_assert_mpi_success (libmesh_mpi_error_code); \
66 } \
67 while (0)
68
69#else
70
71#define libmesh_call_mpi(mpi_call) \
72 do \
73 { \
74 mpi_call; \
75 } \
76 while (0)
77#endif
78
79#else // LIBMESH_HAVE_MPI
80
81#define libmesh_mpi_var(var)
82
83#define libmesh_call_mpi(mpi_call) \
84 do {} \
85 while (0)
86
87#endif // LIBMESH_HAVE_MPI
88
89
90#endif // LIBMESH_CALL_MPI_H