Line data Source code
1 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 UtilitiesGroup 17 : * \brief Number of processing elements. 18 : */ 19 1 : inline int number_of_procs() { return CkNumPes(); } 20 : 21 : /*! 22 : * \ingroup UtilitiesGroup 23 : * \brief %Index of my processing element. 24 : */ 25 1 : inline int my_proc() { return CkMyPe(); } 26 : 27 : /*! 28 : * \ingroup UtilitiesGroup 29 : * \brief Number of nodes. 30 : */ 31 1 : inline int number_of_nodes() { return CkNumNodes(); } 32 : 33 : /*! 34 : * \ingroup UtilitiesGroup 35 : * \brief %Index of my node. 36 : */ 37 1 : inline int my_node() { return CkMyNode(); } 38 : 39 : /*! 40 : * \ingroup UtilitiesGroup 41 : * \brief Number of processing elements on the given node. 42 : */ 43 1 : 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 UtilitiesGroup 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 1 : inline int my_local_rank() { return CkMyRank(); } 62 : 63 : /*! 64 : * \ingroup UtilitiesGroup 65 : * \brief %Index of first processing element on the given node. 66 : */ 67 1 : 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 UtilitiesGroup 74 : * \brief %Index of the node for the given processing element. 75 : */ 76 1 : inline int node_of(const int proc_index) { 77 : static_cast<void>(proc_index); 78 : return CkNodeOf(proc_index); 79 : } 80 : 81 : /*! 82 : * \ingroup UtilitiesGroup 83 : * \brief The local index for the given processing element on its node. 84 : */ 85 1 : 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 UtilitiesGroup 92 : * \brief The elapsed wall time in seconds. 93 : */ 94 1 : inline double wall_time() { return CkWallTimer(); } 95 : } // namespace sys