NeoN
A framework for CFD software
Loading...
Searching...
No Matches
CPUExecutor.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2023 - 2025 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
9#include <Kokkos_Core.hpp> // IWYU pragma: keep
10
11namespace NeoN
12{
13
22{
23public:
24
25 using exec = Kokkos::DefaultHostExecutionSpace;
26
29
30 template<typename T>
31 T* alloc(size_t size) const
32 {
33 return static_cast<T*>(Kokkos::kokkos_malloc<exec>("Vector", size * sizeof(T)));
34 }
35
36 template<typename T>
37 T* realloc(void* ptr, size_t newSize) const
38 {
39 return static_cast<T*>(Kokkos::kokkos_realloc<exec>(ptr, newSize * sizeof(T)));
40 }
41
42 void* alloc(size_t size) const { return Kokkos::kokkos_malloc<exec>("Vector", size); }
43
44 void* realloc(void* ptr, size_t newSize) const
45 {
46 return Kokkos::kokkos_realloc<exec>(ptr, newSize);
47 }
48
56 template<typename ValueType>
57 decltype(auto) createKokkosView(ValueType* ptr, size_t size) const
58 {
59 return Kokkos::View<ValueType*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>(ptr, size);
60 }
61
62 void free(void* ptr) const noexcept { Kokkos::kokkos_free<exec>(ptr); };
63
64 std::string name() const { return "CPUExecutor"; };
65
66 exec underlyingExec() const { return exec {}; }
67};
68
69} // namespace NeoN
Executor for handling multicore CPU based parallelization.
exec underlyingExec() const
decltype(auto) createKokkosView(ValueType *ptr, size_t size) const
create a Kokkos view for a given ptr
T * realloc(void *ptr, size_t newSize) const
T * alloc(size_t size) const
Kokkos::DefaultHostExecutionSpace exec
std::string name() const
void free(void *ptr) const noexcept
void * alloc(size_t size) const
void * realloc(void *ptr, size_t newSize) const
Definition array.hpp:20