Skip to content

Commit

Permalink
Add CLUEAlgo member for block size and bind its setter
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaldu committed Dec 13, 2023
1 parent 63005e3 commit f7f672d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CLUEstering/alpaka/BindingModules/binding_cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,5 +229,7 @@ namespace alpaka_serial_sync {
const GaussianKernel&,
int>(&mainRun),
"mainRun");

m.def("set_blocksize", CLUEAlgoAlpaka::setBlockSize, "set_blocksize");
}
}; // namespace alpaka_serial_sync
18 changes: 10 additions & 8 deletions CLUEstering/alpaka/CLUE/CLUEAlgoAlpaka.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
VecArray<int32_t, max_seeds>* m_seeds;
VecArray<int32_t, max_followers>* m_followers;

void setBlockSize(std::size_t blockSize) { blockSize_ = blockSize; }

template <typename KernelType>
std::vector<std::vector<int>> make_clusters(Points<Ndim>& h_points,
PointsAlpaka<Ndim>& d_points,
Expand All @@ -50,6 +52,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
// average number of points found in a tile
int pointsPerTile_;

std::size_t blockSize_ = 1024;

/* domain_t<Ndim> m_domains; */

// Buffers
Expand Down Expand Up @@ -118,9 +122,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
alpaka::memset(queue_, (*d_seeds), 0x00);

// Define the working division
const Idx block_size{1024};
Idx grid_size = cms::alpakatools::divide_up_by(h_points.n, block_size);
auto working_div = cms::alpakatools::make_workdiv<Acc1D>(grid_size, block_size);
Idx grid_size = cms::alpakatools::divide_up_by(h_points.n, blockSize_);
auto working_div = cms::alpakatools::make_workdiv<Acc1D>(grid_size, blockSize_);
alpaka::enqueue(
queue_,
alpaka::createTaskKernel<Acc1D>(working_div, KernelResetFollowers{}, m_followers, h_points.n));
Expand All @@ -135,9 +138,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
Queue queue_) {
setup(h_points, d_points, queue_);

const Idx block_size{1024};
const Idx grid_size = cms::alpakatools::divide_up_by(h_points.n, block_size);
auto working_div = cms::alpakatools::make_workdiv<Acc1D>(grid_size, block_size);
const Idx grid_size = cms::alpakatools::divide_up_by(h_points.n, blockSize_);
auto working_div = cms::alpakatools::make_workdiv<Acc1D>(grid_size, blockSize_);
alpaka::enqueue(queue_,
alpaka::createTaskKernel<Acc1D>(
working_div, KernelFillTiles(), d_points.view(), m_tiles, h_points.n));
Expand Down Expand Up @@ -172,8 +174,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
h_points.n));

// We change the working division when assigning the clusters
const Idx grid_size_seeds = ceil(max_seeds / static_cast<float>(block_size));
auto working_div_seeds = cms::alpakatools::make_workdiv<Acc1D>(grid_size_seeds, block_size);
const Idx grid_size_seeds = cms::alpakatools::divide_up_by(max_seeds, blockSize_);
auto working_div_seeds = cms::alpakatools::make_workdiv<Acc1D>(grid_size_seeds, blockSize_);
alpaka::enqueue(
queue_,
alpaka::createTaskKernel<Acc1D>(
Expand Down

0 comments on commit f7f672d

Please sign in to comment.