Skip to content

Commit

Permalink
Forbid BitPackedIntSoA with runtime bits and no initialization
Browse files Browse the repository at this point in the history
This uncovered missing initializations in some tests.
  • Loading branch information
bernhardmgruber committed Sep 14, 2022
1 parent 9d6a1eb commit a6a4da3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
13 changes: 10 additions & 3 deletions include/llama/mapping/BitPackedIntSoA.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,21 @@ namespace llama::mapping
public:
static constexpr std::size_t blobCount = boost::mp11::mp_size<FlatRecordDim<TRecordDim>>::value;

using Base::Base;

template<typename B = Bits, std::enable_if_t<isConstant<B>, int> = 0>
LLAMA_FN_HOST_ACC_INLINE constexpr explicit BitPackedIntSoA(
TArrayExtents extents,
TArrayExtents extents = {},
Bits bits = {},
TRecordDim = {})
: Base(extents)
, VHBits{bits}
{
static_assert(VHBits::value() > 0);
}

template<typename B = Bits, std::enable_if_t<!isConstant<B>, int> = 0>
LLAMA_FN_HOST_ACC_INLINE constexpr explicit BitPackedIntSoA(TArrayExtents extents, Bits bits, TRecordDim = {})
: Base(extents)
, VHBits{bits}
{
assert(VHBits::value() > 0);
}
Expand Down
9 changes: 6 additions & 3 deletions tests/recordref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,8 @@ TEST_CASE("RecordRef.load.constref")

TEST_CASE("RecordRef.load.value.fromproxyref")
{
auto view = llama::allocView(llama::mapping::BitPackedIntSoA<llama::ArrayExtents<int, 1>, ParticleInt>{});
auto view = llama::allocView(
llama::mapping::BitPackedIntSoA<llama::ArrayExtents<int, 1>, ParticleInt, llama::Constant<14>>{});
auto&& record = view(0);
record = 1;

Expand Down Expand Up @@ -868,7 +869,8 @@ TEST_CASE("RecordRef.store")

TEST_CASE("RecordRef.store.toproxyref")
{
auto view = llama::allocView(llama::mapping::BitPackedIntSoA<llama::ArrayExtents<int, 1>, ParticleInt>{});
auto view = llama::allocView(
llama::mapping::BitPackedIntSoA<llama::ArrayExtents<int, 1>, ParticleInt, llama::Constant<14>>{});
auto&& record = view(0);

record = 1;
Expand Down Expand Up @@ -951,7 +953,8 @@ TEST_CASE("RecordRef.loadAs.constref")

TEST_CASE("RecordRef.loadAs.value.fromproxyref")
{
auto view = llama::allocView(llama::mapping::BitPackedIntSoA<llama::ArrayExtents<int, 1>, ParticleInt>{});
auto view = llama::allocView(
llama::mapping::BitPackedIntSoA<llama::ArrayExtents<int, 1>, ParticleInt, llama::Constant<14>>{});
auto&& record = view(0);
record = 1;

Expand Down

0 comments on commit a6a4da3

Please sign in to comment.