Low-Level Abstraction of Memory Access
Null.hpp
Go to the documentation of this file.
1 // Copyright 2022 Bernhard Manfred Gruber
2 // SPDX-License-Identifier: MPL-2.0
3 
4 #pragma once
5 
6 #include "../ProxyRefOpMixin.hpp"
7 
8 namespace llama::mapping
9 {
10  namespace internal
11  {
12  template<typename T>
13  struct NullReference : ProxyRefOpMixin<NullReference<T>, T>
14  {
15  using value_type = T;
16 
17  // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions)
18  LLAMA_FN_HOST_ACC_INLINE constexpr operator T() const
19  {
20  return T{}; // this might not be the best design decision
21  }
22 
24  {
25  return *this;
26  }
27  };
28  } // namespace internal
29 
33  template<typename TArrayExtents, typename TRecordDim>
34  struct Null : MappingBase<TArrayExtents, TRecordDim>
35  {
36  private:
38  using size_type = typename TArrayExtents::value_type;
39 
40  public:
41  static constexpr std::size_t blobCount = 0;
42 
43  using Base::Base;
44 
46  constexpr auto blobSize(size_type /*blobIndex*/) const -> size_type
47  {
48  return 0;
49  }
50 
51  template<std::size_t... RecordCoords>
53  {
54  return true;
55  }
56 
57  template<std::size_t... RecordCoords, typename Blobs>
59  typename Base::ArrayIndex,
61  Blobs&) const
62  {
63  using FieldType = GetType<TRecordDim, RecordCoord<RecordCoords...>>;
65  }
66  };
67 
69  template<typename Mapping>
70  inline constexpr bool isNull = false;
71 
73  template<typename ArrayExtents, typename RecordDim>
74  inline constexpr bool isNull<Null<ArrayExtents, RecordDim>> = true;
75 } // namespace llama::mapping
#define LLAMA_EXPORT
Definition: macros.hpp:192
#define LLAMA_FN_HOST_ACC_INLINE
Definition: macros.hpp:96
constexpr bool isNull
Definition: Null.hpp:70
typename internal::GetTypeImpl< RecordDim, RecordCoordOrTags... >::type GetType
Definition: Core.hpp:388
CRTP mixin for proxy reference types to support all compound assignment and increment/decrement opera...
typename ArrayExtents::value_type size_type
Definition: Common.hpp:25
typename ArrayExtents::Index ArrayIndex
Definition: Common.hpp:24
constexpr auto blobSize(size_type) const -> size_type
Definition: Null.hpp:46
constexpr auto compute(typename Base::ArrayIndex, RecordCoord< RecordCoords... >, Blobs &) const
Definition: Null.hpp:58
static constexpr auto isComputed(RecordCoord< RecordCoords... >)
Definition: Null.hpp:52
static constexpr std::size_t blobCount
Definition: Null.hpp:41
constexpr auto operator=(T) -> NullReference &
Definition: Null.hpp:23