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
7#include <Kokkos_Core.hpp> // IWYU pragma: keep
8
9namespace NeoN
10{
11
20{
21public:
22
23 using exec = Kokkos::DefaultHostExecutionSpace;
24
27
28 template<typename T>
29 T* alloc(size_t size) const
30 {
31 return static_cast<T*>(Kokkos::kokkos_malloc<exec>("Vector", size * sizeof(T)));
32 }
33
34 template<typename T>
35 T* realloc(void* ptr, size_t newSize) const
36 {
37 return static_cast<T*>(Kokkos::kokkos_realloc<exec>(ptr, newSize * sizeof(T)));
38 }
39
40 void* alloc(size_t size) const { return Kokkos::kokkos_malloc<exec>("Vector", size); }
41
42 void* realloc(void* ptr, size_t newSize) const
43 {
44 return Kokkos::kokkos_realloc<exec>(ptr, newSize);
45 }
46
54 template<typename ValueType>
55 decltype(auto) createKokkosView(ValueType* ptr, size_t size) const
56 {
57 return Kokkos::View<ValueType*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>(ptr, size);
58 }
59
60 void free(void* ptr) const noexcept { Kokkos::kokkos_free<exec>(ptr); };
61
62 std::string name() const { return "CPUExecutor"; };
63
64 exec underlyingExec() const { return exec {}; }
65};
66
67} // 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