NeoN
A framework for CFD software
Loading...
Searching...
No Matches
GPUExecutor.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>
10
11namespace NeoN
12{
13
21{
22public:
23
24 using exec = Kokkos::DefaultExecutionSpace;
25
28
29 template<typename T>
30 T* alloc(size_t size) const
31 {
32 return static_cast<T*>(Kokkos::kokkos_malloc<exec>("Vector", size * sizeof(T)));
33 }
34
35 template<typename T>
36 T* realloc(void* ptr, size_t newSize) const
37 {
38 return static_cast<T*>(Kokkos::kokkos_realloc<exec>(ptr, newSize * sizeof(T)));
39 }
40
48 template<typename ValueType>
49 decltype(auto) createKokkosView(ValueType* ptr, size_t size) const
50 {
51 return Kokkos::View<ValueType*, Kokkos::DefaultExecutionSpace, Kokkos::MemoryUnmanaged>(
52 ptr, size
53 );
54 }
55
56 void* alloc(size_t size) const { return Kokkos::kokkos_malloc<exec>("Vector", size); }
57
58 void* realloc(void* ptr, size_t newSize) const
59 {
60 return Kokkos::kokkos_realloc<exec>(ptr, newSize);
61 }
62
63 void free(void* ptr) const noexcept { Kokkos::kokkos_free<exec>(ptr); }
64
65 std::string name() const { return "GPUExecutor"; };
66
67 exec underlyingExec() const { return exec {}; }
68};
69
70} // namespace NeoN
Executor for GPU offloading.
void * alloc(size_t size) const
T * alloc(size_t size) const
Kokkos::DefaultExecutionSpace exec
T * realloc(void *ptr, size_t newSize) const
decltype(auto) createKokkosView(ValueType *ptr, size_t size) const
create a Kokkos view for a given ptr
exec underlyingExec() const
void * realloc(void *ptr, size_t newSize) const
void free(void *ptr) const noexcept
std::string name() const
Definition array.hpp:20