libMesh
Loading...
Searching...
No Matches
parallel_only.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_PARALLEL_ONLY_H
20#define LIBMESH_PARALLEL_ONLY_H
21
22#ifndef NDEBUG
23// TIMPI includes
24#include <timpi/communicator.h>
26
27// C++ includes
28#include <string>
29#endif // !NDEBUG
30
31// Macro to identify and debug functions which should only be called in
32// parallel on every processor at once
33
34#undef libmesh_parallel_only
35#undef libmesh_exceptionless_parallel_only
36#ifndef NDEBUG
37#define libmesh_parallel_only(comm_obj) do { \
38 libmesh_assert_msg((comm_obj).verify(std::string(__FILE__).length()), \
39 "Different ranks are at different libmesh_parallel_only points"); \
40 libmesh_assert_msg((comm_obj).verify(std::string(__FILE__)), \
41 "Different ranks are at different libmesh_parallel_only points"); \
42 libmesh_assert_msg((comm_obj).verify(std::to_string(__LINE__)), \
43 "Different ranks are at different libmesh_parallel_only points"); \
44 } while (0)
45#define libmesh_exceptionless_parallel_only(comm_obj) do { \
46 libmesh_exceptionless_assert_msg((comm_obj).verify(std::string(__FILE__).length()), \
47 "Different ranks are at different libmesh_exceptionless_parallel_only points"); \
48 libmesh_exceptionless_assert_msg((comm_obj).verify(std::string(__FILE__)), \
49 "Different ranks are at different libmesh_exceptionless_parallel_only points"); \
50 libmesh_exceptionless_assert_msg((comm_obj).verify(std::to_string(__LINE__)), \
51 "Different ranks are at different libmesh_exceptionless_parallel_only points"); \
52 } while (0)
53#else
54#define libmesh_parallel_only(comm_obj) ((void) 0)
55#define libmesh_exceptionless_parallel_only(comm_obj) ((void) 0)
56#endif
57
58// Macro to identify and debug functions which should only be called in
59// parallel on every processor at once
60
61#undef libmesh_parallel_only_on
62#ifndef NDEBUG
63#define libmesh_parallel_only_on(comm_obj,comm_arg) do { \
64 libmesh_assert(comm_obj.verify(std::string(__FILE__), comm_arg)); \
65 libmesh_assert(comm_obj.verify(std::to_string(__LINE__), comm_arg)); } while (0)
66#else
67#define libmesh_parallel_only_on(comm_obj,comm_arg) ((void) 0)
68#endif
69
70#endif // LIBMESH_PARALLEL_ONLY_H