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