Skip to content

Commit 808bc4c

Browse files
committed
Fix sign-ness in tiles members
1 parent 51c7a30 commit 808bc4c

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed

include/CLUEstering/CLUEstering.hpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
112112
}
113113

114114
template <uint8_t Ndim>
115-
void CLUEAlgoAlpaka<Ndim>::setupTiles(Queue queue,
116-
const PointsSoA<Ndim>& h_points) {
117-
// TODO: reconsider the way that we compute the number of tiles
118-
auto nTiles =
119-
static_cast<uint32_t>(std::ceil(h_points.nPoints() / static_cast<float>(pointsPerTile_)));
120-
const auto nPerDim = static_cast<uint32_t>(std::ceil(std::pow(nTiles, 1. / Ndim)));
121-
nTiles = static_cast<uint32_t>(std::pow(nPerDim, Ndim));
115+
void CLUEAlgoAlpaka<Ndim>::setupTiles(Queue queue, const PointsSoA<Ndim>& h_points) {
116+
// TODO: reconsider the way that we compute the number of tiles
117+
auto nTiles = static_cast<int32_t>(
118+
std::ceil(h_points.nPoints() / static_cast<float>(pointsPerTile_)));
119+
const auto nPerDim = static_cast<int32_t>(std::ceil(std::pow(nTiles, 1. / Ndim)));
120+
nTiles = static_cast<int32_t>(std::pow(nPerDim, Ndim));
122121

123122
// TODO: check if nullptr and if not, reset without allocating
124123
d_tiles =
@@ -131,8 +130,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
131130

132131
// these are now private members
133132
const auto device = alpaka::getDev(queue);
134-
alpaka::memcpy(
135-
queue, d_tiles->minMax(), min_max);
133+
alpaka::memcpy(queue, d_tiles->minMax(), min_max);
136134
alpaka::memcpy(queue, d_tiles->tileSize(), tile_sizes);
137135
alpaka::wait(queue);
138136
}
@@ -251,7 +249,6 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
251249

252250
// Wait for all the operations in the queue to finish
253251
alpaka::wait(queue);
254-
255252
}
256253

257254
template <uint8_t Ndim>

include/CLUEstering/DataFormats/alpaka/AssociationMap.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ namespace clue {
321321

322322
template <typename TFunc>
323323
ALPAKA_FN_HOST void fill(size_t size, TFunc func, Queue queue) {
324-
std::cout << "nbins = " << m_size << std::endl;
325324
auto bin_buffer = make_device_buffer<uint32_t[]>(queue, size);
326325

327326
const auto dev = alpaka::getDev(queue);

include/CLUEstering/DataFormats/alpaka/TilesAlpaka.hpp

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
4141
CoordinateExtremes<Ndim>* minmax;
4242
float* tilesizes;
4343
size_t npoints;
44-
size_t ntiles;
45-
size_t nperdim;
44+
int32_t ntiles;
45+
int32_t nperdim;
4646

4747
ALPAKA_FN_ACC inline constexpr const float* minMax() const { return minmax; }
4848
ALPAKA_FN_ACC inline constexpr float* minMax() { return minmax; }
@@ -57,7 +57,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
5757
int coord_bin{(int)((coord - minmax->min(dim)) / tilesizes[dim])};
5858

5959
// Address the cases of underflow and overflow
60-
coord_bin = alpaka::math::min(acc, (size_t)coord_bin, nperdim - 1);
60+
coord_bin = alpaka::math::min(acc, coord_bin, nperdim - 1);
6161
coord_bin = alpaka::math::max(acc, coord_bin, 0);
6262

6363
return coord_bin;
@@ -111,7 +111,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
111111
template <uint8_t Ndim>
112112
class TilesAlpaka {
113113
public:
114-
TilesAlpaka(Queue queue, uint32_t n_points, uint32_t n_perdim, uint32_t n_tiles)
114+
TilesAlpaka(Queue queue, uint32_t n_points, int32_t n_perdim, uint32_t n_tiles)
115115
: m_ntiles{n_tiles},
116116
m_nperdim{n_perdim},
117117
m_minmax{clue::make_device_buffer<CoordinateExtremes<Ndim>>(queue)},
@@ -125,7 +125,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
125125
host_view->tilesizes = m_tilesizes.data();
126126
host_view->npoints = n_points;
127127
host_view->ntiles = n_tiles;
128-
host_view->nperdim = n_perdim;
128+
host_view->nperdim = n_perdim;
129129

130130
alpaka::memcpy(queue, m_view, host_view);
131131
}
@@ -137,27 +137,25 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
137137
m_assoc.initialize(size, nbins, queue);
138138
}
139139

140-
struct GetGlobalBin {
141-
PointsAlpaka<Ndim>::PointsAlpakaView* pointsView;
142-
TilesAlpakaView<Ndim>* tilesView;
140+
struct GetGlobalBin {
141+
PointsAlpaka<Ndim>::PointsAlpakaView* pointsView;
142+
TilesAlpakaView<Ndim>* tilesView;
143143

144-
template <typename TAcc>
145-
ALPAKA_FN_ACC uint32_t operator()(const TAcc& acc, uint32_t index) const {
144+
template <typename TAcc>
145+
ALPAKA_FN_ACC uint32_t operator()(const TAcc& acc, uint32_t index) const {
146146
float coords[Ndim];
147147
for (auto dim = 0; dim < Ndim; ++dim) {
148148
coords[dim] = pointsView->coords[index + dim * pointsView->n];
149149
}
150150

151-
auto bin = tilesView->getGlobalBin(acc, coords);
151+
auto bin = tilesView->getGlobalBin(acc, coords);
152152
return bin;
153-
}
154-
};
153+
}
154+
};
155155

156-
ALPAKA_FN_HOST void fill(Queue queue,
157-
PointsAlpaka<Ndim>& d_points,
158-
size_t size) {
156+
ALPAKA_FN_HOST void fill(Queue queue, PointsAlpaka<Ndim>& d_points, size_t size) {
159157
auto dev = alpaka::getDev(queue);
160-
auto pointsView = d_points.view();
158+
auto pointsView = d_points.view();
161159
m_assoc.fill(size, GetGlobalBin{pointsView, m_view.data()}, queue);
162160
}
163161

@@ -176,7 +174,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
176174
ALPAKA_FN_HOST inline constexpr void clear(const Queue& queue) {}
177175

178176
ALPAKA_FN_HOST clue::device_view<Device, uint32_t[]> indexes(const Device& dev,
179-
size_t assoc_id) {
177+
size_t assoc_id) {
180178
return m_assoc.indexes(dev, assoc_id);
181179
}
182180

@@ -185,8 +183,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
185183
clue::device_buffer<Device, CoordinateExtremes<Ndim>> m_minmax;
186184
clue::device_buffer<Device, float[Ndim]> m_tilesizes;
187185
clue::device_buffer<Device, TilesAlpakaView<Ndim>> m_view;
188-
uint32_t m_ntiles;
189-
uint32_t m_nperdim;
186+
int32_t m_ntiles;
187+
int32_t m_nperdim;
190188
};
191189

192190
} // namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE

0 commit comments

Comments
 (0)