libMesh
parallel_only.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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 // TIMPI includes
23 #include <timpi/communicator.h>
24 
25 // C++ includes
26 #include <string>
27 
28 // Macro to identify and debug functions which should only be called in
29 // parallel on every processor at once
30 
31 #ifdef LIBMESH_ENABLE_DEPRECATED
32 #undef parallel_only
33 #ifndef NDEBUG
34 #define parallel_only() do { \
35  libmesh_deprecated(); \
36  libmesh_assert(CommWorld.verify(std::string(__FILE__))); \
37  libmesh_assert(CommWorld.verify(std::to_string(__LINE__))); } while (0)
38 #else
39 #define parallel_only() ((void) 0)
40 #endif
41 #endif
42 
43 #undef libmesh_parallel_only
44 #ifndef NDEBUG
45 #define libmesh_parallel_only(comm_obj) do { \
46  libmesh_assert((comm_obj).verify(std::string(__FILE__))); \
47  libmesh_assert((comm_obj).verify(std::to_string(__LINE__))); } while (0)
48 #else
49 #define libmesh_parallel_only(comm_obj) ((void) 0)
50 #endif
51 
52 // Macro to identify and debug functions which should only be called in
53 // parallel on every processor at once
54 
55 #ifdef LIBMESH_ENABLE_DEPRECATED
56 #undef parallel_only_on
57 #ifndef NDEBUG
58 #define parallel_only_on(comm_arg) do { \
59  libmesh_deprecated(); \
60  libmesh_assert(CommWorld.verify(std::string(__FILE__), comm_arg)); \
61  libmesh_assert(CommWorld.verify(std::to_string(__LINE__), comm_arg)); } while (0)
62 #else
63 #define parallel_only_on(comm_arg) ((void) 0)
64 #endif
65 #endif
66 
67 #undef libmesh_parallel_only_on
68 #ifndef NDEBUG
69 #define libmesh_parallel_only_on(comm_obj,comm_arg) do { \
70  libmesh_assert(comm_obj.verify(std::string(__FILE__), comm_arg)); \
71  libmesh_assert(comm_obj.verify(std::to_string(__LINE__), comm_arg)); } while (0)
72 #else
73 #define libmesh_parallel_only_on(comm_obj,comm_arg) ((void) 0)
74 #endif
75 
76 #endif // LIBMESH_PARALLEL_ONLY_H
communicator.h