NeoN
A framework for CFD software
Loading...
Searching...
No Matches
serialExecutor.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>
8
9namespace NeoN
10{
11
19{
20public:
21
22 using exec = Kokkos::Serial;
23
26
27 template<typename T>
28 T* alloc(size_t size) const
29 {
30 return static_cast<T*>(Kokkos::kokkos_malloc<exec>("Vector", size * sizeof(T)));
31 }
32
33 template<typename T>
34 T* realloc(void* ptr, size_t newSize) const
35 {
36 return static_cast<T*>(Kokkos::kokkos_realloc<exec>(ptr, newSize * sizeof(T)));
37 }
38
46 template<typename ValueType>
47 decltype(auto) createKokkosView(ValueType* ptr, size_t size) const
48 {
49 return Kokkos::View<ValueType*, Kokkos::HostSpace, Kokkos::MemoryUnmanaged>(ptr, size);
50 }
51
52 void* alloc(size_t size) const { return Kokkos::kokkos_malloc<exec>("Vector", size); }
53
54 void* realloc(void* ptr, size_t newSize) const
55 {
56 return Kokkos::kokkos_realloc<exec>(ptr, newSize);
57 }
58
59 void free(void* ptr) const noexcept { Kokkos::kokkos_free<exec>(ptr); };
60
61 std::string name() const { return "SerialExecutor"; };
62
63 exec underlyingExec() const { return exec {}; }
64};
65
66} // namespace NeoN
Reference executor for serial CPU execution.
void * realloc(void *ptr, size_t newSize) const
void free(void *ptr) const noexcept
T * alloc(size_t size) const
decltype(auto) createKokkosView(ValueType *ptr, size_t size) const
create a Kokkos view for a given ptr
void * alloc(size_t size) const
T * realloc(void *ptr, size_t newSize) const
std::string name() const
exec underlyingExec() const
Definition array.hpp:20