From 5eba84c4e816627c99071517b08e903c9d55be8c Mon Sep 17 00:00:00 2001 From: Simone Balducci Date: Fri, 7 Feb 2025 09:26:35 +0100 Subject: [PATCH] Formatting --- .../CLUEstering/CLUE/CLUEAlpakaKernels.hpp | 8 +- include/CLUEstering/CLUEstering.hpp | 8 +- .../DataFormats/alpaka/AssociationMap.hpp | 99 +++++++++---------- .../DataFormats/alpaka/TilesAlpaka.hpp | 10 +- 4 files changed, 58 insertions(+), 67 deletions(-) diff --git a/include/CLUEstering/CLUE/CLUEAlpakaKernels.hpp b/include/CLUEstering/CLUE/CLUEAlpakaKernels.hpp index 4e691798..3a703bc6 100644 --- a/include/CLUEstering/CLUE/CLUEAlpakaKernels.hpp +++ b/include/CLUEstering/CLUE/CLUEAlpakaKernels.hpp @@ -43,7 +43,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE { TilesAlpaka* tiles, PointsAlpakaView* dev_points, const KernelType& kernel, - /* const VecArray, Ndim>& domains, */ const float* coords_i, float* rho_i, float dc, @@ -72,7 +71,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE { } } // end of interate inside this bin - return; } else { for (unsigned int i{search_box[search_box.capacity() - N_][0]}; @@ -99,7 +97,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE { TilesAlpaka* dev_tiles, PointsAlpakaView* dev_points, const KernelType& kernel, - /* const VecArray, Ndim>& domains, */ float dc, uint32_t n_points) const { for (auto i : alpaka::uniformElements(acc, n_points)) { @@ -143,9 +140,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE { const TAcc& acc, VecArray& base_vec, const VecArray, Ndim>& s_box, - TilesAlpaka* tiles, + TilesAlpakaView* tiles, PointsAlpakaView* dev_points, - /* const VecArray, Ndim>& domains, */ const float* coords_i, float rho_i, float* delta_i, @@ -211,8 +207,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE { template ALPAKA_FN_ACC void operator()(const TAcc& acc, TilesAlpaka* dev_tiles, + TilesAlpakaView* dev_tiles, PointsAlpakaView* dev_points, - /* const VecArray, Ndim>& domains, */ float dm, float, uint32_t n_points) const { diff --git a/include/CLUEstering/CLUEstering.hpp b/include/CLUEstering/CLUEstering.hpp index a0a26f5d..f3b5b499 100644 --- a/include/CLUEstering/CLUEstering.hpp +++ b/include/CLUEstering/CLUEstering.hpp @@ -151,12 +151,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE { alpaka::memset(queue_, *d_seeds, 0x00); const Idx grid_size = clue::divide_up_by(h_points.nPoints(), block_size); const auto working_div = clue::make_workdiv(grid_size, block_size); - alpaka::exec(queue_, - - working_div, - KernelResetFollowers{}, - m_followers, - h_points.nPoints()); + alpaka::exec( + queue_, working_div, KernelResetFollowers{}, m_followers, h_points.nPoints()); } template diff --git a/include/CLUEstering/DataFormats/alpaka/AssociationMap.hpp b/include/CLUEstering/DataFormats/alpaka/AssociationMap.hpp index b104a854..59de316c 100644 --- a/include/CLUEstering/DataFormats/alpaka/AssociationMap.hpp +++ b/include/CLUEstering/DataFormats/alpaka/AssociationMap.hpp @@ -42,8 +42,11 @@ namespace clue { *nbins = max + 1; } template - ALPAKA_FN_ACC void operator()( - const TAcc& acc, size_t size, uint32_t* associations, uint32_t* nbins, TFunc func) const { + ALPAKA_FN_ACC void operator()(const TAcc& acc, + size_t size, + uint32_t* associations, + uint32_t* nbins, + TFunc func) const { auto max = 0; for (auto i : alpaka::uniformElements(acc, size)) { associations[i] = func(acc, i); @@ -93,24 +96,22 @@ namespace clue { }; struct AssociationMapView { - uint32_t* m_indexes; - uint32_t* m_offsets; - uint32_t m_size; - uint32_t m_nbins; - - ALPAKA_FN_ACC Span indexes(size_t assoc_id) { - auto size = m_offsets[assoc_id + 1] - m_offsets[assoc_id]; - auto* buf_ptr = m_indexes + m_offsets[assoc_id]; - return Span{buf_ptr, size}; - } - ALPAKA_FN_ACC uint32_t offsets(size_t assoc_id) { - return m_offsets[assoc_id]; - } - ALPAKA_FN_ACC Span operator[](size_t assoc_id) { - auto size = m_offsets[assoc_id + 1] - m_offsets[assoc_id]; - auto* buf_ptr = m_indexes + m_offsets[assoc_id]; - return Span{buf_ptr, size}; - } + uint32_t* m_indexes; + uint32_t* m_offsets; + uint32_t m_size; + uint32_t m_nbins; + + ALPAKA_FN_ACC Span indexes(size_t assoc_id) { + auto size = m_offsets[assoc_id + 1] - m_offsets[assoc_id]; + auto* buf_ptr = m_indexes + m_offsets[assoc_id]; + return Span{buf_ptr, size}; + } + ALPAKA_FN_ACC uint32_t offsets(size_t assoc_id) { return m_offsets[assoc_id]; } + ALPAKA_FN_ACC Span operator[](size_t assoc_id) { + auto size = m_offsets[assoc_id + 1] - m_offsets[assoc_id]; + auto* buf_ptr = m_indexes + m_offsets[assoc_id]; + return Span{buf_ptr, size}; + } }; template >> @@ -118,47 +119,45 @@ namespace clue { private: device_buffer m_indexes; device_buffer m_offsets; - device_buffer m_view; - // TODO: the names of this variables are a bit ambiguous + device_buffer m_view; + // TODO: the names of this variables are a bit ambiguous size_t m_size; public: AssociationMap() = default; - // TODO: see above + // TODO: see above AssociationMap(size_t size, size_t nbins, const TDev& dev) : m_indexes{make_device_buffer(dev, size)}, m_offsets{make_device_buffer(dev, nbins + 1)}, - m_view{make_device_buffer(dev)}, + m_view{make_device_buffer(dev)}, m_size{nbins} { - auto h_view = make_host_buffer(dev); - h_view->m_indexes = m_indexes.data(); - h_view->m_offsets = m_offsets.data(); - h_view->m_size = size; - h_view->m_nbins = m_size; - - auto queue(dev); - alpaka::memcpy(queue, m_view, h_view); - } + auto h_view = make_host_buffer(dev); + h_view->m_indexes = m_indexes.data(); + h_view->m_offsets = m_offsets.data(); + h_view->m_size = size; + h_view->m_nbins = m_size; + + auto queue(dev); + alpaka::memcpy(queue, m_view, h_view); + } - // TODO: see above + // TODO: see above template >> AssociationMap(size_t size, size_t nbins, TQueue queue) : m_indexes{make_device_buffer(queue, size)}, m_offsets{make_device_buffer(queue, nbins + 1)}, - m_view{make_device_buffer(queue)}, + m_view{make_device_buffer(queue)}, m_size{nbins} { - auto h_view = make_host_buffer(queue); - h_view->m_indexes = m_indexes.data(); - h_view->m_offsets = m_offsets.data(); - h_view->m_size = size; - h_view->m_nbins = m_size; + auto h_view = make_host_buffer(queue); + h_view->m_indexes = m_indexes.data(); + h_view->m_offsets = m_offsets.data(); + h_view->m_size = size; + h_view->m_nbins = m_size; - alpaka::memcpy(queue, m_view, h_view); - } + alpaka::memcpy(queue, m_view, h_view); + } - AssociationMapView* view() { - return m_view.data(); - } + AssociationMapView* view() { return m_view.data(); } template >> ALPAKA_FN_HOST void initialize(size_t size, size_t nbins, const TQueue& queue) { @@ -175,13 +174,14 @@ namespace clue { auto size() const { return m_size; } - ALPAKA_FN_HOST device_buffer indexes() { return m_indexes; } + ALPAKA_FN_HOST device_buffer indexes() { return m_indexes; } ALPAKA_FN_ACC Span indexes(size_t assoc_id) { auto size = m_offsets[assoc_id + 1] - m_offsets[assoc_id]; auto* buf_ptr = m_indexes.data() + m_offsets[assoc_id]; return Span{buf_ptr, size}; } - ALPAKA_FN_HOST device_view indexes(const TDev& dev, size_t assoc_id) { + ALPAKA_FN_HOST device_view indexes(const TDev& dev, + size_t assoc_id) { auto size = m_offsets[assoc_id + 1] - m_offsets[assoc_id]; auto* buf_ptr = m_indexes.data() + m_offsets[assoc_id]; return make_device_view(dev, buf_ptr, size); @@ -263,7 +263,7 @@ namespace clue { /* template */ /* ALPAKA_FN_HOST void fill(size_t size, TFunc func, TDev dev) { */ - /* std::cout << "nbins = " << m_size << std::endl; */ + /* std::cout << "nbins = " << m_size << std::endl; */ /* auto bin_buffer = make_device_buffer(dev, size); */ /* auto queue(dev); */ @@ -323,7 +323,7 @@ namespace clue { ALPAKA_FN_HOST void fill(size_t size, TFunc func, Queue queue) { auto bin_buffer = make_device_buffer(queue, size); - const auto dev = alpaka::getDev(queue); + const auto dev = alpaka::getDev(queue); const auto blocksize = 512; const auto gridsize = divide_up_by(size, blocksize); const auto workdiv = make_workdiv(gridsize, blocksize); @@ -374,7 +374,6 @@ namespace clue { temp_offsets.data(), size); } - }; /* template class TilesAlpaka { public: - TilesAlpaka(Queue queue, uint32_t n_points, int32_t n_perdim, uint32_t n_tiles) - : m_ntiles{n_tiles}, - m_nperdim{n_perdim}, + TilesAlpaka(Queue queue, uint32_t n_points, int32_t n_perdim, int32_t n_tiles) + : m_assoc{clue::AssociationMap(n_points, n_tiles, queue)}, m_minmax{clue::make_device_buffer>(queue)}, m_tilesizes{clue::make_device_buffer(queue)}, - m_assoc{clue::AssociationMap(n_points, n_tiles, queue)}, + m_ntiles{n_tiles}, + m_nperdim{n_perdim}, m_view{clue::make_device_buffer>(queue)} { auto host_view = clue::make_host_buffer>(queue); host_view->indexes = m_assoc.indexes().data(); @@ -182,9 +182,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE { clue::AssociationMap m_assoc; clue::device_buffer> m_minmax; clue::device_buffer m_tilesizes; - clue::device_buffer> m_view; int32_t m_ntiles; int32_t m_nperdim; + clue::device_buffer> m_view; }; } // namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE