Kokkos Core Kernels Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Kokkos_hwloc.hpp
1 //@HEADER
2 // ************************************************************************
3 //
4 // Kokkos v. 4.0
5 // Copyright (2022) National Technology & Engineering
6 // Solutions of Sandia, LLC (NTESS).
7 //
8 // Under the terms of Contract DE-NA0003525 with NTESS,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12 // See https://kokkos.org/LICENSE for license information.
13 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //
15 //@HEADER
16 
17 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
18 #include <Kokkos_Macros.hpp>
19 static_assert(false,
20  "Including non-public Kokkos header files is not allowed.");
21 #endif
22 #ifndef KOKKOS_HWLOC_HPP
23 #define KOKKOS_HWLOC_HPP
24 
25 #include <Kokkos_Macros.hpp>
26 
27 #include <utility>
28 
29 namespace Kokkos {
30 
43 namespace hwloc {
44 
46 bool available();
47 
52 unsigned get_available_numa_count();
53 
59 
63 
64 } /* namespace hwloc */
65 } /* namespace Kokkos */
66 
67 //----------------------------------------------------------------------------
68 //----------------------------------------------------------------------------
69 // Internal functions for binding persistent spawned threads.
70 
71 namespace Kokkos {
72 namespace hwloc {
73 
83 unsigned thread_mapping(const char* const label, const bool allow_async,
84  unsigned& thread_count, unsigned& use_numa_count,
85  unsigned& use_cores_per_numa,
86  std::pair<unsigned, unsigned> threads_coord[]);
87 
97 std::pair<unsigned, unsigned> get_this_thread_coordinate();
98 
100 bool bind_this_thread(const std::pair<unsigned, unsigned>);
101 
103 bool can_bind_threads();
104 
109 unsigned bind_this_thread(const unsigned coordinate_count,
110  std::pair<unsigned, unsigned> coordinate[]);
111 
113 bool unbind_this_thread();
114 
115 } /* namespace hwloc */
116 } /* namespace Kokkos */
117 
118 //----------------------------------------------------------------------------
119 //----------------------------------------------------------------------------
120 
121 #endif /* #define KOKKOS_HWLOC_HPP */
bool bind_this_thread(const std::pair< unsigned, unsigned >)
Bind the current thread to a core.
bool can_bind_threads()
Can hwloc bind threads?
unsigned get_available_cores_per_numa()
Query number of available cores per NUMA regions. This will be less than the hardware capacity if the...
unsigned get_available_threads_per_core()
Query number of available &quot;hard&quot; threads per core; i.e., hyperthreads.
unsigned get_available_numa_count()
Query number of available NUMA regions. This will be less than the hardware capacity if the MPI proce...
std::pair< unsigned, unsigned > get_this_thread_coordinate()
Query core-coordinate of the current thread with respect to the core_topology.
bool unbind_this_thread()
Unbind the current thread back to the original process binding.
unsigned thread_mapping(const char *const label, const bool allow_async, unsigned &thread_count, unsigned &use_numa_count, unsigned &use_cores_per_numa, std::pair< unsigned, unsigned > threads_coord[])
Recommend mapping of threads onto cores.
bool available()
Query if hwloc is available.