diff --git a/CLUEstering/alpaka/BindingModules/binding_cpu.cc b/CLUEstering/alpaka/BindingModules/binding_cpu.cc index 4c97d588..d4eb3b8e 100644 --- a/CLUEstering/alpaka/BindingModules/binding_cpu.cc +++ b/CLUEstering/alpaka/BindingModules/binding_cpu.cc @@ -14,13 +14,13 @@ namespace alpaka_serial_sync { void listDevices(const std::string& backend) { - const char tab = '\t'; + const char tab = '\t'; const std::vector devices = alpaka::getDevs(); if (devices.empty()) { std::cout << "No devices found for the " << backend << " backend." << std::endl; return; } else { - std::cout << backend << " devices found: \n"; + std::cout << backend << " devices found: \n"; for (size_t i{}; i < devices.size(); ++i) { std::cout << tab << "device " << i << ": " << alpaka::getName(devices[i]) << '\n'; } @@ -36,21 +36,12 @@ namespace alpaka_serial_sync { const FlatKernel& kernel, int Ndim, size_t block_size, - size_t device_id) { + size_t device_id) { auto const dev_acc = alpaka::getDevByIdx(device_id); // Create the queue Queue queue_(dev_acc); - /* Vec const elementsPerThread(Vec::all(static_cast(1))); */ - /* Vec const threadsPerGrid(Vec::all(static_cast(8))); */ - /* WorkDiv const work_div = */ - /* alpaka::getValidWorkDiv(dev_acc, */ - /* threadsPerGrid, */ - /* elementsPerThread, */ - /* false, */ - /* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */ - // Running the clustering algorithm // switch (Ndim) { [[unlikely]] case (1) : @@ -99,21 +90,12 @@ namespace alpaka_serial_sync { const ExponentialKernel& kernel, int Ndim, size_t block_size, - size_t device_id) { + size_t device_id) { auto const dev_acc = alpaka::getDevByIdx(device_id); // Create the queue Queue queue_(dev_acc); - /* Vec const elementsPerThread(Vec::all(static_cast(1))); */ - /* Vec const threadsPerGrid(Vec::all(static_cast(8))); */ - /* WorkDiv const work_div = */ - /* alpaka::getValidWorkDiv(dev_acc, */ - /* threadsPerGrid, */ - /* elementsPerThread, */ - /* false, */ - /* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */ - // Running the clustering algorithm // switch (Ndim) { [[unlikely]] case (1) : @@ -162,21 +144,12 @@ namespace alpaka_serial_sync { const GaussianKernel& kernel, int Ndim, size_t block_size, - size_t device_id) { + size_t device_id) { auto const dev_acc = alpaka::getDevByIdx(device_id); // Create the queue Queue queue_(dev_acc); - /* Vec const elementsPerThread(Vec::all(static_cast(1))); */ - /* Vec const threadsPerGrid(Vec::all(static_cast(8))); */ - /* WorkDiv const work_div = */ - /* alpaka::getValidWorkDiv(dev_acc, */ - /* threadsPerGrid, */ - /* elementsPerThread, */ - /* false, */ - /* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */ - // Running the clustering algorithm // switch (Ndim) { [[unlikely]] case (1) : @@ -219,7 +192,7 @@ namespace alpaka_serial_sync { PYBIND11_MODULE(CLUE_CPU_Serial, m) { m.doc() = "Binding of the CLUE algorithm running serially on CPU"; - m.def("listDevices", &listDevices, "List the available devices for the CPU serial backend"); + m.def("listDevices", &listDevices, "List the available devices for the CPU serial backend"); m.def("mainRun", pybind11::overload_cast(&mainRun), + size_t>(&mainRun), "mainRun"); m.def("mainRun", pybind11::overload_cast(&mainRun), + size_t>(&mainRun), "mainRun"); m.def("mainRun", pybind11::overload_cast(&mainRun), + size_t>(&mainRun), "mainRun"); } }; // namespace alpaka_serial_sync diff --git a/CLUEstering/alpaka/BindingModules/binding_cpu_tbb.cc b/CLUEstering/alpaka/BindingModules/binding_cpu_tbb.cc index 9bc34de5..fe33e584 100644 --- a/CLUEstering/alpaka/BindingModules/binding_cpu_tbb.cc +++ b/CLUEstering/alpaka/BindingModules/binding_cpu_tbb.cc @@ -14,13 +14,13 @@ namespace alpaka_tbb_async { void listDevices(const std::string& backend) { - const char tab = '\t'; + const char tab = '\t'; const std::vector devices = alpaka::getDevs(); if (devices.empty()) { std::cout << "No devices found for the " << backend << " backend." << std::endl; return; } else { - std::cout << backend << " devices found: \n"; + std::cout << backend << " devices found: \n"; for (size_t i{}; i < devices.size(); ++i) { std::cout << tab << "Device " << i << ": " << alpaka::getName(devices[i]) << '\n'; } @@ -36,21 +36,12 @@ namespace alpaka_tbb_async { const FlatKernel& kernel, int Ndim, size_t block_size, - size_t device_id) { + size_t device_id) { auto const dev_acc = alpaka::getDevByIdx(device_id); // Create the queue Queue queue_(dev_acc); - /* Vec const elementsPerThread(Vec::all(static_cast(1))); */ - /* Vec const threadsPerGrid(Vec::all(static_cast(8))); */ - /* WorkDiv const work_div = */ - /* alpaka::getValidWorkDiv(dev_acc, */ - /* threadsPerGrid, */ - /* elementsPerThread, */ - /* false, */ - /* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */ - // Running the clustering algorithm // switch (Ndim) { [[unlikely]] case (1) : @@ -99,21 +90,12 @@ namespace alpaka_tbb_async { const ExponentialKernel& kernel, int Ndim, size_t block_size, - size_t device_id) { + size_t device_id) { auto const dev_acc = alpaka::getDevByIdx(device_id); // Create the queue Queue queue_(dev_acc); - /* Vec const elementsPerThread(Vec::all(static_cast(1))); */ - /* Vec const threadsPerGrid(Vec::all(static_cast(8))); */ - /* WorkDiv const work_div = */ - /* alpaka::getValidWorkDiv(dev_acc, */ - /* threadsPerGrid, */ - /* elementsPerThread, */ - /* false, */ - /* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */ - // Running the clustering algorithm // switch (Ndim) { [[unlikely]] case (1) : @@ -162,21 +144,12 @@ namespace alpaka_tbb_async { const GaussianKernel& kernel, int Ndim, size_t block_size, - size_t device_id) { + size_t device_id) { auto const dev_acc = alpaka::getDevByIdx(device_id); // Create the queue Queue queue_(dev_acc); - /* Vec const elementsPerThread(Vec::all(static_cast(1))); */ - /* Vec const threadsPerGrid(Vec::all(static_cast(8))); */ - /* WorkDiv const work_div = */ - /* alpaka::getValidWorkDiv(dev_acc, */ - /* threadsPerGrid, */ - /* elementsPerThread, */ - /* false, */ - /* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */ - // Running the clustering algorithm // switch (Ndim) { [[unlikely]] case (1) : @@ -219,21 +192,7 @@ namespace alpaka_tbb_async { PYBIND11_MODULE(CLUE_CPU_TBB, m) { m.doc() = "Binding of the CLUE algorithm running on CPU with TBB"; - /* pybind11::class_(m, "ConvolutionalKernel").def(pybind11::init<>()) */ - /* .def("operator()", &ConvolutionalKernel::operator()); */ - /* pybind11::class_(m, "FlatKernel") */ - /* .def(pybind11::init()) */ - /* .def("operator()", &FlatKernel::operator()); */ - /* pybind11::class_(m, "GaussianKernel") */ - /* .def(pybind11::init()) */ - /* .def("operator()", &GaussianKernel::operator()); */ - /* pybind11::class_(m, "ExponentialKernel") */ - /* .def(pybind11::init()) */ - /* .def("operator()", &ExponentialKernel::operator()); */ - /* pybind11::class_(m, "CustomKernel") */ - /* .def(pybind11::init()) */ - /* .def("operator()", &CustomKernel::operator()); */ - m.def("listDevices", &listDevices, "List the available devices for the TBB backend"); + m.def("listDevices", &listDevices, "List the available devices for the TBB backend"); m.def("mainRun", pybind11::overload_cast(&mainRun), + size_t>(&mainRun), "mainRun"); m.def("mainRun", pybind11::overload_cast(&mainRun), + size_t>(&mainRun), "mainRun"); m.def("mainRun", pybind11::overload_cast(&mainRun), + size_t>(&mainRun), "mainRun"); - - /* m.def("mainRun", &mainRun, "mainRun"); */ } }; // namespace alpaka_tbb_async diff --git a/CLUEstering/alpaka/BindingModules/binding_gpu_cuda.cc b/CLUEstering/alpaka/BindingModules/binding_gpu_cuda.cc index 156df3a8..15cea948 100644 --- a/CLUEstering/alpaka/BindingModules/binding_gpu_cuda.cc +++ b/CLUEstering/alpaka/BindingModules/binding_gpu_cuda.cc @@ -16,13 +16,13 @@ using cms::alpakatools::initialise; namespace alpaka_cuda_async { void listDevices(const std::string& backend) { - const char tab = '\t'; + const char tab = '\t'; const std::vector devices = alpaka::getDevs(); if (devices.empty()) { std::cout << "No devices found for the " << backend << " backend." << std::endl; return; } else { - std::cout << backend << " devices found: \n"; + std::cout << backend << " devices found: \n"; for (size_t i{}; i < devices.size(); ++i) { std::cout << tab << "device " << i << ": " << alpaka::getName(devices[i]) << '\n'; } @@ -38,9 +38,7 @@ namespace alpaka_cuda_async { const FlatKernel& kernel, int Ndim, size_t block_size, - size_t device_id) { - std::vector devices = alpaka::getDevs(); - + size_t device_id) { auto const dev_acc = alpaka::getDevByIdx(device_id); /* initialise(); */ @@ -48,15 +46,6 @@ namespace alpaka_cuda_async { // Create the queue Queue queue_(dev_acc); - /* Vec const elementsPerThread(Vec::all(static_cast(1))); */ - /* Vec const threadsPerGrid(Vec::all(static_cast(8))); */ - /* WorkDiv const work_div = */ - /* alpaka::getValidWorkDiv(dev_acc, */ - /* threadsPerGrid, */ - /* elementsPerThread, */ - /* false, */ - /* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */ - // Running the clustering algorithm // switch (Ndim) { [[unlikely]] case (1) : @@ -105,21 +94,12 @@ namespace alpaka_cuda_async { const ExponentialKernel& kernel, int Ndim, size_t block_size, - size_t device_id) { + size_t device_id) { auto const dev_acc = alpaka::getDevByIdx(device_id); // Create the queue Queue queue_(dev_acc); - /* Vec const elementsPerThread(Vec::all(static_cast(1))); */ - /* Vec const threadsPerGrid(Vec::all(static_cast(8))); */ - /* WorkDiv const work_div = */ - /* alpaka::getValidWorkDiv(dev_acc, */ - /* threadsPerGrid, */ - /* elementsPerThread, */ - /* false, */ - /* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */ - // Running the clustering algorithm // switch (Ndim) { [[unlikely]] case (1) : @@ -168,21 +148,12 @@ namespace alpaka_cuda_async { const GaussianKernel& kernel, int Ndim, size_t block_size, - size_t device_id) { + size_t device_id) { auto const dev_acc = alpaka::getDevByIdx(device_id); // Create the queue Queue queue_(dev_acc); - /* Vec const elementsPerThread(Vec::all(static_cast(1))); */ - /* Vec const threadsPerGrid(Vec::all(static_cast(8))); */ - /* WorkDiv const work_div = */ - /* alpaka::getValidWorkDiv(dev_acc, */ - /* threadsPerGrid, */ - /* elementsPerThread, */ - /* false, */ - /* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */ - // Running the clustering algorithm // switch (Ndim) { [[unlikely]] case (1) : @@ -225,7 +196,7 @@ namespace alpaka_cuda_async { PYBIND11_MODULE(CLUE_GPU_CUDA, m) { m.doc() = "Binding of the CLUE algorithm running on CUDA GPUs"; - m.def("listDevices", &listDevices, "List the available devices for the CUDA backend"); + m.def("listDevices", &listDevices, "List the available devices for the CUDA backend"); m.def("mainRun", pybind11::overload_cast(&mainRun), + size_t>(&mainRun), "mainRun"); m.def("mainRun", pybind11::overload_cast(&mainRun), + size_t>(&mainRun), "mainRun"); m.def("mainRun", pybind11::overload_cast(&mainRun), + size_t>(&mainRun), "mainRun"); } }; // namespace alpaka_cuda_async diff --git a/CLUEstering/alpaka/DataFormats/Points.h b/CLUEstering/alpaka/DataFormats/Points.h index 71e40456..e522976c 100644 --- a/CLUEstering/alpaka/DataFormats/Points.h +++ b/CLUEstering/alpaka/DataFormats/Points.h @@ -19,20 +19,20 @@ struct Points { : m_coords{coords}, m_weight{weight}, n{weight.size()} {} Points(const std::vector>& coords, const std::vector& weight) : m_weight{weight}, n{weight.size()} { - for (const auto& x : coords) { - VecArray temp_vecarray; - for (auto value : x) { - temp_vecarray.push_back_unsafe(value); - } - m_coords.push_back(temp_vecarray); - } + for (const auto& x : coords) { + VecArray temp_vecarray; + for (auto value : x) { + temp_vecarray.push_back_unsafe(value); + } + m_coords.push_back(temp_vecarray); + } - m_rho.resize(n); - m_delta.resize(n); - m_nearestHigher.resize(n); - m_clusterIndex.resize(n); - m_isSeed.resize(n); - } + m_rho.resize(n); + m_delta.resize(n); + m_nearestHigher.resize(n); + m_clusterIndex.resize(n); + m_isSeed.resize(n); + } std::vector> m_coords; std::vector m_weight; diff --git a/CLUEstering/alpaka/DataFormats/alpaka/PointsAlpaka.h b/CLUEstering/alpaka/DataFormats/alpaka/PointsAlpaka.h index c6ca708c..9fe71ef4 100644 --- a/CLUEstering/alpaka/DataFormats/alpaka/PointsAlpaka.h +++ b/CLUEstering/alpaka/DataFormats/alpaka/PointsAlpaka.h @@ -38,14 +38,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { // Copy memory inside the host view to device alpaka::memcpy(stream, view_dev, view_host); } - // Copy constructor/assignment operator + // Copy constructor/assignment operator PointsAlpaka(const PointsAlpaka&) = delete; PointsAlpaka& operator=(const PointsAlpaka&) = delete; - // Move constructor/assignment operator + // Move constructor/assignment operator PointsAlpaka(PointsAlpaka&&) = default; PointsAlpaka& operator=(PointsAlpaka&&) = default; - // Destructor - ~PointsAlpaka() = default; + // Destructor + ~PointsAlpaka() = default; cms::alpakatools::device_buffer[]> coords; cms::alpakatools::device_buffer weight; diff --git a/CLUEstering/alpaka/DataFormats/alpaka/TilesAlpaka.h b/CLUEstering/alpaka/DataFormats/alpaka/TilesAlpaka.h index c22319de..9f5812a1 100644 --- a/CLUEstering/alpaka/DataFormats/alpaka/TilesAlpaka.h +++ b/CLUEstering/alpaka/DataFormats/alpaka/TilesAlpaka.h @@ -37,8 +37,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { // Public methods void resizeTiles() { m_tiles.resize(n_tiles); } - // getter - int nPerDim() const { return n_tiles_per_dim; } + // getter + int nPerDim() const { return n_tiles_per_dim; } template ALPAKA_FN_HOST_ACC inline constexpr int getBin(const TAcc& acc, float coord_, int dim_) const {