Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions include/CLUEstering/data_structures/detail/PointsDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ namespace clue {
template <concepts::queue TQueue>
inline PointsDevice<Ndim, TData, TDev>::PointsDevice(TQueue& queue, int32_t n_points)
: m_buffer{make_device_buffer<std::byte[]>(
queue, soa::device::computeSoASize<Ndim, value_type>(n_points))},
queue,
soa::device::computeSoASize<Ndim, value_type>(computeAlignSoASize<Ndim>(n_points)))},
m_view{},
m_size{n_points} {
soa::device::partitionSoAView(m_view, m_buffer.data(), n_points);
soa::device::partitionSoAView(m_view, m_buffer.data(), computeAlignSoASize<Ndim>(n_points));
m_view.m_n = n_points;
}

template <std::size_t Ndim, std::floating_point TData, concepts::device TDev>
Expand Down
6 changes: 4 additions & 2 deletions include/CLUEstering/data_structures/detail/PointsHost.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ namespace clue {
template <concepts::queue TQueue>
inline PointsHost<Ndim, TData>::PointsHost(TQueue& queue, int32_t n_points)
: m_buffer{make_host_buffer<std::byte[]>(
queue, soa::host::computeSoASize<Ndim, value_type>(n_points))},
queue,
soa::host::computeSoASize<Ndim, value_type>(computeAlignSoASize<Ndim>(n_points)))},
m_view{},
m_size{n_points} {
soa::host::partitionSoAView(m_view, m_buffer->data(), n_points);
soa::host::partitionSoAView(m_view, m_buffer->data(), computeAlignSoASize<Ndim>(n_points));
m_view.m_n = n_points;
}

template <std::size_t Ndim, std::floating_point TData>
Expand Down
9 changes: 7 additions & 2 deletions include/CLUEstering/data_structures/internal/PointsCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,13 @@ namespace clue {
}
};

// TODO: implement for better cache use
// Round n_points up to the next multiple of 32 so that each sub-array in a
// SoA layout starts at a 128-byte–aligned address for 4-byte types (float,
// int32), matching the GPU L2 cache line size.
template <std::size_t Ndim>
int32_t computeAlignSoASize(int32_t n_points);
inline int32_t computeAlignSoASize(int32_t n_points) {
constexpr int32_t alignment = 32;
return ((n_points + alignment - 1) / alignment) * alignment;
}

} // namespace clue
Loading