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