diff --git a/.github/workflows/clang_format.yml b/.github/workflows/clang_format.yml new file mode 100644 index 000000000..971dfc865 --- /dev/null +++ b/.github/workflows/clang_format.yml @@ -0,0 +1,32 @@ +name: Formatting via clang-format + +# only trigger this action on specific events +on: + push: + branches: + - main + pull_request: + +jobs: + format: + runs-on: ubuntu-24.04 + steps: + # checkout repository + - name: Checkout PLSSVM + uses: actions/checkout@v4.1.1 + with: + path: PLSSVM + # install dependencies + - name: Dependencies + run: | + sudo apt install libomp-dev clang-format + # configure project via CMake + - name: Configure + run: | + cd PLSSVM + cmake --preset all -DPLSSVM_TARGET_PLATFORMS=cpu -DPLSSVM_ENABLE_FORMATTING=ON + # build project + - name: Generate + run: | + cd PLSSVM + cmake --build --preset all --target check-clang-format diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fd0c260f..205058908 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -627,6 +627,35 @@ target_link_libraries(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC fmt::fmt) list(POP_BACK CMAKE_MESSAGE_INDENT) +######################################################################################################################## +## enable automatic formatting using clang-format ## +######################################################################################################################## +option(PLSSVM_ENABLE_FORMATTING "Enable a formatting targets using clang-format." OFF) +if (PLSSVM_ENABLE_FORMATTING) + list(APPEND CMAKE_MESSAGE_INDENT "Formatting: ") + + ## install library to add a clang-format target + set(PLSSVM_format_VERSION 1b43a3989de33e44e2a4f1766e9842be1744eef6) + find_package(format QUIET) + if (format_FOUND) + message(STATUS "Found package format.") + else () + message(STATUS "Couldn't find package format. Building version ${PLSSVM_format_VERSION} from source.") + set(FORMAT_SKIP_CMAKE ON CACHE INTERNAL "" FORCE) + set(FORMAT_SKIP_CLANG OFF CACHE INTERNAL "" FORCE) + # fetch clang-format library + # TODO: use original library after PR (HIP support) has been merged + FetchContent_Declare(format + GIT_REPOSITORY https://github.com/breyerml/Format.cmake.git + GIT_TAG ${PLSSVM_format_VERSION} + QUIET + ) + FetchContent_MakeAvailable(format) + endif () + + list(POP_BACK CMAKE_MESSAGE_INDENT) +endif () + ######################################################################################################################## ## enable documentation generation via doxygen ## ######################################################################################################################## diff --git a/README.md b/README.md index e7de709b3..e07dbe6a4 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ General dependencies: - [doxygen](https://www.doxygen.nl/index.html) if documentation generation is enabled - [Pybind11 ≥ v2.13.3](https://github.com/pybind/pybind11) if Python bindings are enabled - [OpenMP](https://www.openmp.org/) 4.0 or newer (optional) to speed-up library utilities (like file parsing) +- [Format.cmake](https://github.com/TheLartians/Format.cmake) if auto formatting via clang-format is enabled; also requires at least clang-format-18 and git - multiple Python modules used in the utility scripts, to install all modules use `pip install --user -r install/python_requirements.txt` Additional dependencies for the OpenMP backend: @@ -276,6 +277,7 @@ The `[optional_options]` can be one or multiple of: - `PLSSVM_ENABLE_TESTING=ON|OFF` (default: `ON`): enable testing using GoogleTest and ctest - `PLSSVM_ENABLE_LANGUAGE_BINDINGS=ON|OFF` (default: `OFF`): enable language bindings - `PLSSVM_STL_DEBUG_MODE_FLAGS=ON|OFF` (default: `OFF`): enable STL debug modes (**note**: changes the resulting library's ABI!) +- `PLSSVM_ENABLE_FORMATTING=ON|OFF` (default: `OFF`): enable automatic formatting using clang-format; adds additional targets `check-clang-format`, `clang-format`, and `fix-clang-format` If `PLSSVM_ENABLE_TESTING` is set to `ON`, the following option can also be set: @@ -432,6 +434,23 @@ cmake --build . -- coverage The resulting `html` coverage report is located in the `coverage` folder in the build directory. +### Automatic Source File Formatting + +To enable automatic formatting `PLSSVM_ENABLE_FORMATTING` must be set to `ON` and a `clang-format` and `git` executables must be available in `PATH` (minimum `clang-format` version is 18). + +To check whether formatting changes must be applied use: + +```bash +cmake --build . --target check-clang-format +``` + +To auto format all files use: + +```bash +cmake --build . --target clang-format +cmake --build . --target fix-clang-format +``` + ### Creating the Documentation If doxygen is installed and `PLSSVM_ENABLE_DOCUMENTATION` is set to `ON` the documentation can be build using diff --git a/bindings/Python/detail/tracking/performance_tracker.cpp b/bindings/Python/detail/tracking/performance_tracker.cpp index ea13e68e6..53abdc23c 100644 --- a/bindings/Python/detail/tracking/performance_tracker.cpp +++ b/bindings/Python/detail/tracking/performance_tracker.cpp @@ -8,8 +8,8 @@ #include "plssvm/detail/tracking/performance_tracker.hpp" // plssvm::detail::tracking::{global_tracker, tracking_entry} -#include "plssvm/detail/tracking/events.hpp" // plssvm::detail::tracking::events -#include "plssvm/parameter.hpp" // plssvm::parameter +#include "plssvm/detail/tracking/events.hpp" // plssvm::detail::tracking::events +#include "plssvm/parameter.hpp" // plssvm::parameter #include "pybind11/chrono.h" // automatic bindings for std::chrono::milliseconds #include "pybind11/pybind11.h" // py::module_ diff --git a/bindings/Python/sklearn.cpp b/bindings/Python/sklearn.cpp index f94b5a572..e94e05cd8 100644 --- a/bindings/Python/sklearn.cpp +++ b/bindings/Python/sklearn.cpp @@ -66,10 +66,10 @@ void parse_provided_params(svc &self, const py::kwargs &args) { kernel = plssvm::kernel_function_type::rbf; } else if (kernel_str == "sigmoid") { kernel = plssvm::kernel_function_type::sigmoid; - } else if (kernel_str == "laplacian") { - kernel = plssvm::kernel_function_type::laplacian; - } else if (kernel_str == "chi_squared") { - kernel = plssvm::kernel_function_type::chi_squared; + } else if (kernel_str == "laplacian") { + kernel = plssvm::kernel_function_type::laplacian; + } else if (kernel_str == "chi_squared") { + kernel = plssvm::kernel_function_type::chi_squared; } else if (kernel_str == "precomputed") { throw py::attribute_error{ R"(The "kernel = 'precomputed'" parameter for a call to the 'SVC' constructor is not implemented yet!)" }; } else { diff --git a/include/plssvm/backends/HIP/kernel/detail/fill_kernel.hip.hpp b/include/plssvm/backends/HIP/kernel/detail/fill_kernel.hip.hpp index ff9fd877a..710a759f2 100644 --- a/include/plssvm/backends/HIP/kernel/detail/fill_kernel.hip.hpp +++ b/include/plssvm/backends/HIP/kernel/detail/fill_kernel.hip.hpp @@ -38,4 +38,4 @@ __global__ void fill_array(value_type *data, const value_type value, const size_ } // namespace plssvm::hip::detail -#endif // PLSSVM_BACKENDS_HIP_DETAIL_FILL_KERNEL_HPP_ \ No newline at end of file +#endif // PLSSVM_BACKENDS_HIP_DETAIL_FILL_KERNEL_HPP_ diff --git a/include/plssvm/backends/OpenCL/detail/pinned_memory.hpp b/include/plssvm/backends/OpenCL/detail/pinned_memory.hpp index fec786aa8..c4c1b1cd4 100644 --- a/include/plssvm/backends/OpenCL/detail/pinned_memory.hpp +++ b/include/plssvm/backends/OpenCL/detail/pinned_memory.hpp @@ -88,6 +88,6 @@ class [[nodiscard]] pinned_memory final : public ::plssvm::detail::host_pinned_m extern template class pinned_memory; extern template class pinned_memory; -} // namespace plssvm::adaptivecpp::detail +} // namespace plssvm::opencl::detail #endif // PLSSVM_BACKENDS_OPENCL_DETAIL_PINNED_MEMORY_HPP_ diff --git a/include/plssvm/backends/SYCL/DPCPP/detail/pinned_memory.hpp b/include/plssvm/backends/SYCL/DPCPP/detail/pinned_memory.hpp index 737e4490d..4495b2861 100644 --- a/include/plssvm/backends/SYCL/DPCPP/detail/pinned_memory.hpp +++ b/include/plssvm/backends/SYCL/DPCPP/detail/pinned_memory.hpp @@ -88,6 +88,6 @@ class [[nodiscard]] pinned_memory final : public ::plssvm::detail::host_pinned_m extern template class pinned_memory; extern template class pinned_memory; -} // namespace plssvm::adaptivecpp::detail +} // namespace plssvm::dpcpp::detail #endif // PLSSVM_BACKENDS_SYCL_DPCPP_DETAIL_PINNED_MEMORY_HPP_ diff --git a/include/plssvm/backends/execution_range.hpp b/include/plssvm/backends/execution_range.hpp index 52c78f8e1..3f4bae359 100644 --- a/include/plssvm/backends/execution_range.hpp +++ b/include/plssvm/backends/execution_range.hpp @@ -161,7 +161,6 @@ struct execution_range { /// The grids. Multiple grids are used, if the grid sizes would exceed the maximum allowed number. Also stores the offsets for the respective grids used in the kernels. /// Note: no default initialization due to a linker error occurring with NVIDIA's nvhpc! std::vector grids; - }; /** diff --git a/include/plssvm/backends/gpu_device_ptr.hpp b/include/plssvm/backends/gpu_device_ptr.hpp index 7d364253b..e1b47a5c8 100644 --- a/include/plssvm/backends/gpu_device_ptr.hpp +++ b/include/plssvm/backends/gpu_device_ptr.hpp @@ -32,7 +32,7 @@ template , - "Illegal real type provided! See the 'real_type_list' in the type_list.hpp header for a list of the allowed types."); + "Illegal real type provided! See the 'real_type_list' in the type_list.hpp header for a list of the allowed types."); public: /// The type of the values used in the device_ptr. @@ -370,7 +370,6 @@ class gpu_device_ptr { device_pointer_type data_{}; }; - template gpu_device_ptr::gpu_device_ptr(const size_type size, const queue_type queue) : queue_{ queue }, diff --git a/include/plssvm/backends/stdpar/csvm.hpp b/include/plssvm/backends/stdpar/csvm.hpp index 526118cad..8473a7d6d 100644 --- a/include/plssvm/backends/stdpar/csvm.hpp +++ b/include/plssvm/backends/stdpar/csvm.hpp @@ -119,7 +119,7 @@ class csvm : public ::plssvm::csvm { */ [[nodiscard]] implementation_type get_implementation_type() const noexcept; - protected: + protected: /** * @copydoc plssvm::csvm::get_device_memory */ diff --git a/include/plssvm/backends/stdpar/kernel/kernel_functions.hpp b/include/plssvm/backends/stdpar/kernel/kernel_functions.hpp index 3bd2d6a99..8d86925c2 100644 --- a/include/plssvm/backends/stdpar/kernel/kernel_functions.hpp +++ b/include/plssvm/backends/stdpar/kernel/kernel_functions.hpp @@ -16,8 +16,8 @@ #include "plssvm/constants.hpp" // plssvm::real_type #include "plssvm/kernel_function_types.hpp" // plssvm::kernel_function_type -#if defined(PLSSVM_STDPAR_BACKEND_HAS_INTEL_LLVM) // TODO: remove after linker error is fixed on AMD GPUs - #include "sycl/sycl.hpp" // override std::* math functions +#if defined(PLSSVM_STDPAR_BACKEND_HAS_INTEL_LLVM) // TODO: remove after linker error is fixed on AMD GPUs + #include "sycl/sycl.hpp" // override std::* math functions #endif #if defined(PLSSVM_STDPAR_BACKEND_HAS_HIPSTDPAR) diff --git a/include/plssvm/csvm_factory.hpp b/include/plssvm/csvm_factory.hpp index 0b923caa0..01a2769ec 100644 --- a/include/plssvm/csvm_factory.hpp +++ b/include/plssvm/csvm_factory.hpp @@ -158,7 +158,7 @@ template * @return the C-SVM (`[[nodiscard]]`) */ template -[[nodiscard]] inline std::unique_ptr make_csvm(const backend_type backend, Args ...args) { +[[nodiscard]] inline std::unique_ptr make_csvm(const backend_type backend, Args... args) { return detail::make_csvm_impl(backend, args...); } @@ -170,7 +170,7 @@ template * @return the C-SVM (`[[nodiscard]]`) */ template -[[nodiscard]] inline std::unique_ptr make_csvm(Args ...args) { +[[nodiscard]] inline std::unique_ptr make_csvm(Args... args) { return detail::make_csvm_impl(backend_type::automatic, args...); } diff --git a/include/plssvm/detail/io/scaling_factors_parsing.hpp b/include/plssvm/detail/io/scaling_factors_parsing.hpp index d9893aa2e..2fa87de94 100644 --- a/include/plssvm/detail/io/scaling_factors_parsing.hpp +++ b/include/plssvm/detail/io/scaling_factors_parsing.hpp @@ -22,7 +22,7 @@ #include "plssvm/exceptions/exceptions.hpp" // plssvm::invalid_file_format_exception #include "fmt/format.h" // fmt::format -#include "fmt/os.h" // fmt::ostream, fmt::output_file +#include "fmt/os.h" // fmt::ostream, fmt::output_file #include // std::exception_ptr, std::exception, std::current_exception, std::rethrow_exception #include // std::string diff --git a/src/main_scale.cpp b/src/main_scale.cpp index 1253df454..365f2eb2c 100644 --- a/src/main_scale.cpp +++ b/src/main_scale.cpp @@ -17,7 +17,7 @@ #include "plssvm/detail/utility.hpp" // PLSSVM_IS_DEFINED #if defined(PLSSVM_HARDWARE_SAMPLING_ENABLED) - #include "hws/system_hardware_sampler.hpp" // hws::system_hardware_sampler + #include "hws/system_hardware_sampler.hpp" // hws::system_hardware_sampler #endif #include // std::for_each diff --git a/src/plssvm/backends/OpenCL/detail/command_queue.cpp b/src/plssvm/backends/OpenCL/detail/command_queue.cpp index 211329cf5..642f7409a 100644 --- a/src/plssvm/backends/OpenCL/detail/command_queue.cpp +++ b/src/plssvm/backends/OpenCL/detail/command_queue.cpp @@ -16,8 +16,8 @@ #include "CL/cl.h" // cl_context, cl_command_queue, cl_device_id, clCreateCommandQueueWithProperties, clCreateCommandQueue, clReleaseCommandQueue -#include // std::terminate -#include // std::cerr, std::endl +#include // std::terminate +#include // std::cerr, std::endl #include // std::addressof #include // std::is_same_v #include // std::exchange, std::move diff --git a/src/plssvm/backends/OpenCL/detail/context.cpp b/src/plssvm/backends/OpenCL/detail/context.cpp index e534e079d..0231ec12e 100644 --- a/src/plssvm/backends/OpenCL/detail/context.cpp +++ b/src/plssvm/backends/OpenCL/detail/context.cpp @@ -26,7 +26,7 @@ context::context(context &&other) noexcept : platform{ std::exchange(other.platform, nullptr) }, devices{ std::move(other.devices) } { } -context &context::operator=(context &&other)noexcept { +context &context::operator=(context &&other) noexcept { if (this != std::addressof(other)) { other.device_context = std::exchange(other.device_context, nullptr); platform = std::exchange(other.platform, nullptr); diff --git a/src/plssvm/backends/stdpar/detail/utility.cpp b/src/plssvm/backends/stdpar/detail/utility.cpp index b6b501baa..1c5cea958 100644 --- a/src/plssvm/backends/stdpar/detail/utility.cpp +++ b/src/plssvm/backends/stdpar/detail/utility.cpp @@ -51,16 +51,16 @@ std::string get_stdpar_version() { #if defined(PLSSVM_STDPAR_BACKEND_HAS_ACPP) return plssvm::adaptivecpp::detail::get_adaptivecpp_version_short(); #elif defined(PLSSVM_STDPAR_BACKEND_HAS_NVHPC) -#if defined(PLSSVM_STDPAR_BACKEND_NVHPC_GPU) + #if defined(PLSSVM_STDPAR_BACKEND_NVHPC_GPU) int runtime_version{}; cudaRuntimeGetVersion(&runtime_version); // parse it to a more useful string int major_version = runtime_version / 1000; int minor_version = runtime_version % 1000 / 10; return fmt::format("{}.{}.{}; {}.{}", __NVCOMPILER_MAJOR__, __NVCOMPILER_MINOR__, __NVCOMPILER_PATCHLEVEL__, major_version, minor_version); -#else + #else return fmt::format("{}.{}.{}", __NVCOMPILER_MAJOR__, __NVCOMPILER_MINOR__, __NVCOMPILER_PATCHLEVEL__); -#endif + #endif #elif defined(PLSSVM_STDPAR_BACKEND_HAS_INTEL_LLVM) return fmt::format("{}", __VERSION__); #elif defined(PLSSVM_STDPAR_BACKEND_HAS_GNU_TBB) diff --git a/src/plssvm/detail/cmd/parser_predict.cpp b/src/plssvm/detail/cmd/parser_predict.cpp index 88e91bb2c..c1a8a5be3 100644 --- a/src/plssvm/detail/cmd/parser_predict.cpp +++ b/src/plssvm/detail/cmd/parser_predict.cpp @@ -17,8 +17,8 @@ #include "plssvm/verbosity_levels.hpp" // plssvm::verbosity, plssvm::verbosity_level #include "plssvm/version/version.hpp" // plssvm::version::detail::get_version_info -#include "cxxopts.hpp" // cxxopts::{Options, value, ParseResult} -#include "fmt/color.h" // fmt::fg, fmt::color::orange +#include "cxxopts.hpp" // cxxopts::{Options, value, ParseResult} +#include "fmt/color.h" // fmt::fg, fmt::color::orange #include "fmt/format.h" // fmt::format #include "fmt/ranges.h" // fmt::join diff --git a/src/plssvm/detail/cmd/parser_scale.cpp b/src/plssvm/detail/cmd/parser_scale.cpp index 26f7220b6..4df557a07 100644 --- a/src/plssvm/detail/cmd/parser_scale.cpp +++ b/src/plssvm/detail/cmd/parser_scale.cpp @@ -13,8 +13,8 @@ #include "plssvm/verbosity_levels.hpp" // plssvm::verbosity, plssvm::verbosity_level #include "plssvm/version/version.hpp" // plssvm::version::detail::get_version_info -#include "cxxopts.hpp" // cxxopts::{Options, value, ParseResult} -#include "fmt/color.h" // fmt::fg, fmt::color::red +#include "cxxopts.hpp" // cxxopts::{Options, value, ParseResult} +#include "fmt/color.h" // fmt::fg, fmt::color::red #include "fmt/format.h" // fmt::format #include "fmt/ranges.h" // fmt::join diff --git a/tests/backends/CUDA/cuda_csvm.cpp b/tests/backends/CUDA/cuda_csvm.cpp index 39fdb5e0d..d6b92b887 100644 --- a/tests/backends/CUDA/cuda_csvm.cpp +++ b/tests/backends/CUDA/cuda_csvm.cpp @@ -159,4 +159,4 @@ using cuda_mock_kernel_function_type_gtest = util::combine_test_parameters_gtest // generic GPU CSVM tests - mocked grid sizes INSTANTIATE_TYPED_TEST_SUITE_P(CUDACSVMFakedGridSize, GenericGPUCSVM, cuda_mock_csvm_test_type_gtest, naming::test_parameter_to_name); -INSTANTIATE_TYPED_TEST_SUITE_P(CUDACSVMFakedGridSize, GenericGPUCSVMKernelFunction, cuda_mock_kernel_function_type_gtest, naming::test_parameter_to_name); \ No newline at end of file +INSTANTIATE_TYPED_TEST_SUITE_P(CUDACSVMFakedGridSize, GenericGPUCSVMKernelFunction, cuda_mock_kernel_function_type_gtest, naming::test_parameter_to_name); diff --git a/tests/backends/OpenCL/opencl_csvm.cpp b/tests/backends/OpenCL/opencl_csvm.cpp index 7c2458ec0..dd939fc1a 100644 --- a/tests/backends/OpenCL/opencl_csvm.cpp +++ b/tests/backends/OpenCL/opencl_csvm.cpp @@ -157,4 +157,4 @@ using opencl_mock_kernel_function_type_gtest = util::combine_test_parameters_gte // generic GPU CSVM tests - mocked grid sizes INSTANTIATE_TYPED_TEST_SUITE_P(OpenCLCSVMFakedGridSize, GenericGPUCSVM, opencl_mock_csvm_test_type_gtest, naming::test_parameter_to_name); -INSTANTIATE_TYPED_TEST_SUITE_P(OpenCLCSVMFakedGridSize, GenericGPUCSVMKernelFunction, opencl_mock_kernel_function_type_gtest, naming::test_parameter_to_name); \ No newline at end of file +INSTANTIATE_TYPED_TEST_SUITE_P(OpenCLCSVMFakedGridSize, GenericGPUCSVMKernelFunction, opencl_mock_kernel_function_type_gtest, naming::test_parameter_to_name); diff --git a/tests/backends/SYCL/DPCPP/mock_dpcpp_csvm.hpp b/tests/backends/SYCL/DPCPP/mock_dpcpp_csvm.hpp index b081fda75..88b6c15cf 100644 --- a/tests/backends/SYCL/DPCPP/mock_dpcpp_csvm.hpp +++ b/tests/backends/SYCL/DPCPP/mock_dpcpp_csvm.hpp @@ -13,15 +13,14 @@ #define PLSSVM_TESTS_BACKENDS_SYCL_DPCPP_MOCK_DPCPP_CSVM_HPP_ #pragma once -#include "plssvm/backends/SYCL/DPCPP/csvm.hpp" // plssvm::dpcpp::csvm #include "plssvm/backends/execution_range.hpp" // plssvm::detail::dim_type +#include "plssvm/backends/SYCL/DPCPP/csvm.hpp" // plssvm::dpcpp::csvm #include "gmock/gmock.h" // MOCK_METHOD, ON_CALL, ::testing::Return #include // std::size_t #include // std::forward - /** * @brief GTest mock class for the SYCL CSVM using DPC++ as SYCL implementation. * @tparam mock_grid_size `true` if the `plssvm::dpcpp::csvm::get_max_grid_size()` function should be mocked, otherwise `false` diff --git a/tests/backends/ground_truth.cpp b/tests/backends/ground_truth.cpp index d1437fed6..640b88fde 100644 --- a/tests/backends/ground_truth.cpp +++ b/tests/backends/ground_truth.cpp @@ -17,11 +17,11 @@ #include "plssvm/parameter.hpp" // plssvm::parameter #include "plssvm/shape.hpp" // plssvm::shape -#include // std::pow, std::exp, std::fma -#include // std::size_t -#include // std::pair, std::make_pair, std::move -#include // std::get -#include // std::vector +#include // std::pow, std::exp, std::fma +#include // std::size_t +#include // std::pair, std::make_pair, std::move +#include // std::get +#include // std::vector namespace ground_truth { @@ -116,7 +116,6 @@ real_type chi_squared_kernel(const std::vector &x, const std::vector< template float chi_squared_kernel(const std::vector &, const std::vector &, const float); template double chi_squared_kernel(const std::vector &, const std::vector &, const double); - template real_type linear_kernel(const plssvm::matrix &X, const std::size_t i, const plssvm::matrix &Y, const std::size_t j) { PLSSVM_ASSERT(X.num_cols() == Y.num_cols(), "Sizes mismatch!: {} != {}", X.num_cols(), Y.num_cols()); @@ -364,7 +363,6 @@ plssvm::aos_matrix predict_values(const plssvm::parameter ¶ms, co template plssvm::aos_matrix predict_values(const plssvm::parameter &, const plssvm::soa_matrix &, const plssvm::aos_matrix &, const std::vector &, const plssvm::soa_matrix &, const plssvm::soa_matrix &, const std::size_t, const std::size_t); template plssvm::aos_matrix predict_values(const plssvm::parameter &, const plssvm::soa_matrix &, const plssvm::aos_matrix &, const std::vector &, const plssvm::soa_matrix &, const plssvm::soa_matrix &, const std::size_t, const std::size_t); - } // namespace detail template diff --git a/tests/backends/ground_truth.hpp b/tests/backends/ground_truth.hpp index 61f69bc65..ffa7c5d8c 100644 --- a/tests/backends/ground_truth.hpp +++ b/tests/backends/ground_truth.hpp @@ -185,7 +185,6 @@ template template [[nodiscard]] plssvm::aos_matrix predict_values(const plssvm::parameter ¶ms, const plssvm::soa_matrix &w, const plssvm::aos_matrix &weights, const std::vector &rho, const plssvm::soa_matrix &support_vectors, const plssvm::soa_matrix &predict_points, std::size_t row_offset, std::size_t device_specific_num_rows); - } // namespace detail /** diff --git a/tests/backends/stdpar/implementation_types.cpp b/tests/backends/stdpar/implementation_types.cpp index 2f6d6db61..b8fcf1268 100644 --- a/tests/backends/stdpar/implementation_types.cpp +++ b/tests/backends/stdpar/implementation_types.cpp @@ -71,11 +71,11 @@ TEST(stdparImplementationType, from_string_unknown) { TEST(stdparImplementationType, minimal_available_stdpar_implementation_type) { const std::vector implementation_type = plssvm::stdpar::list_available_stdpar_implementations(); - #if defined(PLSSVM_HAS_STDPAR_BACKEND) - // at least one must be available! - EXPECT_GE(implementation_type.size(), 1); - #else - // stdpar not active -> no implementation type available - EXPECT_TRUE(implementation_type.empty()); - #endif +#if defined(PLSSVM_HAS_STDPAR_BACKEND) + // at least one must be available! + EXPECT_GE(implementation_type.size(), 1); +#else + // stdpar not active -> no implementation type available + EXPECT_TRUE(implementation_type.empty()); +#endif } diff --git a/tests/classification_report.cpp b/tests/classification_report.cpp index 064039891..dbcb860bd 100644 --- a/tests/classification_report.cpp +++ b/tests/classification_report.cpp @@ -87,17 +87,17 @@ TEST_F(ZeroDivisionBehavior, sanitize_nan_one) { EXPECT_EQ(plssvm::detail::sanitize_nan(42.0, 1.0, plssvm::classification_report::zero_division_behavior::one, "Foo"), 42.0); } -//TEST_F(ZeroDivisionBehavior, sanitize_nan_nan) { -// // sanitize NaN using nan -//#if !defined(PLSSVM_USE_FAST_MATH) || defined(_MSC_VER) -// // ATTENTION: MSVC doesn't optimize out the NaN check even if fast math is used -// EXPECT_TRUE(std::isnan(plssvm::detail::sanitize_nan(42.0, 0.0, plssvm::classification_report::zero_division_behavior::nan, "Foo"))); -//#else -// // ATTENTION: std::isnan will ALWAYS return false due to -ffast-math being enabled in release mode (in GCC and clang) -// EXPECT_FALSE(std::isnan(plssvm::detail::sanitize_nan(42.0, 0.0, plssvm::classification_report::zero_division_behavior::nan, "Foo"))); -//#endif -// EXPECT_EQ(plssvm::detail::sanitize_nan(42.0, 1.0, plssvm::classification_report::zero_division_behavior::nan, "Foo"), 42.0); -//} +// TEST_F(ZeroDivisionBehavior, sanitize_nan_nan) { +// // sanitize NaN using nan +// #if !defined(PLSSVM_USE_FAST_MATH) || defined(_MSC_VER) +// // ATTENTION: MSVC doesn't optimize out the NaN check even if fast math is used +// EXPECT_TRUE(std::isnan(plssvm::detail::sanitize_nan(42.0, 0.0, plssvm::classification_report::zero_division_behavior::nan, "Foo"))); +// #else +// // ATTENTION: std::isnan will ALWAYS return false due to -ffast-math being enabled in release mode (in GCC and clang) +// EXPECT_FALSE(std::isnan(plssvm::detail::sanitize_nan(42.0, 0.0, plssvm::classification_report::zero_division_behavior::nan, "Foo"))); +// #endif +// EXPECT_EQ(plssvm::detail::sanitize_nan(42.0, 1.0, plssvm::classification_report::zero_division_behavior::nan, "Foo"), 42.0); +// } //*************************************************************************************************************************************// // metrics // diff --git a/tests/data_set/getter.cpp b/tests/data_set/getter.cpp index b4e995d45..9f5d4b7b7 100644 --- a/tests/data_set/getter.cpp +++ b/tests/data_set/getter.cpp @@ -18,7 +18,7 @@ #include "tests/types_to_test.hpp" // util::{label_type_gtest, test_parameter_type_at_t} #include "tests/utility.hpp" // util::{redirect_output, scale} -#include "gtest/gtest.h" // TYPED_TEST, TYPED_TEST_SUITE, EXPECT_TRUE, EXPECT_FALSE, EXPECT_EQ, ASSERT_TRUE, ::testing::Test +#include "gtest/gtest.h" // TYPED_TEST, TYPED_TEST_SUITE, EXPECT_TRUE, EXPECT_FALSE, EXPECT_EQ, ASSERT_TRUE, ::testing::Test #include // std::size_t #include // std::get diff --git a/tests/detail/operators.cpp b/tests/detail/operators.cpp index 94fb8b455..b323dcc3a 100644 --- a/tests/detail/operators.cpp +++ b/tests/detail/operators.cpp @@ -465,4 +465,4 @@ TYPED_TEST(VectorOperationsDeathTest, operator_manhattan_dist) { // try to calculate the Manhattan distance between two vectors with different distance EXPECT_DEATH(std::ignore = manhattan_dist(this->get_a(), this->get_b()), "Sizes mismatch!: 4 != 2"); EXPECT_DEATH(std::ignore = manhattan_dist(this->get_b(), this->get_a()), "Sizes mismatch!: 2 != 4"); -} \ No newline at end of file +} diff --git a/tests/detail/tracking/performance_tracker.cpp b/tests/detail/tracking/performance_tracker.cpp index b81542ee7..cc3eb9ee9 100644 --- a/tests/detail/tracking/performance_tracker.cpp +++ b/tests/detail/tracking/performance_tracker.cpp @@ -17,9 +17,9 @@ #include "plssvm/detail/memory_size.hpp" // plssvm::detail::memory_size (literals) #include "plssvm/detail/tracking/events.hpp" // plssvm::detail::tracking::{events, event} -#include "tests/naming.hpp" // naming::test_parameter_to_name -#include "tests/types_to_test.hpp" // util::{label_type_gtest, test_parameter_type_at_t} -#include "tests/utility.hpp" // util::redirect_output +#include "tests/naming.hpp" // naming::test_parameter_to_name +#include "tests/types_to_test.hpp" // util::{label_type_gtest, test_parameter_type_at_t} +#include "tests/utility.hpp" // util::redirect_output #include "fmt/format.h" // fmt::format #include "gmock/gmock.h" // EXPECT_CALL, EXPECT_THAT, ::testing::{HasSubstr} diff --git a/tests/kernel_function_types.cpp b/tests/kernel_function_types.cpp index f29c25e6b..864a2b0e9 100644 --- a/tests/kernel_function_types.cpp +++ b/tests/kernel_function_types.cpp @@ -10,7 +10,7 @@ #include "plssvm/kernel_function_types.hpp" -#include "tests/custom_test_macros.hpp" // EXPECT_CONVERSION_TO_STRING, EXPECT_CONVERSION_FROM_STRING +#include "tests/custom_test_macros.hpp" // EXPECT_CONVERSION_TO_STRING, EXPECT_CONVERSION_FROM_STRING #include "gtest/gtest.h" // TEST, EXPECT_EQ, EXPECT_TRUE diff --git a/tests/types_to_test.hpp b/tests/types_to_test.hpp index 44db342b3..8697247bd 100644 --- a/tests/types_to_test.hpp +++ b/tests/types_to_test.hpp @@ -462,8 +462,7 @@ using combine_test_parameters_gtest_t = typename combine_test_parameters_gtest kernel_functions_to_test{ - plssvm::kernel_function_type::linear, plssvm::kernel_function_type::polynomial, plssvm::kernel_function_type::rbf, - plssvm::kernel_function_type::sigmoid, plssvm::kernel_function_type::laplacian, plssvm::kernel_function_type::chi_squared + plssvm::kernel_function_type::linear, plssvm::kernel_function_type::polynomial, plssvm::kernel_function_type::rbf, plssvm::kernel_function_type::sigmoid, plssvm::kernel_function_type::laplacian, plssvm::kernel_function_type::chi_squared }; /// A list of all available layout types. constexpr std::array layout_types_to_test{