CLUEstering
High-performance density-based weighted clustering library developed at CERN
Loading...
Searching...
No Matches
PointsHost.hpp
Go to the documentation of this file.
1
4
5#pragma once
6
7#include "CLUEstering/data_structures/internal/PointsCommon.hpp"
8#include "CLUEstering/internal/alpaka/memory.hpp"
9
10#include <optional>
11#include <ranges>
12#include <span>
13#include <alpaka/alpaka.hpp>
14
15namespace clue {
16
21 template <uint8_t Ndim>
22 class PointsHost : public internal::points_interface<PointsHost<Ndim>> {
23 private:
24 std::optional<host_buffer<std::byte[]>> m_buffer;
25 PointsView m_view;
26 int32_t m_size;
27
28 public:
29 class Point {
30 std::array<float, Ndim> m_coordinates;
31 float m_weight;
32 int m_clusterIndex;
33
34 public:
35 Point(const std::array<float, Ndim>& coordinates, float weight, int cluster_index);
36 float operator[](size_t dim) const;
37
38 float weight() const;
39 float cluster_index() const;
40 };
41
42 template <concepts::queue TQueue>
43 PointsHost(TQueue& queue, int32_t n_points);
44
45 template <concepts::queue TQueue>
46 PointsHost(TQueue& queue, int32_t n_points, std::span<std::byte> buffer);
47
48 template <concepts::queue TQueue, std::ranges::contiguous_range... TBuffers>
49 requires(sizeof...(TBuffers) == 2 || sizeof...(TBuffers) == 4)
50 PointsHost(TQueue& queue, int32_t n_points, TBuffers&&... buffers);
51
52 template <concepts::queue TQueue, concepts::contiguous_raw_data... TBuffers>
53 requires(sizeof...(TBuffers) == 2 || sizeof...(TBuffers) == 4)
54 PointsHost(TQueue& queue, int32_t n_points, TBuffers... buffers);
55
56 PointsHost(const PointsHost&) = delete;
57 PointsHost& operator=(const PointsHost&) = delete;
58 PointsHost(PointsHost&&) = default;
59 PointsHost& operator=(PointsHost&&) = default;
60 ~PointsHost() = default;
61
62#ifdef CLUE_BUILD_DOXYGEN
65 ALPAKA_FN_HOST int32_t size() const;
68 ALPAKA_FN_HOST auto coords() const;
71 ALPAKA_FN_HOST auto coords();
75 ALPAKA_FN_HOST auto coords(size_t dim) const;
79 ALPAKA_FN_HOST auto coords(size_t dim);
82 ALPAKA_FN_HOST auto weights() const;
85 ALPAKA_FN_HOST auto weights();
88 ALPAKA_FN_HOST auto clusterIndexes() const;
91 ALPAKA_FN_HOST auto clusterIndexes();
94 ALPAKA_FN_HOST auto isSeed() const;
97 ALPAKA_FN_HOST auto isSeed();
100 ALPAKA_FN_HOST const auto& view() const;
103 ALPAKA_FN_HOST auto& view();
104#endif
105
106 Point operator[](std::size_t idx) const;
107
108 private:
109 inline static constexpr uint8_t Ndim_ = Ndim;
110
111 template <concepts::queue _TQueue, uint8_t _Ndim, concepts::device _TDev>
112 friend void copyToHost(_TQueue& queue,
113 PointsHost<_Ndim>& h_points,
114 const PointsDevice<_Ndim, _TDev>& d_points);
115 template <concepts::queue _TQueue, uint8_t _Ndim, concepts::device _TDev>
116 friend void copyToDevice(_TQueue& queue,
118 const PointsHost<_Ndim>& h_points);
119 friend struct internal::points_interface<PointsHost<Ndim>>;
120 };
121
122} // namespace clue
123
124#include "CLUEstering/data_structures/detail/PointsHost.hpp"
125#include "CLUEstering/data_structures/detail/Point.hpp"
The PointsDevice class is a data structure that manages points on a device. It provides methods to al...
Definition PointsDevice.hpp:25
Definition PointsHost.hpp:29
ALPAKA_FN_HOST auto coords(size_t dim)
Returns the coordinates of the points for a specific dimension as a span.
ALPAKA_FN_HOST auto clusterIndexes()
Returns the cluster indexes of the points as a span.
ALPAKA_FN_HOST const auto & view() const
Returns the view of the points.
ALPAKA_FN_HOST auto & view()
Returns the view of the points.
ALPAKA_FN_HOST int32_t size() const
Returns the number of points.
ALPAKA_FN_HOST auto coords()
Returns the coordinates of the points as a span.
ALPAKA_FN_HOST auto isSeed()
Returns the seed status of the points as a span.
ALPAKA_FN_HOST auto coords(size_t dim) const
Returns the coordinates of the points for a specific dimension as a const span.
ALPAKA_FN_HOST auto clusterIndexes() const
Returns the cluster indexes of the points as a const span.
ALPAKA_FN_HOST auto isSeed() const
Returns the seed status of the points as a const span.
ALPAKA_FN_HOST auto coords() const
Returns the coordinates of the points as a const span.
ALPAKA_FN_HOST auto weights()
Returns the weights of the points as a span.
ALPAKA_FN_HOST auto weights() const
Returns the weights of the points as a const span.