Skip to content

Commit

Permalink
Use span<const int> in getClusters and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaldu committed Feb 26, 2025
1 parent 0edb1b9 commit f7e1d55
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions benchmark/profiling/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {

const std::size_t block_size{256};
algo.make_clusters(h_points, d_points, FlatKernel{.5f}, queue_, block_size);
auto clusters = algo.getClusters(h_points);

Check warning

Code scanning / Cppcheck (reported by Codacy)

Variable 'clusters' is assigned a value that is never used. Warning test

Variable 'clusters' is assigned a value that is never used.
}
}; // namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE

Expand Down
2 changes: 1 addition & 1 deletion include/CLUEstering/CLUEstering.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE_CLUE {
template <uint8_t Ndim>
std::vector<std::vector<int>> CLUEAlgoAlpaka<Ndim>::getClusters(
const PointsSoA<Ndim>& h_points) {
std::span<int> cluster_ids{h_points.clusterIndexes(), h_points.nPoints()};
std::span<const int> cluster_ids{h_points.clusterIndexes(), h_points.nPoints()};
return clue::compute_clusters_points(cluster_ids);
}

Expand Down
8 changes: 4 additions & 4 deletions include/CLUEstering/utility/validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

namespace clue {

int compute_nclusters(std::span<int> cluster_ids) {
int compute_nclusters(std::span<const int> cluster_ids) {
return *std::ranges::max_element(cluster_ids) + 1;
}

std::vector<std::vector<int>> compute_clusters_points(std::span<int> cluster_ids) {
std::vector<std::vector<int>> compute_clusters_points(std::span<const int> cluster_ids) {
const auto nclusters = compute_nclusters(cluster_ids);
std::vector<std::vector<int>> clusters_points(nclusters);

Expand All @@ -21,7 +21,7 @@ namespace clue {
return clusters_points;
}

std::vector<int> compute_clusters_size(std::span<int> cluster_ids) {
std::vector<int> compute_clusters_size(std::span<const int> cluster_ids) {
const auto nclusters = compute_nclusters(cluster_ids);
const auto clusters_points = compute_clusters_points(cluster_ids);

Expand All @@ -32,7 +32,7 @@ namespace clue {
return clusters;
}

bool validate_results(std::span<int> cluster_ids, std::span<int> truth) {
bool validate_results(std::span<int> cluster_ids, std::span<const int> truth) {
auto result_clusters_sizes = compute_clusters_size(cluster_ids);
auto truth_clusters_sizes = compute_clusters_size(truth);
std::ranges::sort(result_clusters_sizes);
Expand Down

0 comments on commit f7e1d55

Please sign in to comment.