3MUDA_INLINE
void SubFieldImpl<FieldEntryLayout::SoA>::build_impl()
5 auto min_alignment = build_options().min_alignment;
6 auto max_alignment = build_options().max_alignment;
8 auto base_array_size = max_alignment;
24 uint32_t struct_stride = 0;
25 for(
auto& e : m_entries)
28 auto elem_byte_size = e->elem_byte_size();
31 auto elem_count = e->shape().x * e->shape().y;
32 struct_stride = align(struct_stride, elem_byte_size, min_alignment, max_alignment);
33 auto total_elem_count_in_base_array = e->shape().x * e->shape().y * base_array_size;
35 e->m_core.m_info.offset_in_base_struct = struct_stride;
36 struct_stride += elem_byte_size * total_elem_count_in_base_array;
39 MUDA_ASSERT(struct_stride % base_array_size == 0,
40 "m_struct_stride should be multiple of base_array_size");
42 m_base_struct_stride = struct_stride;
44 m_h_copy_map_buffer.reserve(4 * m_entries.size());
45 for(
size_t i = 0; i < m_entries.size(); ++i)
47 auto& e = m_entries[i];
48 e->m_core.m_info.struct_stride = m_struct_stride;
49 auto btye_in_base_array = e->elem_byte_size() * max_alignment;
50 auto first_comp_offset_in_base_struct =
51 e->m_core.m_info.offset_in_base_struct;
52 auto comp_count = e->shape().x * e->shape().y;
53 for(
int i = 0; i < comp_count; ++i)
55 details::SoACopyMap copy_map;
56 copy_map.offset_in_base_struct =
57 first_comp_offset_in_base_struct + i * btye_in_base_array;
58 copy_map.elem_byte_size = e->elem_byte_size();
59 m_h_copy_map_buffer.push_back(copy_map);
63 m_copy_map_buffer = m_h_copy_map_buffer;
115MUDA_INLINE
size_t SubFieldImpl<FieldEntryLayout::SoA>::require_total_buffer_byte_size(
size_t num_elements)
117 auto base = m_build_options.max_alignment;
118 auto old_count_of_base = (m_num_elements + base - 1) / base;
119 auto new_count_of_base = (num_elements + base - 1) / base;
120 auto rounded_new_count = base * new_count_of_base;
121 auto total_bytes = m_base_struct_stride * new_count_of_base;
125MUDA_INLINE
void SubFieldImpl<FieldEntryLayout::SoA>::calculate_new_cores(
126 std::byte* byte_buffer,
size_t total_bytes,
size_t element_count, span<FieldEntryCore> new_cores)
128 auto base = m_build_options.max_alignment;
129 auto old_count_of_base = (m_num_elements + base - 1) / base;
130 auto new_count_of_base = (element_count + base - 1) / base;
131 auto rounded_new_count = base * new_count_of_base;
133 for(
auto& new_core : new_cores)
135 new_core.m_info.struct_stride = m_struct_stride;
136 new_core.m_info.offset_in_struct =
137 new_core.m_info.offset_in_base_struct * new_count_of_base;
138 new_core.m_info.elem_count_based_stride =
139 new_core.m_info.elem_byte_size * rounded_new_count;