TIMPI
Loading...
Searching...
No Matches
timpi_call_mpi.h
Go to the documentation of this file.
1// The TIMPI Message-Passing Parallelism Library.
2// Copyright (C) 2002-2025 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 TIMPI_CALL_MPI_H
20#define TIMPI_CALL_MPI_H
21
22// TIMPI includes
23#include "timpi/timpi_assert.h"
24#include "timpi/timpi_config.h"
25
26// C/C++ includes
27#ifdef TIMPI_HAVE_MPI
29# include "mpi.h"
31
35#define timpi_mpi_var(var) var
36
40#ifndef NDEBUG
41#define timpi_assert_mpi_success(error_code) \
42 do \
43 { \
44 if (error_code != MPI_SUCCESS) \
45 { \
46 char timpi_mpi_error_string[MPI_MAX_ERROR_STRING+1]; \
47 int timpi_mpi_error_string_len; \
48 MPI_Error_string(error_code, timpi_mpi_error_string, \
49 &timpi_mpi_error_string_len); \
50 timpi_assert_equal_to_msg(error_code, MPI_SUCCESS, \
51 timpi_mpi_error_string); \
52 } \
53 } \
54 while (0)
55
56#else
57
58#define timpi_assert_mpi_success(error_code) ((void) 0)
59
60#endif
61
62
63
64// Only catch MPI return values when asserts are active.
65#ifndef NDEBUG
66#define timpi_call_mpi(mpi_call) \
67 do \
68 { \
69 int timpi_mpi_error_code = mpi_call; \
70 timpi_assert_mpi_success (timpi_mpi_error_code); \
71 } \
72 while (0)
73
74#else
75
76#define timpi_call_mpi(mpi_call) \
77 do \
78 { \
79 mpi_call; \
80 } \
81 while (0)
82#endif
83
84#else // TIMPI_HAVE_MPI
85
86#define timpi_mpi_var(var)
87
88#define timpi_call_mpi(mpi_call) \
89 do {} \
90 while (0)
91
92#endif // TIMPI_HAVE_MPI
93
94
95#endif // TIMPI_CALL_MPI_H