Skip to content

Commit

Permalink
Cleaning and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaldu committed Dec 20, 2023
1 parent a25a533 commit 854809d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 145 deletions.
45 changes: 9 additions & 36 deletions CLUEstering/alpaka/BindingModules/binding_cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Device> devices = alpaka::getDevs<Platform>();
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';
}
Expand All @@ -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<Acc1D>(device_id);

// Create the queue
Queue queue_(dev_acc);

/* Vec const elementsPerThread(Vec::all(static_cast<Idx>(1))); */
/* Vec const threadsPerGrid(Vec::all(static_cast<Idx>(8))); */
/* WorkDiv const work_div = */
/* alpaka::getValidWorkDiv<Acc1D>(dev_acc, */
/* threadsPerGrid, */
/* elementsPerThread, */
/* false, */
/* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */

// Running the clustering algorithm //
switch (Ndim) {
[[unlikely]] case (1) :
Expand Down Expand Up @@ -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<Acc1D>(device_id);

// Create the queue
Queue queue_(dev_acc);

/* Vec const elementsPerThread(Vec::all(static_cast<Idx>(1))); */
/* Vec const threadsPerGrid(Vec::all(static_cast<Idx>(8))); */
/* WorkDiv const work_div = */
/* alpaka::getValidWorkDiv<Acc1D>(dev_acc, */
/* threadsPerGrid, */
/* elementsPerThread, */
/* false, */
/* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */

// Running the clustering algorithm //
switch (Ndim) {
[[unlikely]] case (1) :
Expand Down Expand Up @@ -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<Acc1D>(device_id);

// Create the queue
Queue queue_(dev_acc);

/* Vec const elementsPerThread(Vec::all(static_cast<Idx>(1))); */
/* Vec const threadsPerGrid(Vec::all(static_cast<Idx>(8))); */
/* WorkDiv const work_div = */
/* alpaka::getValidWorkDiv<Acc1D>(dev_acc, */
/* threadsPerGrid, */
/* elementsPerThread, */
/* false, */
/* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */

// Running the clustering algorithm //
switch (Ndim) {
[[unlikely]] case (1) :
Expand Down Expand Up @@ -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<float,
float,
Expand All @@ -230,7 +203,7 @@ namespace alpaka_serial_sync {
const FlatKernel&,
int,
size_t,
size_t>(&mainRun),
size_t>(&mainRun),
"mainRun");
m.def("mainRun",
pybind11::overload_cast<float,
Expand All @@ -242,7 +215,7 @@ namespace alpaka_serial_sync {
const ExponentialKernel&,
int,
size_t,
size_t>(&mainRun),
size_t>(&mainRun),
"mainRun");
m.def("mainRun",
pybind11::overload_cast<float,
Expand All @@ -254,7 +227,7 @@ namespace alpaka_serial_sync {
const GaussianKernel&,
int,
size_t,
size_t>(&mainRun),
size_t>(&mainRun),
"mainRun");
}
}; // namespace alpaka_serial_sync
61 changes: 9 additions & 52 deletions CLUEstering/alpaka/BindingModules/binding_cpu_tbb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Device> devices = alpaka::getDevs<Platform>();
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';
}
Expand All @@ -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<Acc1D>(device_id);

// Create the queue
Queue queue_(dev_acc);

/* Vec const elementsPerThread(Vec::all(static_cast<Idx>(1))); */
/* Vec const threadsPerGrid(Vec::all(static_cast<Idx>(8))); */
/* WorkDiv const work_div = */
/* alpaka::getValidWorkDiv<Acc1D>(dev_acc, */
/* threadsPerGrid, */
/* elementsPerThread, */
/* false, */
/* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */

// Running the clustering algorithm //
switch (Ndim) {
[[unlikely]] case (1) :
Expand Down Expand Up @@ -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<Acc1D>(device_id);

// Create the queue
Queue queue_(dev_acc);

/* Vec const elementsPerThread(Vec::all(static_cast<Idx>(1))); */
/* Vec const threadsPerGrid(Vec::all(static_cast<Idx>(8))); */
/* WorkDiv const work_div = */
/* alpaka::getValidWorkDiv<Acc1D>(dev_acc, */
/* threadsPerGrid, */
/* elementsPerThread, */
/* false, */
/* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */

// Running the clustering algorithm //
switch (Ndim) {
[[unlikely]] case (1) :
Expand Down Expand Up @@ -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<Acc1D>(device_id);

// Create the queue
Queue queue_(dev_acc);

/* Vec const elementsPerThread(Vec::all(static_cast<Idx>(1))); */
/* Vec const threadsPerGrid(Vec::all(static_cast<Idx>(8))); */
/* WorkDiv const work_div = */
/* alpaka::getValidWorkDiv<Acc1D>(dev_acc, */
/* threadsPerGrid, */
/* elementsPerThread, */
/* false, */
/* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */

// Running the clustering algorithm //
switch (Ndim) {
[[unlikely]] case (1) :
Expand Down Expand Up @@ -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_<ConvolutionalKernel>(m, "ConvolutionalKernel").def(pybind11::init<>()) */
/* .def("operator()", &ConvolutionalKernel::operator()); */
/* pybind11::class_<FlatKernel, ConvolutionalKernel>(m, "FlatKernel") */
/* .def(pybind11::init<float>()) */
/* .def("operator()", &FlatKernel::operator()); */
/* pybind11::class_<GaussianKernel, ConvolutionalKernel>(m, "GaussianKernel") */
/* .def(pybind11::init<float, float, float>()) */
/* .def("operator()", &GaussianKernel::operator()); */
/* pybind11::class_<ExponentialKernel, ConvolutionalKernel>(m, "ExponentialKernel") */
/* .def(pybind11::init<float, float>()) */
/* .def("operator()", &ExponentialKernel::operator()); */
/* pybind11::class_<CustomKernel, ConvolutionalKernel>(m, "CustomKernel") */
/* .def(pybind11::init<kernel_t>()) */
/* .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<float,
float,
Expand All @@ -244,7 +203,7 @@ namespace alpaka_tbb_async {
const FlatKernel&,
int,
size_t,
size_t>(&mainRun),
size_t>(&mainRun),
"mainRun");
m.def("mainRun",
pybind11::overload_cast<float,
Expand All @@ -256,7 +215,7 @@ namespace alpaka_tbb_async {
const ExponentialKernel&,
int,
size_t,
size_t>(&mainRun),
size_t>(&mainRun),
"mainRun");
m.def("mainRun",
pybind11::overload_cast<float,
Expand All @@ -268,9 +227,7 @@ namespace alpaka_tbb_async {
const GaussianKernel&,
int,
size_t,
size_t>(&mainRun),
size_t>(&mainRun),
"mainRun");

/* m.def("mainRun", &mainRun, "mainRun"); */
}
}; // namespace alpaka_tbb_async
47 changes: 9 additions & 38 deletions CLUEstering/alpaka/BindingModules/binding_gpu_cuda.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Device> devices = alpaka::getDevs<Platform>();
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';
}
Expand All @@ -38,25 +38,14 @@ namespace alpaka_cuda_async {
const FlatKernel& kernel,
int Ndim,
size_t block_size,
size_t device_id) {
std::vector<Device> devices = alpaka::getDevs<Platform>();

size_t device_id) {
auto const dev_acc = alpaka::getDevByIdx<Acc1D>(device_id);

/* initialise<Platform>(); */

// Create the queue
Queue queue_(dev_acc);

/* Vec const elementsPerThread(Vec::all(static_cast<Idx>(1))); */
/* Vec const threadsPerGrid(Vec::all(static_cast<Idx>(8))); */
/* WorkDiv const work_div = */
/* alpaka::getValidWorkDiv<Acc1D>(dev_acc, */
/* threadsPerGrid, */
/* elementsPerThread, */
/* false, */
/* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */

// Running the clustering algorithm //
switch (Ndim) {
[[unlikely]] case (1) :
Expand Down Expand Up @@ -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<Acc1D>(device_id);

// Create the queue
Queue queue_(dev_acc);

/* Vec const elementsPerThread(Vec::all(static_cast<Idx>(1))); */
/* Vec const threadsPerGrid(Vec::all(static_cast<Idx>(8))); */
/* WorkDiv const work_div = */
/* alpaka::getValidWorkDiv<Acc1D>(dev_acc, */
/* threadsPerGrid, */
/* elementsPerThread, */
/* false, */
/* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */

// Running the clustering algorithm //
switch (Ndim) {
[[unlikely]] case (1) :
Expand Down Expand Up @@ -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<Acc1D>(device_id);

// Create the queue
Queue queue_(dev_acc);

/* Vec const elementsPerThread(Vec::all(static_cast<Idx>(1))); */
/* Vec const threadsPerGrid(Vec::all(static_cast<Idx>(8))); */
/* WorkDiv const work_div = */
/* alpaka::getValidWorkDiv<Acc1D>(dev_acc, */
/* threadsPerGrid, */
/* elementsPerThread, */
/* false, */
/* alpaka::GridBlockExtentSubDivRestrictions::Unrestricted); */

// Running the clustering algorithm //
switch (Ndim) {
[[unlikely]] case (1) :
Expand Down Expand Up @@ -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<float,
float,
Expand All @@ -236,7 +207,7 @@ namespace alpaka_cuda_async {
const FlatKernel&,
int,
size_t,
size_t>(&mainRun),
size_t>(&mainRun),
"mainRun");
m.def("mainRun",
pybind11::overload_cast<float,
Expand All @@ -248,7 +219,7 @@ namespace alpaka_cuda_async {
const ExponentialKernel&,
int,
size_t,
size_t>(&mainRun),
size_t>(&mainRun),
"mainRun");
m.def("mainRun",
pybind11::overload_cast<float,
Expand All @@ -260,7 +231,7 @@ namespace alpaka_cuda_async {
const GaussianKernel&,
int,
size_t,
size_t>(&mainRun),
size_t>(&mainRun),
"mainRun");
}
}; // namespace alpaka_cuda_async
Loading

0 comments on commit 854809d

Please sign in to comment.