45 #ifndef KOKKOS_CORE_HPP 46 #define KOKKOS_CORE_HPP 51 #include <Kokkos_Core_fwd.hpp> 55 #include <Kokkos_Half.hpp> 56 #include <KokkosCore_Config_DeclareBackend.hpp> 58 #include <Kokkos_AnonymousSpace.hpp> 59 #include <Kokkos_LogicalSpaces.hpp> 61 #include <Kokkos_MathematicalFunctions.hpp> 62 #include <Kokkos_MemoryPool.hpp> 63 #include <Kokkos_Array.hpp> 64 #include <Kokkos_View.hpp> 67 #include <Kokkos_hwloc.hpp> 68 #include <Kokkos_Timer.hpp> 69 #include <Kokkos_Tuners.hpp> 70 #include <Kokkos_TaskScheduler.hpp> 71 #include <Kokkos_Complex.hpp> 72 #include <Kokkos_CopyViews.hpp> 82 struct InitArguments {
88 bool disable_warnings;
90 bool tool_help =
false;
91 std::string tool_lib = {};
92 std::string tool_args = {};
94 InitArguments(
int nt = -1,
int nn = -1,
int dv = -1,
bool dw =
false,
101 disable_warnings{dw},
102 tune_internals{ti} {}
112 class ExecSpaceManager {
113 std::map<std::string, std::unique_ptr<ExecSpaceInitializerBase>>
114 exec_space_factory_list;
117 ExecSpaceManager() =
default;
119 void register_space_factory(std::string name,
120 std::unique_ptr<ExecSpaceInitializerBase> ptr);
121 void initialize_spaces(
const Kokkos::InitArguments& args);
122 void finalize_spaces(
const bool all_spaces);
124 void print_configuration(std::ostream& msg,
const bool detail);
125 static ExecSpaceManager& get_instance();
128 template <
class SpaceInitializerType>
129 int initialize_space_factory(std::string name) {
130 auto space_ptr = std::make_unique<SpaceInitializerType>();
131 ExecSpaceManager::get_instance().register_space_factory(name,
132 std::move(space_ptr));
137 void initialize(
int& narg,
char* arg[]);
139 void initialize(InitArguments args = InitArguments());
143 void pre_initialize(
const InitArguments& args);
145 void post_initialize(
const InitArguments& args);
147 void declare_configuration_metadata(
const std::string& category,
148 const std::string& key,
149 const std::string& value);
153 bool is_initialized() noexcept;
155 bool show_warnings() noexcept;
156 bool tune_internals() noexcept;
181 void push_finalize_hook(std::function<
void()> f);
189 void print_configuration(std::ostream&, const
bool detail = false);
202 template <
class Space =
typename Kokkos::DefaultExecutionSpace::memory_space>
203 inline void* kokkos_malloc(
const std::string& arg_alloc_label,
204 const size_t arg_alloc_size) {
205 using MemorySpace =
typename Space::memory_space;
206 return Impl::SharedAllocationRecord<MemorySpace>::allocate_tracked(
207 MemorySpace(), arg_alloc_label, arg_alloc_size);
210 template <
class Space =
typename Kokkos::DefaultExecutionSpace::memory_space>
211 inline void* kokkos_malloc(
const size_t arg_alloc_size) {
212 using MemorySpace =
typename Space::memory_space;
213 return Impl::SharedAllocationRecord<MemorySpace>::allocate_tracked(
214 MemorySpace(),
"no-label", arg_alloc_size);
217 template <
class Space =
typename Kokkos::DefaultExecutionSpace::memory_space>
218 inline void kokkos_free(
void* arg_alloc) {
219 using MemorySpace =
typename Space::memory_space;
220 return Impl::SharedAllocationRecord<MemorySpace>::deallocate_tracked(
224 template <
class Space =
typename Kokkos::DefaultExecutionSpace::memory_space>
225 inline void* kokkos_realloc(
void* arg_alloc,
const size_t arg_alloc_size) {
226 using MemorySpace =
typename Space::memory_space;
227 return Impl::SharedAllocationRecord<MemorySpace>::reallocate_tracked(
228 arg_alloc, arg_alloc_size);
248 if (!Kokkos::is_initialized()) {
249 initialize(narg, arg);
254 ScopeGuard(
const InitArguments& args = InitArguments()) {
256 if (!Kokkos::is_initialized()) {
263 if (Kokkos::is_initialized() && sg_init) {
277 #include <Kokkos_Crs.hpp> 278 #include <Kokkos_WorkGraphPolicy.hpp> 283 #include <impl/Kokkos_Combined_Reducer.hpp> 286 #include <Kokkos_AcquireUniqueTokenImpl.hpp> 289 #include <KokkosCore_Config_PostInclude.hpp> Declaration and definition of Kokkos::Vectorization interface.
Declaration and definition of Kokkos::pair.
ScopeGuard Some user scope issues have been identified with some Kokkos::finalize calls; ScopeGuard a...