Skip to content
Snippets Groups Projects
Commit 85e710c1 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Do not initializa Kokkos Arrays anymore

This should improve performances for small Arrays
parent 16afaa96
No related branches found
No related tags found
1 merge request!93Do not initializa Kokkos Arrays anymore
...@@ -85,10 +85,15 @@ class [[nodiscard]] Array ...@@ -85,10 +85,15 @@ class [[nodiscard]] Array
Array& operator=(Array&&) = default; Array& operator=(Array&&) = default;
PUGS_INLINE PUGS_INLINE
explicit Array(size_t size) : m_values("anonymous", size) explicit Array(size_t size)
{ {
static_assert(not std::is_const<DataType>(), "Cannot allocate Array of const data: only view is " static_assert(not std::is_const<DataType>(), "Cannot allocate Array of const data: only view is "
"supported"); "supported");
if constexpr (std::is_arithmetic_v<DataType>) {
m_values = Kokkos::View<DataType*>{Kokkos::view_alloc(Kokkos::WithoutInitializing, "anonymous"), size};
} else {
m_values = Kokkos::View<DataType*>{"anonymous", size};
}
} }
PUGS_INLINE PUGS_INLINE
......
...@@ -99,10 +99,16 @@ class [[nodiscard]] Table ...@@ -99,10 +99,16 @@ class [[nodiscard]] Table
Table& operator=(Table&&) = default; Table& operator=(Table&&) = default;
PUGS_INLINE PUGS_INLINE
explicit Table(size_t nb_lines, size_t nb_columns) : m_values("anonymous", nb_lines, nb_columns) explicit Table(size_t nb_lines, size_t nb_columns)
{ {
static_assert(not std::is_const<DataType>(), "Cannot allocate Table of const data: only view is " static_assert(not std::is_const<DataType>(), "Cannot allocate Table of const data: only view is "
"supported"); "supported");
if constexpr (std::is_arithmetic_v<DataType>) {
m_values =
Kokkos::View<DataType**>{Kokkos::view_alloc(Kokkos::WithoutInitializing, "anonymous"), nb_lines, nb_columns};
} else {
m_values = Kokkos::View<DataType**>{"anonymous", nb_lines, nb_columns};
}
} }
PUGS_INLINE PUGS_INLINE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment