Skip to content

Commit ada9fe0

Browse files
committed
Merge branch 'regression' into spack
2 parents 4b90f3e + cc12324 commit ada9fe0

38 files changed

+148
-104
lines changed

bindings/Python/backend_types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace py = pybind11;
1818

1919
void init_backend_types(py::module_ &m) {
2020
// bind enum class
21-
py::enum_<plssvm::backend_type>(m, "BackendType")
21+
py::enum_<plssvm::backend_type>(m, "BackendType", "Enum class for all possible backend types, all different SYCL implementations have the same backend type \"sycl\".")
2222
.value("AUTOMATIC", plssvm::backend_type::automatic, "the default backend; depends on the specified target platform")
2323
.value("OPENMP", plssvm::backend_type::openmp, "OpenMP to target CPUs only (currently no OpenMP target offloading support)")
2424
.value("HPX", plssvm::backend_type::hpx, "HPX to target CPUs only (currently no GPU executor support)")

bindings/Python/backends/adaptivecpp_csvm.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ void bind_adaptivecpp_csvms(py::module_ &m, const std::string &csvm_name) {
3535
using backend_csvm_type = plssvm::adaptivecpp::backend_csvm_type_t<csvm_type>;
3636

3737
// assemble docstrings
38+
const std::string class_docstring{ fmt::format("A {} using the AdaptiveCpp SYCL backend.", csvm_name) };
3839
const std::string param_docstring{ fmt::format("create an AdaptiveCpp SYCL {} with the provided parameters and optional SYCL specific keyword arguments", csvm_name) };
3940
const std::string target_param_docstring{ fmt::format("create an AdaptiveCpp SYCL {} with the provided target platform, parameters, and optional SYCL specific keyword arguments", csvm_name) };
4041
const std::string kwargs_docstring{ fmt::format("create an AdaptiveCpp SYCL {} with the provided keyword arguments (including optional SYCL specific keyword arguments)", csvm_name) };
4142
const std::string target_kwargs_docstring{ fmt::format("create an AdaptiveCpp SYCL {} with the provided target platform and keyword arguments (including optional SYCL specific keyword arguments)", csvm_name) };
4243

43-
py::class_<backend_csvm_type, plssvm::adaptivecpp::csvm, csvm_type>(m, csvm_name.c_str())
44+
py::class_<backend_csvm_type, plssvm::adaptivecpp::csvm, csvm_type>(m, csvm_name.c_str(), class_docstring.c_str())
4445
.def(py::init([](const plssvm::parameter params, const py::kwargs &args) {
4546
// check for valid keys
4647
plssvm::bindings::python::util::check_kwargs_for_correctness(args, { "sycl_kernel_invocation_type" });
@@ -81,7 +82,10 @@ void bind_adaptivecpp_csvms(py::module_ &m, const std::string &csvm_name) {
8182
return std::make_unique<backend_csvm_type>(target, params, plssvm::sycl_kernel_invocation_type = invocation);
8283
}),
8384
target_kwargs_docstring.c_str())
84-
.def("get_kernel_invocation_type", &plssvm::adaptivecpp::csvm::get_kernel_invocation_type, "get the kernel invocation type used in this SYCL C-SVM");
85+
.def("get_kernel_invocation_type", &plssvm::adaptivecpp::csvm::get_kernel_invocation_type, "get the kernel invocation type used in this SYCL C-SVM")
86+
.def("__repr__", [csvm_name](const backend_csvm_type &self) {
87+
return fmt::format("<plssvm.adaptivecpp.{} with {{ #devices: {}, kernel_invocation_type: {} }}>", csvm_name, self.num_available_devices(), self.get_kernel_invocation_type());
88+
});
8589
}
8690

8791
} // namespace

bindings/Python/backends/cuda_csvm.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ void bind_cuda_csvms(py::module_ &m, const std::string &csvm_name) {
3434
using backend_csvm_type = plssvm::cuda::backend_csvm_type_t<csvm_type>;
3535

3636
// assemble docstrings
37+
const std::string class_docstring{ fmt::format("A {} using the CUDA backend.", csvm_name) };
3738
const std::string param_docstring{ fmt::format("create a CUDA {} with the provided parameters", csvm_name) };
3839
const std::string target_param_docstring{ fmt::format("create a CUDA {} with the provided target platform and parameters", csvm_name) };
3940
const std::string kwargs_docstring{ fmt::format("create a CUDA {} with the provided keyword arguments", csvm_name) };
4041
const std::string target_kwargs_docstring{ fmt::format("create a CUDA {} with the provided target platform and keyword arguments", csvm_name) };
4142

42-
py::class_<backend_csvm_type, plssvm::cuda::csvm, csvm_type>(m, csvm_name.c_str())
43+
py::class_<backend_csvm_type, plssvm::cuda::csvm, csvm_type>(m, csvm_name.c_str(), class_docstring.c_str())
4344
.def(py::init<plssvm::parameter>(), param_docstring.c_str())
4445
.def(py::init<plssvm::target_platform, plssvm::parameter>(), target_param_docstring.c_str())
4546
.def(py::init([](const py::kwargs &args) {
@@ -59,7 +60,10 @@ void bind_cuda_csvms(py::module_ &m, const std::string &csvm_name) {
5960
// create C-SVM with the provided target platform
6061
return std::make_unique<backend_csvm_type>(target, params);
6162
}),
62-
target_kwargs_docstring.c_str());
63+
target_kwargs_docstring.c_str())
64+
.def("__repr__", [csvm_name](const backend_csvm_type &self) {
65+
return fmt::format("<plssvm.cuda.{} with {{ #devices: {} }}>", csvm_name, self.num_available_devices());
66+
});
6367
}
6468

6569
} // namespace

bindings/Python/backends/dpcpp_csvm.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ void bind_dpcpp_csvms(py::module_ &m, const std::string &csvm_name) {
3535
using backend_csvm_type = plssvm::dpcpp::backend_csvm_type_t<csvm_type>;
3636

3737
// assemble docstrings
38+
const std::string class_docstring{ fmt::format("A {} using the DPC++ SYCL backend.", csvm_name) };
3839
const std::string param_docstring{ fmt::format("create a DPC++ SYCL {} with the provided parameters and optional SYCL specific keyword arguments", csvm_name) };
3940
const std::string target_param_docstring{ fmt::format("create a DPC++ SYCL {} with the provided target platform, parameters, and optional SYCL specific keyword arguments", csvm_name) };
4041
const std::string kwargs_docstring{ fmt::format("create a DPC++ SYCL {} with the provided keyword arguments (including optional SYCL specific keyword arguments)", csvm_name) };
4142
const std::string target_kwargs_docstring{ fmt::format("create a DPC++ SYCL {} with the provided target platform and keyword arguments (including optional SYCL specific keyword arguments)", csvm_name) };
4243

43-
py::class_<backend_csvm_type, plssvm::dpcpp::csvm, csvm_type>(m, csvm_name.c_str())
44+
py::class_<backend_csvm_type, plssvm::dpcpp::csvm, csvm_type>(m, csvm_name.c_str(), class_docstring.c_str())
4445
.def(py::init([](const plssvm::parameter params, const py::kwargs &args) {
4546
// check for valid keys
4647
plssvm::bindings::python::util::check_kwargs_for_correctness(args, { "sycl_kernel_invocation_type" });
@@ -81,7 +82,10 @@ void bind_dpcpp_csvms(py::module_ &m, const std::string &csvm_name) {
8182
return std::make_unique<backend_csvm_type>(target, params, plssvm::sycl_kernel_invocation_type = invocation);
8283
}),
8384
target_kwargs_docstring.c_str())
84-
.def("get_kernel_invocation_type", &plssvm::dpcpp::csvm::get_kernel_invocation_type, "get the kernel invocation type used in this SYCL C-SVM");
85+
.def("get_kernel_invocation_type", &plssvm::dpcpp::csvm::get_kernel_invocation_type, "get the kernel invocation type used in this SYCL C-SVM")
86+
.def("__repr__", [csvm_name](const backend_csvm_type &self) {
87+
return fmt::format("<plssvm.dpcpp.{} with {{ #devices: {}, kernel_invocation_type: {} }}>", csvm_name, self.num_available_devices(), self.get_kernel_invocation_type());
88+
});
8589
}
8690

8791
} // namespace

bindings/Python/backends/hip_csvm.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ void bind_hip_csvms(py::module_ &m, const std::string &csvm_name) {
3434
using backend_csvm_type = plssvm::hip::backend_csvm_type_t<csvm_type>;
3535

3636
// assemble docstrings
37+
const std::string class_docstring{ fmt::format("A {} using the HIP backend.", csvm_name) };
3738
const std::string param_docstring{ fmt::format("create a HIP {} with the provided parameters", csvm_name) };
3839
const std::string target_param_docstring{ fmt::format("create a HIP {} with the provided target platform and parameters", csvm_name) };
3940
const std::string kwargs_docstring{ fmt::format("create a HIP {} with the provided keyword arguments", csvm_name) };
4041
const std::string target_kwargs_docstring{ fmt::format("create a HIP {} with the provided target platform and keyword arguments", csvm_name) };
4142

42-
py::class_<backend_csvm_type, plssvm::hip::csvm, csvm_type>(m, csvm_name.c_str())
43+
py::class_<backend_csvm_type, plssvm::hip::csvm, csvm_type>(m, csvm_name.c_str(), class_docstring.c_str())
4344
.def(py::init<plssvm::parameter>(), param_docstring.c_str())
4445
.def(py::init<plssvm::target_platform, plssvm::parameter>(), target_param_docstring.c_str())
4546
.def(py::init([](const py::kwargs &args) {
@@ -59,7 +60,10 @@ void bind_hip_csvms(py::module_ &m, const std::string &csvm_name) {
5960
// create C-SVM with the provided target platform
6061
return std::make_unique<backend_csvm_type>(target, params);
6162
}),
62-
target_kwargs_docstring.c_str());
63+
target_kwargs_docstring.c_str())
64+
.def("__repr__", [csvm_name](const backend_csvm_type &self) {
65+
return fmt::format("<plssvm.hip.{} with {{ #devices: {} }}>", csvm_name, self.num_available_devices());
66+
});
6367
}
6468

6569
} // namespace

bindings/Python/backends/hpx_csvm.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ void bind_hpx_csvms(py::module_ &m, const std::string &csvm_name) {
3535
using backend_csvm_type = plssvm::hpx::backend_csvm_type_t<csvm_type>;
3636

3737
// assemble docstrings
38+
const std::string class_docstring{ fmt::format("A {} using the HPX backend.", csvm_name) };
3839
const std::string param_docstring{ fmt::format("create an HPX {} with the provided parameters", csvm_name) };
3940
const std::string target_param_docstring{ fmt::format("create an HPX {} with the provided target platform and parameters", csvm_name) };
4041
const std::string kwargs_docstring{ fmt::format("create an HPX {} with the provided keyword arguments", csvm_name) };
4142
const std::string target_kwargs_docstring{ fmt::format("create an HPX {} with the provided target platform and keyword arguments", csvm_name) };
4243

43-
py::class_<backend_csvm_type, plssvm::hpx::csvm, csvm_type>(m, csvm_name.c_str())
44+
py::class_<backend_csvm_type, plssvm::hpx::csvm, csvm_type>(m, csvm_name.c_str(), class_docstring.c_str())
4445
.def(py::init<plssvm::parameter>(), param_docstring.c_str())
4546
.def(py::init<plssvm::target_platform, plssvm::parameter>(), target_param_docstring.c_str())
4647
.def(py::init([](const py::kwargs &args) {
@@ -60,7 +61,10 @@ void bind_hpx_csvms(py::module_ &m, const std::string &csvm_name) {
6061
// create C-SVM with the provided target platform
6162
return std::make_unique<backend_csvm_type>(target, params);
6263
}),
63-
target_kwargs_docstring.c_str());
64+
target_kwargs_docstring.c_str())
65+
.def("__repr__", [csvm_name](const backend_csvm_type &self) {
66+
return fmt::format("<plssvm.hpx.{} with {{ #devices: {} }}>", csvm_name, self.num_available_devices());
67+
});
6468
}
6569

6670
} // namespace

bindings/Python/backends/kokkos_csvm.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ void bind_kokkos_csvms(py::module_ &m, const std::string &csvm_name) {
3535
using backend_csvm_type = plssvm::kokkos::backend_csvm_type_t<csvm_type>;
3636

3737
// assemble docstrings
38+
const std::string class_docstring{ fmt::format("A {} using the Kokkos backend.", csvm_name) };
3839
const std::string param_docstring{ fmt::format("create a Kokkos {} with the provided parameters and optional Kokkos specific keyword arguments", csvm_name) };
3940
const std::string target_param_docstring{ fmt::format("create a Kokkos {} with the provided target platform, parameters, and optional Kokkos specific keyword arguments", csvm_name) };
4041
const std::string kwargs_docstring{ fmt::format("create a Kokkos {} with the provided keyword arguments (including optional Kokkos specific keyword arguments)", csvm_name) };
4142
const std::string target_kwargs_docstring{ fmt::format("create a Kokkos {} with the provided target platform and keyword arguments (including optional Kokkos specific keyword arguments)", csvm_name) };
4243

43-
py::class_<backend_csvm_type, plssvm::kokkos::csvm, csvm_type>(m, csvm_name.c_str())
44+
py::class_<backend_csvm_type, plssvm::kokkos::csvm, csvm_type>(m, csvm_name.c_str(), class_docstring.c_str())
4445
.def(py::init([](const plssvm::parameter params, const py::kwargs &args) {
4546
// check for valid keys
4647
plssvm::bindings::python::util::check_kwargs_for_correctness(args, { "kokkos_execution_space" });
@@ -81,7 +82,10 @@ void bind_kokkos_csvms(py::module_ &m, const std::string &csvm_name) {
8182
return std::make_unique<backend_csvm_type>(target, params, plssvm::kokkos_execution_space = space);
8283
}),
8384
target_kwargs_docstring.c_str())
84-
.def("get_execution_space", &plssvm::kokkos::csvm::get_execution_space, "get the Kokkos execution space used in this Kokkos C-SVM");
85+
.def("get_execution_space", &plssvm::kokkos::csvm::get_execution_space, "get the Kokkos execution space used in this Kokkos C-SVM")
86+
.def("__repr__", [csvm_name](const backend_csvm_type &self) {
87+
return fmt::format("<plssvm.kokkos.{} with {{ #devices: {}, execution_space: {} }}>", csvm_name, self.num_available_devices(), self.get_execution_space());
88+
});
8589
}
8690

8791
} // namespace

bindings/Python/backends/opencl_csvm.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ void bind_opencl_csvms(py::module_ &m, const std::string &csvm_name) {
3434
using backend_csvm_type = plssvm::opencl::backend_csvm_type_t<csvm_type>;
3535

3636
// assemble docstrings
37+
const std::string class_docstring{ fmt::format("A {} using the OpenCL backend.", csvm_name) };
3738
const std::string param_docstring{ fmt::format("create an OpenCL {} with provided parameters", csvm_name) };
3839
const std::string target_param_docstring{ fmt::format("create an OpenCL {} with the provided target platform and parameters", csvm_name) };
3940
const std::string kwargs_docstring{ fmt::format("create an OpenCL {} with the provided keyword arguments", csvm_name) };
4041
const std::string target_kwargs_docstring{ fmt::format("create an OpenCL {} with the provided target platform and keyword arguments", csvm_name) };
4142

42-
py::class_<backend_csvm_type, plssvm::opencl::csvm, csvm_type>(m, csvm_name.c_str())
43+
py::class_<backend_csvm_type, plssvm::opencl::csvm, csvm_type>(m, csvm_name.c_str(), class_docstring.c_str())
4344
.def(py::init<plssvm::parameter>(), param_docstring.c_str())
4445
.def(py::init<plssvm::target_platform, plssvm::parameter>(), target_param_docstring.c_str())
4546
.def(py::init([](const py::kwargs &args) {
@@ -59,7 +60,10 @@ void bind_opencl_csvms(py::module_ &m, const std::string &csvm_name) {
5960
// create C-SVM with the provided target platform
6061
return std::make_unique<backend_csvm_type>(target, params);
6162
}),
62-
target_kwargs_docstring.c_str());
63+
target_kwargs_docstring.c_str())
64+
.def("__repr__", [csvm_name](const backend_csvm_type &self) {
65+
return fmt::format("<plssvm.opencl.{} with {{ #devices: {} }}>", csvm_name, self.num_available_devices());
66+
});
6367
}
6468

6569
} // namespace

bindings/Python/backends/openmp_csvm.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ void bind_openmp_csvms(py::module_ &m, const std::string &csvm_name) {
3434
using backend_csvm_type = plssvm::openmp::backend_csvm_type_t<csvm_type>;
3535

3636
// assemble docstrings
37+
const std::string class_docstring{ fmt::format("A {} using the OpenMP backend.", csvm_name) };
3738
const std::string param_docstring{ fmt::format("create an OpenMP {} with the provided parameters", csvm_name) };
3839
const std::string target_param_docstring{ fmt::format("create an OpenMP {} with the provided target platform and parameters", csvm_name) };
3940
const std::string kwargs_docstring{ fmt::format("create an OpenMP {} with the provided keyword arguments", csvm_name) };
4041
const std::string target_kwargs_docstring{ fmt::format("create an OpenMP {} with the provided target platform and keyword arguments", csvm_name) };
4142

42-
py::class_<backend_csvm_type, plssvm::openmp::csvm, csvm_type>(m, csvm_name.c_str())
43+
py::class_<backend_csvm_type, plssvm::openmp::csvm, csvm_type>(m, csvm_name.c_str(), class_docstring.c_str())
4344
.def(py::init<plssvm::parameter>(), param_docstring.c_str())
4445
.def(py::init<plssvm::target_platform, plssvm::parameter>(), target_param_docstring.c_str())
4546
.def(py::init([](const py::kwargs &args) {
@@ -59,7 +60,10 @@ void bind_openmp_csvms(py::module_ &m, const std::string &csvm_name) {
5960
// create C-SVM with the provided target platform
6061
return std::make_unique<backend_csvm_type>(target, params);
6162
}),
62-
target_kwargs_docstring.c_str());
63+
target_kwargs_docstring.c_str())
64+
.def("__repr__", [csvm_name](const backend_csvm_type &self) {
65+
return fmt::format("<plssvm.openmp.{} with {{ #devices: {} }}>", csvm_name, self.num_available_devices());
66+
});
6367
}
6468

6569
} // namespace

bindings/Python/backends/stdpar_csvm.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void bind_stdpar_csvms(py::module_ &m, const std::string &csvm_name) {
3535
using backend_csvm_type = plssvm::stdpar::backend_csvm_type_t<csvm_type>;
3636

3737
// assemble docstrings
38+
const std::string class_docstring{ fmt::format("A {} using the stdpar backend.", csvm_name) };
3839
const std::string param_docstring{ fmt::format("create an stdpar {} with the provided parameters", csvm_name) };
3940
const std::string target_param_docstring{ fmt::format("create an stdpar {} with the provided target platform and parameters", csvm_name) };
4041
const std::string kwargs_docstring{ fmt::format("create an stdpar {} with the provided keyword arguments", csvm_name) };
@@ -60,7 +61,11 @@ void bind_stdpar_csvms(py::module_ &m, const std::string &csvm_name) {
6061
// create C-SVM with the provided target platform
6162
return std::make_unique<backend_csvm_type>(target, params);
6263
}),
63-
target_kwargs_docstring.c_str());
64+
target_kwargs_docstring.c_str())
65+
.def("get_implementation_type", &plssvm::stdpar::csvm::get_implementation_type, "get the stdpar implementation used in this stdpar C-SVM")
66+
.def("__repr__", [csvm_name](const backend_csvm_type &self) {
67+
return fmt::format("<plssvm.stdpar.{} with {{ #devices: {}, implementation_type: {} }}>", csvm_name, self.num_available_devices(), self.get_implementation_type());
68+
});
6469
}
6570

6671
} // namespace
@@ -71,7 +76,7 @@ void init_stdpar_csvm(py::module_ &m, const py::exception<plssvm::exception> &ba
7176
const py::module_ stdpar_pure_virtual_module = stdpar_module.def_submodule("__pure_virtual", "a module containing all pure-virtual stdpar backend specific functionality");
7277

7378
// bind the enum class
74-
py::enum_<plssvm::stdpar::implementation_type>(stdpar_module, "ImplementationType")
79+
py::enum_<plssvm::stdpar::implementation_type>(stdpar_module, "ImplementationType", "Enum class for all supported stdpar implementations in PLSSVM.")
7580
.value("NVHPC", plssvm::stdpar::implementation_type::nvhpc, "use NVIDIA's HPC SDK (NVHPC) compiler nvc++")
7681
.value("ROC_STDPAR", plssvm::stdpar::implementation_type::roc_stdpar, "use AMD's roc-stdpar compiler (patched LLVM)")
7782
.value("INTEL_LLVM", plssvm::stdpar::implementation_type::intel_llvm, "use Intel's LLVM compiler icpx")

0 commit comments

Comments
 (0)