MUDA
Loading...
Searching...
No Matches
field_entry_layout.h
1#pragma once
2#include <cinttypes>
3#include <muda/muda_def.h>
4#include <muda/tools/debug_log.h>
5namespace muda
6{
7enum class FieldEntryLayout
8{
9 None,
10 // Array of Struct
11 AoS,
12 // Struct of Array
13 SoA,
14 // Array of Struct of Array
15 // The innermost Array must be fixed size
16 // e.g. size = 32 (warp size)
17 AoSoA,
18
19 // the layout is not known at compile time
20 RuntimeLayout,
21};
22
24{
25 using Layout = FieldEntryLayout;
26
27 public:
28 MUDA_GENERIC auto layout() const MUDA_NOEXCEPT { return m_layout; }
29 MUDA_GENERIC auto innermost_array_size() const MUDA_NOEXCEPT
30 {
31 return m_innermost_array_size;
32 }
33
34 MUDA_GENERIC FieldEntryLayoutInfo(Layout layout, uint32_t innermost_array_size = 32) MUDA_NOEXCEPT
35 : m_layout(layout),
36 m_innermost_array_size(layout == Layout::AoSoA ? innermost_array_size : 0)
37 {
38 MUDA_ASSERT(layout != Layout::RuntimeLayout,
39 "RuntimeLayout is not allowed to use when constructing FieldEntryLayoutInfo, because it's meaningless."
40 "RuntimeLayout is only used in template argument.");
41
42 MUDA_ASSERT((innermost_array_size & (innermost_array_size - 1)) == 0,
43 "innermost_array_size must be power of 2");
44 }
45
46 MUDA_GENERIC FieldEntryLayoutInfo() MUDA_NOEXCEPT {}
47
48 private:
49 Layout m_layout = Layout::AoSoA;
50 uint32_t m_innermost_array_size = 32;
51};
52} // namespace muda
Definition field_entry_layout.h:24