ParallelInfo.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 /// \file
5 /// Defines functions that provide low-level system information such as number
6 /// of nodes and processors.
7 
8 #pragma once
9 
10 #include <charm++.h>
11 
12 namespace sys {
13 /*!
14  * \ingroup SystemUtilitiesGroup
15  * \brief Number of processing elements.
16  */
17 inline int number_of_procs() { return CkNumPes(); }
18 
19 /*!
20  * \ingroup SystemUtilitiesGroup
21  * \brief %Index of my processing element.
22  */
23 inline int my_proc() { return CkMyPe(); }
24 
25 /*!
26  * \ingroup SystemUtilitiesGroup
27  * \brief Number of nodes.
28  */
29 inline int number_of_nodes() { return CkNumNodes(); }
30 
31 /*!
32  * \ingroup SystemUtilitiesGroup
33  * \brief %Index of my node.
34  */
35 inline int my_node() { return CkMyNode(); }
36 
37 /*!
38  * \ingroup SystemUtilitiesGroup
39  * \brief Number of processing elements on the given node.
40  */
41 inline int procs_on_node(const int node_index) {
42  // When using the verbs-linux-x86_64 non-SMP build of Charm++ these
43  // functions have unused-parameter warnings. This is remedied by
44  // casting the integer to a void which results in no extra assembly
45  // code being generated. We use this instead of pragmas because we
46  // would require one pragma for GCC and one for clang, which would
47  // result in code duplication. Commenting out the variable
48  // nodeIndex gives compilation failures on most Charm++ builds since
49  // they actually use the variable. Charm++ plz...
50  static_cast<void>(node_index);
51  return CkNodeSize(node_index);
52 }
53 
54 /*!
55  * \ingroup SystemUtilitiesGroup
56  * \brief The local index of my processing element on my node.
57  * This is in the interval 0, ..., procs_on_node(my_node()) - 1.
58  */
59 inline int my_local_rank() { return CkMyRank(); }
60 
61 /*!
62  * \ingroup SystemUtilitiesGroup
63  * \brief %Index of first processing element on the given node.
64  */
65 inline int first_proc_on_node(const int node_index) {
66  static_cast<void>(node_index);
67  return CkNodeFirst(node_index);
68 }
69 
70 /*!
71  * \ingroup SystemUtilitiesGroup
72  * \brief %Index of the node for the given processing element.
73  */
74 inline int node_of(const int proc_index) {
75  static_cast<void>(proc_index);
76  return CkNodeOf(proc_index);
77 }
78 
79 /*!
80  * \ingroup SystemUtilitiesGroup
81  * \brief The local index for the given processing element on its node.
82  */
83 inline int local_rank_of(const int proc_index) {
84  static_cast<void>(proc_index);
85  return CkRankOf(proc_index);
86 }
87 
88 /*!
89  * \ingroup SystemUtilitiesGroup
90  * \brief The current wall time in seconds
91  */
92 inline double wall_time() { return CmiWallTimer(); }
93 } // namespace sys
sys::procs_on_node
int procs_on_node(const int node_index)
Number of processing elements on the given node.
Definition: ParallelInfo.hpp:41
sys::number_of_nodes
int number_of_nodes()
Number of nodes.
Definition: ParallelInfo.hpp:29
sys::my_node
int my_node()
Index of my node.
Definition: ParallelInfo.hpp:35
sys::first_proc_on_node
int first_proc_on_node(const int node_index)
Index of first processing element on the given node.
Definition: ParallelInfo.hpp:65
sys::my_local_rank
int my_local_rank()
The local index of my processing element on my node. This is in the interval 0, .....
Definition: ParallelInfo.hpp:59
sys::local_rank_of
int local_rank_of(const int proc_index)
The local index for the given processing element on its node.
Definition: ParallelInfo.hpp:83
sys::wall_time
double wall_time()
The current wall time in seconds.
Definition: ParallelInfo.hpp:92
sys::node_of
int node_of(const int proc_index)
Index of the node for the given processing element.
Definition: ParallelInfo.hpp:74
sys::number_of_procs
int number_of_procs()
Number of processing elements.
Definition: ParallelInfo.hpp:17
sys::my_proc
int my_proc()
Index of my processing element.
Definition: ParallelInfo.hpp:23