45#ifndef KOKKOS_THREADS_HPP
46#define KOKKOS_THREADS_HPP
48#include <Kokkos_Macros.hpp>
49#if defined(KOKKOS_ENABLE_THREADS)
51#include <Kokkos_Core_fwd.hpp>
55#include <Kokkos_HostSpace.hpp>
56#include <Kokkos_ScratchSpace.hpp>
58#include <Kokkos_MemoryTraits.hpp>
59#include <impl/Kokkos_Profiling_Interface.hpp>
60#include <impl/Kokkos_Tags.hpp>
61#include <impl/Kokkos_ExecSpaceInitializer.hpp>
81 using execution_space = Threads;
85 using device_type = Kokkos::Device<execution_space, memory_space>;
88 using size_type = memory_space::size_type;
90 using scratch_memory_space = ScratchMemorySpace<Threads>;
99 static int in_parallel();
102 static void print_configuration(std::ostream&,
const bool detail =
false);
110 static void impl_static_fence();
115 static int concurrency();
120 static void impl_finalize();
145 static void impl_initialize(
unsigned threads_count = 0,
146 unsigned use_numa_count = 0,
147 unsigned use_cores_per_numa = 0,
148 bool allow_asynchronous_threadpool =
false);
150 static int impl_is_initialized();
152 static Threads& impl_instance(
int = 0);
156 static int impl_thread_pool_size(
int depth = 0);
157#if defined(KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST)
158 static int impl_thread_pool_rank();
160 KOKKOS_INLINE_FUNCTION
static int impl_thread_pool_rank() {
return 0; }
163 inline static unsigned impl_max_hardware_threads() {
164 return impl_thread_pool_size(0);
166 KOKKOS_INLINE_FUNCTION
static unsigned impl_hardware_thread_id() {
167 return impl_thread_pool_rank();
170 uint32_t impl_instance_id() const noexcept {
return 0; }
172 static const char* name();
180struct DeviceTypeTraits<Threads> {
181 static constexpr DeviceType
id = DeviceType::Threads;
188class ThreadsSpaceInitializer :
public ExecSpaceInitializerBase {
190 ThreadsSpaceInitializer() =
default;
191 ~ThreadsSpaceInitializer() =
default;
192 void initialize(
const InitArguments& args)
final;
193 void finalize(
const bool)
final;
195 void print_configuration(std::ostream& msg, const
bool detail) final;
207struct MemorySpaceAccess<Kokkos::Threads::memory_space,
208 Kokkos::Threads::scratch_memory_space> {
209 enum :
bool { assignable =
false };
210 enum :
bool { accessible =
true };
211 enum :
bool { deepcopy =
false };
219#include <Kokkos_ExecPolicy.hpp>
221#include <Threads/Kokkos_ThreadsExec.hpp>
222#include <Threads/Kokkos_ThreadsTeam.hpp>
223#include <Threads/Kokkos_Threads_Parallel.hpp>
225#include <KokkosExp_MDRangePolicy.hpp>
Declaration of various MemoryLayout options.
Declaration of parallel operators.
Memory management for host memory.
Memory layout tag indicating right-to-left (C or lexigraphical scheme) striding of multi-indices.