@@ -42,8 +42,11 @@ namespace clue {
42
42
*nbins = max + 1 ;
43
43
}
44
44
template <typename TAcc>
45
- ALPAKA_FN_ACC void operator ()(
46
- const TAcc& acc, size_t size, uint32_t * associations, uint32_t * nbins, TFunc func) const {
45
+ ALPAKA_FN_ACC void operator ()(const TAcc& acc,
46
+ size_t size,
47
+ uint32_t * associations,
48
+ uint32_t * nbins,
49
+ TFunc func) const {
47
50
auto max = 0 ;
48
51
for (auto i : alpaka::uniformElements (acc, size)) {
49
52
associations[i] = func (acc, i);
@@ -93,72 +96,68 @@ namespace clue {
93
96
};
94
97
95
98
struct AssociationMapView {
96
- uint32_t * m_indexes;
97
- uint32_t * m_offsets;
98
- uint32_t m_size;
99
- uint32_t m_nbins;
100
-
101
- ALPAKA_FN_ACC Span<uint32_t > indexes (size_t assoc_id) {
102
- auto size = m_offsets[assoc_id + 1 ] - m_offsets[assoc_id];
103
- auto * buf_ptr = m_indexes + m_offsets[assoc_id];
104
- return Span<uint32_t >{buf_ptr, size};
105
- }
106
- ALPAKA_FN_ACC uint32_t offsets (size_t assoc_id) {
107
- return m_offsets[assoc_id];
108
- }
109
- ALPAKA_FN_ACC Span<uint32_t > operator [](size_t assoc_id) {
110
- auto size = m_offsets[assoc_id + 1 ] - m_offsets[assoc_id];
111
- auto * buf_ptr = m_indexes + m_offsets[assoc_id];
112
- return Span<uint32_t >{buf_ptr, size};
113
- }
99
+ uint32_t * m_indexes;
100
+ uint32_t * m_offsets;
101
+ uint32_t m_size;
102
+ uint32_t m_nbins;
103
+
104
+ ALPAKA_FN_ACC Span<uint32_t > indexes (size_t assoc_id) {
105
+ auto size = m_offsets[assoc_id + 1 ] - m_offsets[assoc_id];
106
+ auto * buf_ptr = m_indexes + m_offsets[assoc_id];
107
+ return Span<uint32_t >{buf_ptr, size};
108
+ }
109
+ ALPAKA_FN_ACC uint32_t offsets (size_t assoc_id) { return m_offsets[assoc_id]; }
110
+ ALPAKA_FN_ACC Span<uint32_t > operator [](size_t assoc_id) {
111
+ auto size = m_offsets[assoc_id + 1 ] - m_offsets[assoc_id];
112
+ auto * buf_ptr = m_indexes + m_offsets[assoc_id];
113
+ return Span<uint32_t >{buf_ptr, size};
114
+ }
114
115
};
115
116
116
117
template <typename TDev, typename = std::enable_if_t <alpaka::isDevice<TDev>>>
117
118
class AssociationMap {
118
119
private:
119
120
device_buffer<TDev, uint32_t []> m_indexes;
120
121
device_buffer<TDev, uint32_t []> m_offsets;
121
- device_buffer<TDev, AssociationMapView> m_view;
122
- // TODO: the names of this variables are a bit ambiguous
122
+ device_buffer<TDev, AssociationMapView> m_view;
123
+ // TODO: the names of this variables are a bit ambiguous
123
124
size_t m_size;
124
125
125
126
public:
126
127
AssociationMap () = default ;
127
- // TODO: see above
128
+ // TODO: see above
128
129
AssociationMap (size_t size, size_t nbins, const TDev& dev)
129
130
: m_indexes{make_device_buffer<uint32_t []>(dev, size)},
130
131
m_offsets{make_device_buffer<uint32_t []>(dev, nbins + 1 )},
131
- m_view{make_device_buffer<AssociationMapView>(dev)},
132
+ m_view{make_device_buffer<AssociationMapView>(dev)},
132
133
m_size{nbins} {
133
- auto h_view = make_host_buffer<AssociationMapView>(dev);
134
- h_view->m_indexes = m_indexes.data ();
135
- h_view->m_offsets = m_offsets.data ();
136
- h_view->m_size = size;
137
- h_view->m_nbins = m_size;
138
-
139
- auto queue (dev);
140
- alpaka::memcpy (queue, m_view, h_view);
141
- }
134
+ auto h_view = make_host_buffer<AssociationMapView>(dev);
135
+ h_view->m_indexes = m_indexes.data ();
136
+ h_view->m_offsets = m_offsets.data ();
137
+ h_view->m_size = size;
138
+ h_view->m_nbins = m_size;
139
+
140
+ auto queue (dev);
141
+ alpaka::memcpy (queue, m_view, h_view);
142
+ }
142
143
143
- // TODO: see above
144
+ // TODO: see above
144
145
template <typename TQueue, typename = std::enable_if_t <alpaka::isQueue<TQueue>>>
145
146
AssociationMap (size_t size, size_t nbins, TQueue queue)
146
147
: m_indexes{make_device_buffer<uint32_t []>(queue, size)},
147
148
m_offsets{make_device_buffer<uint32_t []>(queue, nbins + 1 )},
148
- m_view{make_device_buffer<AssociationMapView>(queue)},
149
+ m_view{make_device_buffer<AssociationMapView>(queue)},
149
150
m_size{nbins} {
150
- auto h_view = make_host_buffer<AssociationMapView>(queue);
151
- h_view->m_indexes = m_indexes.data ();
152
- h_view->m_offsets = m_offsets.data ();
153
- h_view->m_size = size;
154
- h_view->m_nbins = m_size;
151
+ auto h_view = make_host_buffer<AssociationMapView>(queue);
152
+ h_view->m_indexes = m_indexes.data ();
153
+ h_view->m_offsets = m_offsets.data ();
154
+ h_view->m_size = size;
155
+ h_view->m_nbins = m_size;
155
156
156
- alpaka::memcpy (queue, m_view, h_view);
157
- }
157
+ alpaka::memcpy (queue, m_view, h_view);
158
+ }
158
159
159
- AssociationMapView* view () {
160
- return m_view.data ();
161
- }
160
+ AssociationMapView* view () { return m_view.data (); }
162
161
163
162
template <typename TQueue, typename = std::enable_if_t <alpaka::isQueue<TQueue>>>
164
163
ALPAKA_FN_HOST void initialize (size_t size, size_t nbins, const TQueue& queue) {
@@ -175,13 +174,14 @@ namespace clue {
175
174
176
175
auto size () const { return m_size; }
177
176
178
- ALPAKA_FN_HOST device_buffer<TDev, uint32_t []> indexes () { return m_indexes; }
177
+ ALPAKA_FN_HOST device_buffer<TDev, uint32_t []> indexes () { return m_indexes; }
179
178
ALPAKA_FN_ACC Span<uint32_t > indexes (size_t assoc_id) {
180
179
auto size = m_offsets[assoc_id + 1 ] - m_offsets[assoc_id];
181
180
auto * buf_ptr = m_indexes.data () + m_offsets[assoc_id];
182
181
return Span<uint32_t >{buf_ptr, size};
183
182
}
184
- ALPAKA_FN_HOST device_view<TDev, uint32_t []> indexes (const TDev& dev, size_t assoc_id) {
183
+ ALPAKA_FN_HOST device_view<TDev, uint32_t []> indexes (const TDev& dev,
184
+ size_t assoc_id) {
185
185
auto size = m_offsets[assoc_id + 1 ] - m_offsets[assoc_id];
186
186
auto * buf_ptr = m_indexes.data () + m_offsets[assoc_id];
187
187
return make_device_view<uint32_t [], TDev>(dev, buf_ptr, size);
@@ -263,7 +263,7 @@ namespace clue {
263
263
264
264
/* template <typename TFunc> */
265
265
/* ALPAKA_FN_HOST void fill(size_t size, TFunc func, TDev dev) { */
266
- /* std::cout << "nbins = " << m_size << std::endl; */
266
+ /* std::cout << "nbins = " << m_size << std::endl; */
267
267
/* auto bin_buffer = make_device_buffer<uint32_t[]>(dev, size); */
268
268
269
269
/* auto queue(dev); */
@@ -323,7 +323,7 @@ namespace clue {
323
323
ALPAKA_FN_HOST void fill (size_t size, TFunc func, Queue queue) {
324
324
auto bin_buffer = make_device_buffer<uint32_t []>(queue, size);
325
325
326
- const auto dev = alpaka::getDev (queue);
326
+ const auto dev = alpaka::getDev (queue);
327
327
const auto blocksize = 512 ;
328
328
const auto gridsize = divide_up_by (size, blocksize);
329
329
const auto workdiv = make_workdiv<Acc1D>(gridsize, blocksize);
@@ -374,7 +374,6 @@ namespace clue {
374
374
temp_offsets.data (),
375
375
size);
376
376
}
377
-
378
377
};
379
378
380
379
/* template <typename TFunc, */
0 commit comments