Skip to content

Commit 7f1e6f0

Browse files
committed
BareField: adapt default initialization for named Kokkos Veiws
1 parent b976c40 commit 7f1e6f0

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ include(ProjectSetup)
3030
# ------------------------------------------------------------------------------
3131
# Primary IPPL options
3232
# ------------------------------------------------------------------------------
33-
set(IPPL_PLATFORMS "OPENMP;CUDA" CACHE STRING "Platforms to build IPPL for")
33+
# set(IPPL_PLATFORMS "OPENMP;CUDA" CACHE STRING "Platforms to build IPPL for")
34+
set(IPPL_PLATFORMS "SERIAL" CACHE STRING "Platforms to build IPPL for")
3435
option(BUILD_SHARED_LIBS "Build IPPL as a shared library" OFF)
3536
option(IPPL_ENABLE_UNIT_TESTS "Enable unit tests using GoogleTest" OFF)
3637
option(IPPL_ENABLE_FFT "Enable FFT support" OFF)

src/Field/BareField.hpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,25 @@ namespace ippl {
8383
namespace detail {
8484
template <typename T, unsigned Dim, class... ViewArgs>
8585
struct isExpression<BareField<T, Dim, ViewArgs...>> : std::true_type {};
86+
87+
template <typename view_T, size_t... I>
88+
view_T make_zero_extent_view(const std::string& name, std::index_sequence<I...>) {
89+
// Expands to dview_m(name, 0, 0, ..., 0) with Dim zeros
90+
return view_T(name, ((void)I, 0)...);
91+
}
92+
8693
} // namespace detail
8794

8895
template <typename T, unsigned Dim, class... ViewArgs>
8996
BareField<T, Dim, ViewArgs...>::BareField(const std::string& name_)
9097
: nghost_m(1)
91-
, dview_m(name_)
98+
, dview_m([&]{return detail::make_zero_extent_view(name_, std::make_index_sequence<Dim>{});}())
9299
, layout_m(nullptr) {}
93100

101+
102+
103+
104+
94105
template <typename T, unsigned Dim, class... ViewArgs>
95106
BareField<T, Dim, ViewArgs...> BareField<T, Dim, ViewArgs...>::deepCopy() const {
96107
BareField<T, Dim, ViewArgs...> copy(*layout_m, nghost_m);
@@ -101,7 +112,7 @@ namespace ippl {
101112
template <typename T, unsigned Dim, class... ViewArgs>
102113
BareField<T, Dim, ViewArgs...>::BareField(Layout_t& l, int nghost, const std::string& name_)
103114
: nghost_m(nghost)
104-
, dview_m(name_)
115+
, dview_m([&]{return detail::make_zero_extent_view(name_, std::make_index_sequence<Dim>{});}())
105116
// , owned_m(0)
106117
, layout_m(&l) {
107118
setup();

0 commit comments

Comments
 (0)