diff --git a/.cmake-format b/.cmake-format new file mode 100644 index 000000000..68a15f78c --- /dev/null +++ b/.cmake-format @@ -0,0 +1,249 @@ +# ---------------------------------- +# Options affecting listfile parsing +# ---------------------------------- +with section("parse"): + + # Specify structure for custom cmake functions + additional_commands = { 'foo': { 'flags': ['BAR', 'BAZ'], + 'kwargs': {'DEPENDS': '*', 'HEADERS': '*', 'SOURCES': '*'}}} + + # Override configurations per-command where available + override_spec = {} + + # Specify variable tags. + vartags = [] + + # Specify property tags. + proptags = [] + +# ----------------------------- +# Options affecting formatting. +# ----------------------------- +with section("format"): + + # Disable formatting entirely, making cmake-format a no-op + disable = False + + # How wide to allow formatted cmake files + line_width = 160 + + # How many spaces to tab for indent + tab_size = 4 + + # If true, lines are indented using tab characters (utf-8 0x09) instead of + # space characters (utf-8 0x20). In cases where the layout would + # require a fractional tab character, the behavior of the fractional + # indentation is governed by + use_tabchars = False + + # If is True, then the value of this variable indicates how + # fractional indentions are handled during whitespace replacement. If set to + # 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set + # to `round-up` fractional indentation is replaced with a single tab character + # (utf-8 0x09) effectively shifting the column to the next tabstop + fractional_tab_policy = 'use-space' + + # If an argument group contains more than this many sub-groups (parg or kwarg + # groups) then force it to a vertical layout. + max_subgroups_hwrap = 3 + + # If a positional argument group contains more than this many arguments, then + # force it to a vertical layout. + max_pargs_hwrap = 4 + + # If a cmdline positional group consumes more than this many lines without + # nesting, then invalidate the layout (and nest) + max_rows_cmdline = 3 + + # If true, separate flow control names from their parentheses with a space + separate_ctrl_name_with_space = True + + # If true, separate function names from parentheses with a space + separate_fn_name_with_space = False + + # If a statement is wrapped to more than one line, than dangle the closing + # parenthesis on its own line. + dangle_parens = True + + # If the trailing parenthesis must be 'dangled' on its on line, then align it + # to this reference: `prefix`: the start of the statement, `prefix-indent`: + # the start of the statement, plus one indentation level, `child`: align to + # the column of the arguments + dangle_align = 'prefix' + + # If the statement spelling length (including space and parenthesis) is + # smaller than this amount, then force reject nested layouts. + min_prefix_chars = 4 + + # If the statement spelling length (including space and parenthesis) is larger + # than the tab width by more than this amount, then force reject un-nested + # layouts. + max_prefix_chars = 12 + + # If a candidate layout is wrapped horizontally but it exceeds this many + # lines, then reject the layout. + max_lines_hwrap = 12 + + # What style line endings to use in the output. + line_ending = 'unix' + + # Format command names consistently as 'lower' or 'upper' case + command_case = 'canonical' + + # Format keywords consistently as 'lower' or 'upper' case + keyword_case = 'unchanged' + + # A list of command names which should always be wrapped + always_wrap = [ + "FetchContent_Declare", + "add_custom_target", + "find_path", + "gtest_discover_tests", + "execute_process", + "configure_package_config_file", + "write_basic_package_version_file" + ] + + # If true, the argument lists which are known to be sortable will be sorted + # lexicographicall + enable_sort = False + + # If true, the parsers may infer whether or not an argument list is sortable + # (without annotation). + autosort = False + + # By default, if cmake-format cannot successfully fit everything into the + # desired linewidth it will apply the last, most agressive attempt that it + # made. If this flag is True, however, cmake-format will print error, exit + # with non-zero status code, and write-out nothing + require_valid_layout = False + + # A dictionary mapping layout nodes to a list of wrap decisions. See the + # documentation for more information. + layout_passes = {} + +# ------------------------------------------------ +# Options affecting comment reflow and formatting. +# ------------------------------------------------ +with section("markup"): + + # What character to use for bulleted lists + bullet_char = '-' + + # What character to use as punctuation after numerals in an enumerated list + enum_char = '.' + + # If comment markup is enabled, don't reflow the first comment block in each + # listfile. Use this to preserve formatting of your copyright/license + # statements. + first_comment_is_literal = True + + # If comment markup is enabled, don't reflow any comment block which matches + # this (regex) pattern. Default is `None` (disabled). + literal_comment_pattern = '^[##]+' + + # Regular expression to match preformat fences in comments default= + # ``r'^\s*([`~]{3}[`~]*)(.*)$'`` + ruler_pattern = '^\s*([`~]{3}[`~]*)(.*)$' + + # Regular expression to match rulers in comments default= + # ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'`` + ruler_pattern = '^\s*[^\w\s]{3}.*[^\w\s]{3}$' + + # If a comment line matches starts with this pattern then it is explicitly a + # trailing comment for the preceeding argument. Default is '#<' + explicit_trailing_pattern = '#<' + + # If a comment line starts with at least this many consecutive hash + # characters, then don't lstrip() them off. This allows for lazy hash rulers + # where the first hash char is not separated by space + hashruler_min_length = 10 + + # If true, then insert a space between the first hash char and remaining hash + # chars in a hash ruler, and normalize its length to fill the column + canonicalize_hashrulers = False + + # enable comment markup parsing and reflow + enable_markup = True + +# ---------------------------- +# Options affecting the linter +# ---------------------------- +with section("lint"): + + # a list of lint codes to disable + disabled_codes = [] + + # regular expression pattern describing valid function names + function_pattern = '[0-9a-z_]+' + + # regular expression pattern describing valid macro names + macro_pattern = '[0-9A-Z_]+' + + # regular expression pattern describing valid names for variables with global + # (cache) scope + global_var_pattern = '[A-Z][0-9A-Z_]+' + + # regular expression pattern describing valid names for variables with global + # scope (but internal semantic) + internal_var_pattern = '_[A-Z][0-9A-Z_]+' + + # regular expression pattern describing valid names for variables with local + # scope + local_var_pattern = '[a-z][a-z0-9_]+' + + # regular expression pattern describing valid names for privatedirectory + # variables + private_var_pattern = '_[0-9a-z_]+' + + # regular expression pattern describing valid names for public directory + # variables + public_var_pattern = '[A-Z][0-9A-Z_]+' + + # regular expression pattern describing valid names for function/macro + # arguments and loop variables. + argument_var_pattern = '[a-z][a-z0-9_]+' + + # regular expression pattern describing valid names for keywords used in + # functions or macros + keyword_pattern = '[A-Z][0-9A-Z_]+' + + # In the heuristic for C0201, how many conditionals to match within a loop in + # before considering the loop a parser. + max_conditionals_custom_parser = 2 + + # Require at least this many newlines between statements + min_statement_spacing = 1 + + # Require no more than this many newlines between statements + max_statement_spacing = 2 + max_returns = 6 + max_branches = 12 + max_arguments = 5 + max_localvars = 15 + max_statements = 50 + +# ------------------------------- +# Options affecting file encoding +# ------------------------------- +with section("encode"): + + # If true, emit the unicode byte-order mark (BOM) at the start of the file + emit_byteorder_mark = False + + # Specify the encoding of the input file. Defaults to utf-8 + input_encoding = 'utf-8' + + # Specify the encoding of the output file. Defaults to utf-8. Note that cmake + # only claims to support utf-8 so be careful when using anything else + output_encoding = 'utf-8' + +# ------------------------------------- +# Miscellaneous configurations options. +# ------------------------------------- +with section("misc"): + + # A dictionary containing any per-command configuration overrides. Currently + # only `command_case` is supported. + per_command = {} + diff --git a/.github/workflows/clang_format.yml b/.github/workflows/clang_format.yml deleted file mode 100644 index 926ba6ab8..000000000 --- a/.github/workflows/clang_format.yml +++ /dev/null @@ -1,52 +0,0 @@ -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 - # install new CMake version - - name: "Install cmake 3.31.0" - uses: lukka/get-cmake@v3.31.0 - # configure project via CMake - - name: "Configure" - run: | - cd PLSSVM - cmake --preset all -DPLSSVM_TARGET_PLATFORMS="cpu" -DPLSSVM_ENABLE_FORMATTING=ON - # check formatting - - name: "Check Formatting" - run: | - set +e - cd PLSSVM - cmake --build --preset all --target check-clang-format - status=$? - if [ $status -ne 0 ]; then - echo "Formatting errors found!" - cmake --build --preset all --target clang-format > clang-format-patch.txt 2>&1 - exit $status - else - echo "No formatting errors found!" - fi - # upload the git patch, if available - - name: "Upload Patch" - if: always() - uses: actions/upload-artifact@v4 - with: - name: clang-format-patch - path: PLSSVM/clang-format-patch.txt - if-no-files-found: ignore \ No newline at end of file diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..20552191d --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,75 @@ +name: Formatting via cmake- and 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 + pip install "git+https://github.com/vancraar/cmake_format@master" + # install new CMake version + - name: "Install cmake 3.31.0" + uses: lukka/get-cmake@v3.31.0 + # configure project via CMake + - name: "Configure" + run: | + cd PLSSVM + cmake --preset all -DPLSSVM_TARGET_PLATFORMS="cpu" -DPLSSVM_ENABLE_FORMATTING=ON + # check source file formatting + - name: "Check source file formatting via clang-format" + run: | + set +e + cd PLSSVM + cmake --build --preset all --target check-clang-format + status=$? + if [ $status -ne 0 ]; then + echo "clang-format formatting errors found!" + cmake --build --preset all --target clang-format > clang-format-patch.txt 2>&1 + exit $status + else + echo "No clang-format formatting errors found!" + fi + # upload the clang-format git patch, if available + - name: "Upload clang-format patch" + if: always() + uses: actions/upload-artifact@v4 + with: + name: clang-format-patch + path: PLSSVM/clang-format-patch.txt + if-no-files-found: ignore + # check CMake formatting + - name: "Check CMake formatting via cmake-format" + run: | + set +e + cd PLSSVM + cmake --build --preset all --target check-cmake-format + status=$? + if [ $status -ne 0 ]; then + echo "cmake-format formatting errors found!" + cmake --build --preset all --target cmake-format > cmake-format-patch.txt 2>&1 + exit $status + else + echo "No cmake-format formatting errors found!" + fi + # upload the cmake-format git patch, if available + - name: "Upload cmake-format patch" + if: always() + uses: actions/upload-artifact@v4 + with: + name: cmake-format-patch + path: PLSSVM/cmake-format-patch.txt + if-no-files-found: ignore \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a03058e0..84e730eec 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,26 @@ -## Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## cmake_minimum_required(VERSION 3.25) -project("PLSSVM - Parallel Least Squares Support Vector Machine" - VERSION 3.0.0 - LANGUAGES CXX - DESCRIPTION "A Least Squares Support Vector Machine implementation using different backends.") +project( + "PLSSVM - Parallel Least Squares Support Vector Machine" + VERSION 3.0.0 + LANGUAGES CXX + DESCRIPTION "A Least Squares Support Vector Machine implementation using different backends." +) -## include some generally used utility scripts +# include some generally used utility scripts include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/add_coverage_build_type.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/utility_macros.cmake) -## add custom module files +# add custom module files list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") -## set default CMake build type +# set default CMake build type set(PLSSVM_DEFAULT_BUILD_TYPE "RelWithDebInfo") set(PLSSVM_ALLOWED_BUILD_TYPES "Debug;Release;MinSizeRel;RelWithDebInfo;Coverage") get_property(PLSSVM_IS_MULTI_CONFIG_GENERATOR GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) @@ -32,7 +34,10 @@ if (PLSSVM_IS_MULTI_CONFIG_GENERATOR) else () foreach (type IN LISTS CMAKE_CONFIGURATION_TYPES) if (NOT ${type} IN_LIST PLSSVM_ALLOWED_BUILD_TYPES) - message(FATAL_ERROR "Unrecognized build type '${type}' in multi-configuration '${CMAKE_CONFIGURATION_TYPES}'! Allowed build types are: ${PLSSVM_ALLOWED_BUILD_TYPES}") + message( + FATAL_ERROR + "Unrecognized build type '${type}' in multi-configuration '${CMAKE_CONFIGURATION_TYPES}'! Allowed build types are: ${PLSSVM_ALLOWED_BUILD_TYPES}" + ) endif () endforeach () message(STATUS "The multi-configuration build types are '${CMAKE_CONFIGURATION_TYPES}'.") @@ -54,23 +59,23 @@ else () endif () string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) -## add option to enable or disable fast-math in all backends (mainly used for tests) +# add option to enable or disable fast-math in all backends (mainly used for tests) if (uppercase_CMAKE_BUILD_TYPE MATCHES RELEASE OR uppercase_CMAKE_BUILD_TYPE MATCHES RELWITHDEBINFO) option(PLSSVM_ENABLE_FAST_MATH "Enables fast-math options for different targets. Default ON iff CMAKE_BUILD_TYPE=Release|RelWithDebInfo, else OFF." ON) else () option(PLSSVM_ENABLE_FAST_MATH "Enables fast-math options for different targets. Default ON iff CMAKE_BUILD_TYPE=Release|RelWithDebInfo, else OFF." OFF) endif () -## enable shared linkage for Windows +# enable shared linkage for Windows if (WIN32) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) set(BUILD_SHARED_LIBS TRUE) endif () ######################################################################################################################## -## create and set necessary base properties ## +# create and set necessary base properties # ######################################################################################################################## -## set base sources +# set base sources set(PLSSVM_BASE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/plssvm/backends/Kokkos/execution_space.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/plssvm/backends/SYCL/implementation_types.cpp @@ -105,75 +110,98 @@ set(PLSSVM_BASE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/plssvm/verbosity_levels.cpp ) -## create base library: linked against all backend libraries +# create base library: linked against all backend libraries set(PLSSVM_BASE_LIBRARY_NAME plssvm-base) add_library(${PLSSVM_BASE_LIBRARY_NAME} SHARED ${PLSSVM_BASE_SOURCES}) -## create all library: one target against all backends are linked +# create all library: one target against all backends are linked set(PLSSVM_ALL_LIBRARY_NAME plssvm-all) add_library(${PLSSVM_ALL_LIBRARY_NAME} INTERFACE) -## create list of targets to install +# create list of targets to install set(PLSSVM_TARGETS_TO_INSTALL ${PLSSVM_ALL_LIBRARY_NAME} ${PLSSVM_BASE_LIBRARY_NAME}) -## set include directory -target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC - $ - $ -) +# set include directory +target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC $ $) -## set library cxx standard +# set library cxx standard if (DEFINED ENV{CLION_IDE} OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - # somehow necessary for CLion to detect the C++ standard as 17 - # also necessary for MSVC + # somehow necessary for CLion to detect the C++ standard as 17 also necessary for MSVC set(CMAKE_CXX_STANDARD 17) endif () target_compile_features(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC cxx_std_17) -## additional base library compile options -target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC - $<$:$<$:-Wall -Wextra -Wdouble-promotion -fno-common -Wshadow -Wcast-qual - -Wnull-dereference -Wnon-virtual-dtor -Wextra-semi -Wunreachable-code -Wuninitialized -Wno-ctor-dtor-privacy - -fPIC> - $<$:-Wsuggest-override -Wstrict-null-sentinel -Wlogical-op -Wduplicated-branches -Wimplicit-fallthrough=5> - $<$:-Wmost> - $<$:/W4 /bigobj /wd4459 /Zc:lambda>> +# additional base library compile options +target_compile_options( + ${PLSSVM_BASE_LIBRARY_NAME} + PUBLIC $<$:$<$:-Wall + -Wextra + -Wdouble-promotion + -fno-common + -Wshadow + -Wcast-qual + -Wnull-dereference + -Wnon-virtual-dtor + -Wextra-semi + -Wunreachable-code + -Wuninitialized + -Wno-ctor-dtor-privacy + -fPIC> + $<$:-Wsuggest-override + -Wstrict-null-sentinel + -Wlogical-op + -Wduplicated-branches + -Wimplicit-fallthrough=5> + $<$:-Wmost> + $<$:/W4 + /bigobj + /wd4459 + /Zc:lambda>> ) -## nvcc doesn't recognize -Werror=??? option, so only set it when using a CXX compiler -target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC - $<$:-Werror=switch -fstrict-enums> - $<$:/we4062 /wd4005 /wd4702 /wd4849 /wd4127> - # /wd4849: ignore "OpenMP 'reduction' clause ignored in 'simd' directive" -> no SIMD clause currently effective in MSVC - # /wd4127: ignore "conditional expression is constant" from {fmt} ranges.h header +# nvcc doesn't recognize -Werror=??? option, so only set it when using a CXX compiler +target_compile_options( + ${PLSSVM_BASE_LIBRARY_NAME} + PUBLIC $<$:-Werror=switch + -fstrict-enums> + $<$:/we4062 + /wd4005 + /wd4702 + /wd4849 + /wd4127> + # /wd4849: ignore "OpenMP 'reduction' clause ignored in 'simd' directive" -> no SIMD clause currently effective in MSVC /wd4127: ignore "conditional + # expression is constant" from {fmt} ranges.h header ) -## enable fast-math if requested +# enable fast-math if requested if (PLSSVM_ENABLE_FAST_MATH) message(STATUS "Enabling fast-math flags.") - target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC - $<$:-ffast-math> - $<$:/fp:fast> + target_compile_options( + ${PLSSVM_BASE_LIBRARY_NAME} PUBLIC $<$:-ffast-math> $<$:/fp:fast> ) target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_USE_FAST_MATH) endif () -## set march native flag based on target architecture +# set march native flag based on target architecture if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64le") message(STATUS "Compiling for ppc64le: setting -mcpu=native") - target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC $<$,$>,$>:-mcpu=native>) + target_compile_options( + ${PLSSVM_BASE_LIBRARY_NAME} + PUBLIC $<$,$>,$>:-mcpu=native> + ) elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") message(STATUS "Compiling for x86_64: setting -march=native") - target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC $<$,$>,$>:-march=native>) + target_compile_options( + ${PLSSVM_BASE_LIBRARY_NAME} + PUBLIC $<$,$>,$>:-march=native> + ) endif () -target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC - $<$:NOMINMAX> -) -target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PRIVATE - $<$:PLSSVM_COMPILE_BASE_LIBRARY> -) +target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC $<$:NOMINMAX>) +target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PRIVATE $<$:PLSSVM_COMPILE_BASE_LIBRARY>) option(PLSSVM_ENABLE_STL_DEBUG_MODE "Enables the debug modes for the STL implementations. Note: changes the ABI!" OFF) +# ~~~ # GCC standard library (libstdc++): _GLIBCXX_DEBUG # LLVM standard library (libc++): LIBCXX_ENABLE_DEBUG_MODE # MSVC standard library: _ITERATOR_DEBUG_LEVEL +# ~~~ set(PLSSVM_STL_DEBUG_MODE_FLAGS "-D_GLIBCXX_DEBUG -DLIBCXX_ENABLE_DEBUG_MODE -D_ITERATOR_DEBUG_LEVEL") if (PLSSVM_ENABLE_STL_DEBUG_MODE) message(STATUS "Enable standard library debug modes.") @@ -181,7 +209,7 @@ if (PLSSVM_ENABLE_STL_DEBUG_MODE) endif () ######################################################################################################################## -## check for OpenMP (not for the backend!) ## +# check for OpenMP (not for the backend!) # ######################################################################################################################## find_package(OpenMP 4.0 QUIET) if (OpenMP_FOUND) @@ -194,34 +222,39 @@ if (OpenMP_FOUND) endif () else () # disable warning for unknown OpenMP pragmas if no OpenMP could be found - target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC - $<$:-Wno-unknown-pragmas> - $<$:/wd4068> + target_compile_options( + ${PLSSVM_BASE_LIBRARY_NAME} PUBLIC $<$:-Wno-unknown-pragmas> $<$:/wd4068> ) # issue warning that multi-GPU execution will be serialized message(WARNING "Couldn't find OpenMP. Note that in a multi-GPU setting this will result in serialized kernel calls across all GPUs!") endif () ######################################################################################################################## -## create executables ## +# create executables # ######################################################################################################################## -## create train executable +# create train executable set(PLSSVM_EXECUTABLE_TRAIN_NAME plssvm-train) add_executable(${PLSSVM_EXECUTABLE_TRAIN_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/main_train.cpp) -## create predict executable +# create predict executable set(PLSSVM_EXECUTABLE_PREDICT_NAME plssvm-predict) add_executable(${PLSSVM_EXECUTABLE_PREDICT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/main_predict.cpp) -## create scale executable +# create scale executable set(PLSSVM_EXECUTABLE_SCALE_NAME plssvm-scale) add_executable(${PLSSVM_EXECUTABLE_SCALE_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/main_scale.cpp) -## append executables to installed targets -list(APPEND PLSSVM_TARGETS_TO_INSTALL ${PLSSVM_EXECUTABLE_TRAIN_NAME} ${PLSSVM_EXECUTABLE_PREDICT_NAME} ${PLSSVM_EXECUTABLE_SCALE_NAME}) +# append executables to installed targets +list( + APPEND + PLSSVM_TARGETS_TO_INSTALL + ${PLSSVM_EXECUTABLE_TRAIN_NAME} + ${PLSSVM_EXECUTABLE_PREDICT_NAME} + ${PLSSVM_EXECUTABLE_SCALE_NAME} +) ######################################################################################################################## -## setup code coverage analysis ## +# setup code coverage analysis # ######################################################################################################################## -## coverage analysis only possible with the Coverage CMAKE_BUILD_TYPE +# coverage analysis only possible with the Coverage CMAKE_BUILD_TYPE if (uppercase_CMAKE_BUILD_TYPE MATCHES COVERAGE) # must be linux if (WIN32 OR APPLE) @@ -237,44 +270,48 @@ if (uppercase_CMAKE_BUILD_TYPE MATCHES COVERAGE) # assertions must be available for a coverage analysis message(STATUS "Enabling assertions since they are necessary for the coverage analysis.") set(PLSSVM_ENABLE_ASSERTS ON CACHE BOOL "" FORCE) - + message(STATUS "Enable code coverage analysis using lcov.") - + # Create the coverage target. Run coverage tests with 'make coverage' - add_custom_target(coverage - COMMAND lcov --zerocounters --directory . - COMMAND lcov --capture -d . --initial --output-file test_base.info - COMMAND mkdir -p coverage - COMMAND ${CMAKE_MAKE_PROGRAM} test || true - COMMAND lcov --capture -d . --output-file test_test.info - COMMAND lcov --add-tracefile test_base.info --add-tracefile test_test.info -o test_total.info - COMMAND lcov --remove test_total.info '/usr/*' '*/build/*' '*/tests/*' '*/_deps/*' -o test_clean.info - COMMAND genhtml test_clean.info --output-directory coverage --title "PLSSVM Test Coverage" --show-details --legend - BYPRODUCTS ${CMAKE_BINARY_DIR}/test_base.info ${CMAKE_BINARY_DIR}/test_test.info ${CMAKE_BINARY_DIR}/test_total.info ${CMAKE_BINARY_DIR}/test_clean.info ${CMAKE_BINARY_DIR}/coverage - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + add_custom_target( + coverage + COMMAND lcov --zerocounters --directory . + COMMAND lcov --capture -d . --initial --output-file test_base.info + COMMAND mkdir -p coverage + COMMAND ${CMAKE_MAKE_PROGRAM} test || true + COMMAND lcov --capture -d . --output-file test_test.info + COMMAND lcov --add-tracefile test_base.info --add-tracefile test_test.info -o test_total.info + COMMAND lcov --remove test_total.info '/usr/*' '*/build/*' '*/tests/*' '*/_deps/*' -o test_clean.info + COMMAND genhtml test_clean.info --output-directory coverage --title "PLSSVM Test Coverage" --show-details --legend + BYPRODUCTS ${CMAKE_BINARY_DIR}/test_base.info + ${CMAKE_BINARY_DIR}/test_test.info + ${CMAKE_BINARY_DIR}/test_total.info + ${CMAKE_BINARY_DIR}/test_clean.info + ${CMAKE_BINARY_DIR}/coverage + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) - + # add executables as coverage target add_dependencies(coverage ${PLSSVM_EXECUTABLE_TRAIN_NAME}) add_dependencies(coverage ${PLSSVM_EXECUTABLE_PREDICT_NAME}) add_dependencies(coverage ${PLSSVM_EXECUTABLE_SCALE_NAME}) - + # add custom target `make clean_coverage` which calls `make clean` and also removes all generate *.gcda and *.gcno files add_custom_target(clean_coverage) add_custom_command( - DEPENDS clean - COMMENT "remove all coverage files" - COMMAND ${CMAKE_MAKE_PROGRAM} clean - COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/delete_coverage_files.cmake" - TARGET clean_coverage + DEPENDS clean + COMMENT "remove all coverage files" + COMMAND ${CMAKE_MAKE_PROGRAM} clean + COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/delete_coverage_files.cmake" TARGET clean_coverage ) endif () ######################################################################################################################## -## parse target platform information ## +# parse target platform information # ######################################################################################################################## -## the target platforms and architectures must either be set using the CMake command line option -## PLSSVM_TARGET_PLATFORMS or the environment variable with the same name +# the target platforms and architectures must either be set using the CMake command line option +# PLSSVM_TARGET_PLATFORMS or the environment variable with the same name if (DEFINED PLSSVM_TARGET_PLATFORMS) set(PLSSVM_TARGET_PLATFORMS ${PLSSVM_TARGET_PLATFORMS} CACHE STRING "The target platforms to compile for." FORCE) elseif (DEFINED ENV{PLSSVM_TARGET_PLATFORMS}) @@ -283,41 +320,47 @@ else () # check for Python3 and all necessary libraries find_package(Python3 COMPONENTS Interpreter Development) if (NOT Python3_FOUND) - message(FATAL_ERROR "Can't find Python3. Please manually specify PLSSVM_TARGET_PLATFORMS (e.g. -DPLSSVM_TARGET_PLATFORMS=\"cpu;nvidia:sm_70,sm_86;amd:gfx906;intel:skl\"!") + message( + FATAL_ERROR + "Can't find Python3. Please manually specify PLSSVM_TARGET_PLATFORMS (e.g. -DPLSSVM_TARGET_PLATFORMS=\"cpu;nvidia:sm_70,sm_86;amd:gfx906;intel:skl\"!" + ) endif () - + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_python_libs.cmake) set(PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS cpuinfo GPUtil pyamdgpuinfo pylspci) - message(STATUS "Checking required Python3 libraries (${PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS}) to automatically determine the PLSSVM_TARGET_PLATFORMS.") - set(PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS_ERROR_MESSAGE "or manually define PLSSVM_TARGET_PLATFORMS (e.g. -DPLSSVM_TARGET_PLATFORMS=\"cpu;nvidia:sm_70,sm_86;amd:gfx906;intel:skl\"!") + message( + STATUS + "Checking required Python3 libraries (${PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS}) to automatically determine the PLSSVM_TARGET_PLATFORMS." + ) + set(PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS_ERROR_MESSAGE + "or manually define PLSSVM_TARGET_PLATFORMS (e.g. -DPLSSVM_TARGET_PLATFORMS=\"cpu;nvidia:sm_70,sm_86;amd:gfx906;intel:skl\"!" + ) check_python_libs(${PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS} ${PLSSVM_TARGET_PLATFORMS_PYTHON_SCRIPT_REQUIRED_LIBS_ERROR_MESSAGE}) - + # run our `plssvm_target_platforms.py` script to determine the PLSSVM_TARGET_PLATFORMS string execute_process( - COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/utility_scripts/plssvm_target_platforms.py" "--quiet" - RESULT_VARIABLE PLSSVM_PYTHON_TARGET_PLATFORMS_EXIT_CODE - OUTPUT_VARIABLE PLSSVM_PYTHON_TARGET_PLATFORMS_OUTPUT + COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/utility_scripts/plssvm_target_platforms.py" "--quiet" + RESULT_VARIABLE PLSSVM_PYTHON_TARGET_PLATFORMS_EXIT_CODE OUTPUT_VARIABLE PLSSVM_PYTHON_TARGET_PLATFORMS_OUTPUT ) - + # an error occurred when running our python script if (NOT ${PLSSVM_PYTHON_TARGET_PLATFORMS_EXIT_CODE} EQUAL 0) - message(FATAL_ERROR - "Error running '${CMAKE_CURRENT_SOURCE_DIR}/utility_scripts/plssvm_target_platforms.py'." - "Please manually specify PLSSVM_TARGET_PLATFORMS (e.g. -DPLSSVM_TARGET_PLATFORMS=\"cpu;nvidia:sm_70,sm_86;amd:gfx906;intel:skl\"!" + message(FATAL_ERROR "Error running '${CMAKE_CURRENT_SOURCE_DIR}/utility_scripts/plssvm_target_platforms.py'." + "Please manually specify PLSSVM_TARGET_PLATFORMS (e.g. -DPLSSVM_TARGET_PLATFORMS=\"cpu;nvidia:sm_70,sm_86;amd:gfx906;intel:skl\"!" ) endif () - + # set PLSSVM_TARGET_PLATFORMS string(STRIP "${PLSSVM_PYTHON_TARGET_PLATFORMS_OUTPUT}" PLSSVM_TARGET_PLATFORMS) message(STATUS "Automatically derived PLSSVM_TARGET_PLATFORMS=\"${PLSSVM_TARGET_PLATFORMS}\".") endif () -## PLSSVM_TARGET_PLATFORMS must not be empty +# PLSSVM_TARGET_PLATFORMS must not be empty if (PLSSVM_TARGET_PLATFORMS STREQUAL "") message(FATAL_ERROR "PLSSVM_TARGET_PLATFORMS must not be empty!") endif () -## parse provided target platforms +# parse provided target platforms include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/parse_architecture_info.cmake) set(PLSSVM_PLATFORM_NAME_LIST "automatic") foreach (PLSSVM_PLATFORM ${PLSSVM_TARGET_PLATFORMS}) @@ -359,65 +402,65 @@ foreach (PLSSVM_PLATFORM ${PLSSVM_TARGET_PLATFORMS}) endforeach () ######################################################################################################################## -## check for and enable backends ## +# check for and enable backends # ######################################################################################################################## -## check for OpenMP backend +# check for OpenMP backend set(PLSSVM_ENABLE_OPENMP_BACKEND AUTO CACHE STRING "Enable OpenMP Backend") set_property(CACHE PLSSVM_ENABLE_OPENMP_BACKEND PROPERTY STRINGS AUTO ON OFF) if (PLSSVM_ENABLE_OPENMP_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_OPENMP_BACKEND) add_subdirectory(src/plssvm/backends/OpenMP) endif () -## check for stdpar backend +# check for stdpar backend set(PLSSVM_ENABLE_STDPAR_BACKEND AUTO CACHE STRING "Enable stdpar Backend") set_property(CACHE PLSSVM_ENABLE_STDPAR_BACKEND PROPERTY STRINGS AUTO ON OFF) if (PLSSVM_ENABLE_STDPAR_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_STDPAR_BACKEND) add_subdirectory(src/plssvm/backends/stdpar) endif () -## check for HPX backend +# check for HPX backend set(PLSSVM_ENABLE_HPX_BACKEND AUTO CACHE STRING "Enable HPX Backend") set_property(CACHE PLSSVM_ENABLE_HPX_BACKEND PROPERTY STRINGS AUTO ON OFF) if (PLSSVM_ENABLE_HPX_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_HPX_BACKEND) add_subdirectory(src/plssvm/backends/HPX) endif () -## check for CUDA backend +# check for CUDA backend set(PLSSVM_ENABLE_CUDA_BACKEND AUTO CACHE STRING "Enable CUDA Backend") set_property(CACHE PLSSVM_ENABLE_CUDA_BACKEND PROPERTY STRINGS AUTO ON OFF) if (PLSSVM_ENABLE_CUDA_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_CUDA_BACKEND) add_subdirectory(src/plssvm/backends/CUDA) endif () -## check for HIP backend +# check for HIP backend set(PLSSVM_ENABLE_HIP_BACKEND AUTO CACHE STRING "Enable HIP Backend") set_property(CACHE PLSSVM_ENABLE_HIP_BACKEND PROPERTY STRINGS AUTO ON OFF) if (PLSSVM_ENABLE_HIP_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_HIP_BACKEND) add_subdirectory(src/plssvm/backends/HIP) endif () -## check for OpenCL backend +# check for OpenCL backend set(PLSSVM_ENABLE_OPENCL_BACKEND AUTO CACHE STRING "Enable OpenCL Backend") set_property(CACHE PLSSVM_ENABLE_OPENCL_BACKEND PROPERTY STRINGS AUTO ON OFF) if (PLSSVM_ENABLE_OPENCL_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_OPENCL_BACKEND) add_subdirectory(src/plssvm/backends/OpenCL) endif () -## check for SYCL backend +# check for SYCL backend set(PLSSVM_ENABLE_SYCL_BACKEND AUTO CACHE STRING "Enable SYCL Backend") set_property(CACHE PLSSVM_ENABLE_SYCL_BACKEND PROPERTY STRINGS AUTO ON OFF) if (PLSSVM_ENABLE_SYCL_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_SYCL_BACKEND) add_subdirectory(src/plssvm/backends/SYCL) endif () -## check for Kokkos backend +# check for Kokkos backend set(PLSSVM_ENABLE_KOKKOS_BACKEND AUTO CACHE STRING "Enable SYCL Backend") set_property(CACHE PLSSVM_ENABLE_KOKKOS_BACKEND PROPERTY STRINGS AUTO ON OFF) if (PLSSVM_ENABLE_KOKKOS_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_KOKKOS_BACKEND) add_subdirectory(src/plssvm/backends/Kokkos) endif () -## check if ANY backend is available/has been enabled +# check if ANY backend is available/has been enabled get_target_property(PLSSVM_LINKED_BACKENDS ${PLSSVM_ALL_LIBRARY_NAME} INTERFACE_LINK_LIBRARIES) if (NOT PLSSVM_LINKED_BACKENDS) message(FATAL_ERROR "At least one backend must be available!") @@ -427,34 +470,39 @@ elseif (PLSSVM_STDPAR_BACKEND_LIBRARY_NAME AND PLSSVM_LINKED_BACKENDS MATCHES "$ list(LENGTH PLSSVM_MATCHED_LINKED_BACKENDS PLSSVM_NUM_MATCHED_LINKED_BACKENDS) # if plssvm-stdpar has been found and plssvm- occurred more than once, some other backend is present which is currently not supported! if (PLSSVM_NUM_MATCHED_LINKED_BACKENDS GREATER 1) - message(FATAL_ERROR "Found the stdpar backend together with some other backend(s). This is currently not supported!\nTo fix this, either disable the stdpar backend or all other backends!") + message( + FATAL_ERROR + "Found the stdpar backend together with some other backend(s). This is currently not supported!\nTo fix this, either disable the stdpar backend or all other backends!" + ) endif () endif () -## link backends against executables +# link backends against executables target_link_libraries(${PLSSVM_EXECUTABLE_TRAIN_NAME} ${PLSSVM_ALL_LIBRARY_NAME}) target_link_libraries(${PLSSVM_EXECUTABLE_PREDICT_NAME} ${PLSSVM_ALL_LIBRARY_NAME}) target_link_libraries(${PLSSVM_EXECUTABLE_SCALE_NAME} ${PLSSVM_ALL_LIBRARY_NAME}) ######################################################################################################################## -## add additional compile definitions ## +# add additional compile definitions # ######################################################################################################################## -## the CMake build type for performance tracking +# the CMake build type for performance tracking target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_BUILD_TYPE="${CMAKE_BUILD_TYPE}") -## add assert option +# add assert option option(PLSSVM_ENABLE_ASSERTS "Enables PLSSVM asserts even if NDEBUG is set." OFF) if (PLSSVM_ENABLE_ASSERTS) message(STATUS "Enable additional debugging assertions.") target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_ENABLE_ASSERTS) - + + # ~~~ # disable vectorization warning in clang in Release mode # -> loops can't be vectorized due to the PLSSVM_ASSERTs in the matrix::operator() member function # target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC # $<$,$>,$>:-Wno-pass-failed> # ) + # ~~~ endif () -## use float as real_type if requested +# use float as real_type if requested option(PLSSVM_USE_FLOAT_AS_REAL_TYPE "Use float as real_type instead of double." OFF) if (PLSSVM_USE_FLOAT_AS_REAL_TYPE) message(STATUS "Using float as real_type.") @@ -463,7 +511,7 @@ else () message(STATUS "Using double as real_type (default).") endif () -## set specific thread block sizes if requested +# set specific thread block sizes if requested if (DEFINED ENV{PLSSVM_THREAD_BLOCK_SIZE}) set(PLSSVM_THREAD_BLOCK_SIZE $ENV{PLSSVM_THREAD_BLOCK_SIZE} CACHE STRING "The used thread block size." FORCE) endif () @@ -477,7 +525,7 @@ if (DEFINED PLSSVM_THREAD_BLOCK_SIZE) endif () endif () -## set specific internal block sizes of requested +# set specific internal block sizes of requested if (DEFINED ENV{PLSSVM_INTERNAL_BLOCK_SIZE}) set(PLSSVM_INTERNAL_BLOCK_SIZE $ENV{PLSSVM_INTERNAL_BLOCK_SIZE} CACHE STRING "The used internal block size." FORCE) endif () @@ -491,7 +539,7 @@ if (DEFINED PLSSVM_INTERNAL_BLOCK_SIZE) endif () endif () -## enforce maximum device memory allocation sizes for the automatic solver type +# enforce maximum device memory allocation sizes for the automatic solver type option(PLSSVM_ENFORCE_MAX_MEM_ALLOC_SIZE "Enforce the maximum device memory allocation sizes for the automatic plssvm::solver_type." ON) if (PLSSVM_ENFORCE_MAX_MEM_ALLOC_SIZE) message(STATUS "Enforce the maximum device memory allocation sizes for the automatic plssvm::solver_type.") @@ -500,9 +548,9 @@ if (PLSSVM_ENFORCE_MAX_MEM_ALLOC_SIZE) endif () ######################################################################################################################## -## check for Link Time Optimization ## +# check for Link Time Optimization # ######################################################################################################################## -## enable Link Time Optimization (LTO) +# enable Link Time Optimization (LTO) option(PLSSVM_ENABLE_LTO "Enable Link Time Optimizations." ON) if (PLSSVM_ENABLE_LTO) include(CheckIPOSupported) @@ -519,13 +567,13 @@ if (PLSSVM_ENABLE_LTO) endif () ######################################################################################################################## -## check for optional and necessary dependencies ## +# check for optional and necessary dependencies # ######################################################################################################################## -## setup dependencies +# setup dependencies include(FetchContent) list(APPEND CMAKE_MESSAGE_INDENT "Dependencies: ") -## try finding cxxopts +# try finding cxxopts set(PLSSVM_cxxopts_VERSION v3.2.0) find_package(cxxopts 3.2.0 QUIET) if (cxxopts_FOUND) @@ -538,20 +586,18 @@ else () set(CXXOPTS_BUILD_TESTS OFF CACHE INTERNAL "" FORCE) set(CXXOPTS_ENABLE_WARNINGS OFF CACHE INTERNAL "" FORCE) # fetch command line parser library cxxopts - FetchContent_Declare(cxxopts - GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git - GIT_TAG ${PLSSVM_cxxopts_VERSION} - QUIET + FetchContent_Declare( + cxxopts + GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git + GIT_TAG ${PLSSVM_cxxopts_VERSION} + QUIET ) FetchContent_MakeAvailable(cxxopts) add_dependencies(${PLSSVM_BASE_LIBRARY_NAME} cxxopts) - target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC - $ - $ - ) + target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC $ $) endif () -## try finding fast_float +# try finding fast_float set(PLSSVM_fast_float_VERSION v6.1.3) find_package(fast_float QUIET) if (fast_float_FOUND) @@ -564,20 +610,18 @@ else () set(FASTFLOAT_TEST OFF CACHE INTERNAL "" FORCE) set(FASTFLOAT_SANITIZE OFF CACHE INTERNAL "" FORCE) # fetch float parsing library fast_float - FetchContent_Declare(fast_float - GIT_REPOSITORY https://github.com/fastfloat/fast_float - GIT_TAG ${PLSSVM_fast_float_VERSION} - QUIET + FetchContent_Declare( + fast_float + GIT_REPOSITORY https://github.com/fastfloat/fast_float + GIT_TAG ${PLSSVM_fast_float_VERSION} + QUIET ) FetchContent_MakeAvailable(fast_float) add_dependencies(${PLSSVM_BASE_LIBRARY_NAME} fast_float) - target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC - $ - $ - ) + target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC $ $) endif () -## try finding igor +# try finding igor set(PLSSVM_igor_VERSION a5224c60d266974d3f407191583fe266cbe1c93d) find_package(igor QUIET) if (igor_FOUND) @@ -589,21 +633,19 @@ else () # set options for igor set(IGOR_BUILD_TESTS OFF CACHE INTERNAL "" FORCE) # fetch named argument library igor - FetchContent_Declare(igor - GIT_REPOSITORY https://github.com/bluescarni/igor - GIT_TAG ${PLSSVM_igor_VERSION} - QUIET + FetchContent_Declare( + igor + GIT_REPOSITORY https://github.com/bluescarni/igor + GIT_TAG ${PLSSVM_igor_VERSION} + QUIET ) FetchContent_MakeAvailable(igor) add_dependencies(${PLSSVM_BASE_LIBRARY_NAME} igor) - target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC - $ - $ - ) + target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC $ $) list(APPEND PLSSVM_TARGETS_TO_INSTALL "igor") endif () -## try finding fmt +# try finding fmt set(PLSSVM_fmt_VERSION 11.0.2) find_package(fmt 11.0.2 QUIET) if (fmt_FOUND) @@ -625,10 +667,11 @@ else () set(FMT_MODULE OFF CACHE INTERNAL "" FORCE) set(FMT_SYSTEM_HEADERS ON CACHE INTERNAL "" FORCE) # fetch string formatting library fmt - FetchContent_Declare(fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt.git - GIT_TAG ${PLSSVM_fmt_VERSION} - QUIET + FetchContent_Declare( + fmt + GIT_REPOSITORY https://github.com/fmtlib/fmt.git + GIT_TAG ${PLSSVM_fmt_VERSION} + QUIET ) FetchContent_MakeAvailable(fmt) set_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -641,36 +684,36 @@ target_link_libraries(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC fmt::fmt) list(POP_BACK CMAKE_MESSAGE_INDENT) ######################################################################################################################## -## enable automatic formatting using clang-format ## +# 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 + + # install library to add a clang-format target set(PLSSVM_format_VERSION d22c36043bea6ef85f3eb68b823f50703bd1cc21) 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_CMAKE OFF 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 + # 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 ## +# enable documentation generation via doxygen # ######################################################################################################################## option(PLSSVM_ENABLE_DOCUMENTATION "Build documentation using doxygen." OFF) if (PLSSVM_ENABLE_DOCUMENTATION) @@ -680,15 +723,17 @@ if (PLSSVM_ENABLE_DOCUMENTATION) endif () ######################################################################################################################## -## enable performance tracking and hardware sampling ## +# enable performance tracking and hardware sampling # ######################################################################################################################## -option(PLSSVM_ENABLE_PERFORMANCE_TRACKING "Enable performance tracking to YAML files for the PLSSVM executables plssvm-train, plssvm-predict, and plssvm-scale." OFF) +option(PLSSVM_ENABLE_PERFORMANCE_TRACKING + "Enable performance tracking to YAML files for the PLSSVM executables plssvm-train, plssvm-predict, and plssvm-scale." OFF +) if (PLSSVM_ENABLE_PERFORMANCE_TRACKING) add_subdirectory(src/plssvm/detail/tracking) endif () ######################################################################################################################## -## enable testing via google test ## +# enable testing via google test # ######################################################################################################################## option(PLSSVM_ENABLE_TESTING "Build tests for all backends." ON) if (PLSSVM_ENABLE_TESTING) @@ -697,7 +742,7 @@ if (PLSSVM_ENABLE_TESTING) endif () ######################################################################################################################## -## enable language bindings ## +# enable language bindings # ######################################################################################################################## option(PLSSVM_ENABLE_LANGUAGE_BINDINGS "Build language bindings, e.g., for Python." OFF) if (PLSSVM_ENABLE_LANGUAGE_BINDINGS) @@ -705,7 +750,7 @@ if (PLSSVM_ENABLE_LANGUAGE_BINDINGS) endif () ######################################################################################################################## -## print short (backend) summary ## +# print short (backend) summary # ######################################################################################################################## message(STATUS "") message(STATUS "Enabled backends with respective targets:") @@ -747,146 +792,132 @@ endif () message(STATUS "") ######################################################################################################################## -## configure version and git metadata files ## +# configure version and git metadata files # ######################################################################################################################## message(STATUS "Configuring version and git metadata.") set(PRE_CONFIGURE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/src/plssvm/version/git_metadata/git_metadata.cpp.in") set(POST_CONFIGURE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/src/plssvm/version/git_metadata/git_metadata.cpp") set(GIT_FAIL_IF_NONZERO_EXIT FALSE) include(cmake/git_watcher.cmake) -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/include/plssvm/version/version.hpp.in - ${CMAKE_CURRENT_SOURCE_DIR}/include/plssvm/version/version.hpp - @ONLY -) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/plssvm/version/version.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/plssvm/version/version.hpp @ONLY) ######################################################################################################################## -## generate man pages ## +# generate man pages # ######################################################################################################################## -## assemble the SYCL manpage entry +# assemble the SYCL manpage entry message(STATUS "Generating manpage files.") string(TIMESTAMP PLSSVM_CURRENT_BUILD_TIME "%d. %B %Y") string(REPLACE ";" "|" PLSSVM_PLATFORM_NAME_LIST "${PLSSVM_PLATFORM_NAME_LIST}") string(REPLACE ";" "|" PLSSVM_BACKEND_NAME_LIST "${PLSSVM_BACKEND_NAME_LIST}") if (TARGET ${PLSSVM_SYCL_BACKEND_LIBRARY_NAME}) string(REPLACE ";" "|" PLSSVM_SYCL_BACKEND_NAME_LIST "${PLSSVM_SYCL_BACKEND_NAME_LIST}") - set(PLSSVM_SYCL_IMPLEMENTATION_TYPE_MANPAGE_ENTRY " + set(PLSSVM_SYCL_IMPLEMENTATION_TYPE_MANPAGE_ENTRY + " .TP .B --sycl_implementation_type choose the SYCL implementation to be used in the SYCL backend: ${PLSSVM_SYCL_BACKEND_NAME_LIST} (default: automatic) -") - set(PLSSVM_SYCL_KERNEL_INVOCATION_TYPE_MANPAGE_ENTRY " +" + ) + set(PLSSVM_SYCL_KERNEL_INVOCATION_TYPE_MANPAGE_ENTRY + " .TP .B --sycl_kernel_invocation_type choose the kernel invocation type when using SYCL as backend: automatic|nd_range (default: automatic) -") +" + ) endif () set(PLSSVM_SYCL_MANPAGE_ENTRY "${PLSSVM_SYCL_KERNEL_INVOCATION_TYPE_MANPAGE_ENTRY}${PLSSVM_SYCL_IMPLEMENTATION_TYPE_MANPAGE_ENTRY}") -## assemble the Kokkos manpage entry +# assemble the Kokkos manpage entry if (TARGET ${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME}) string(REPLACE ";" "|" PLSSVM_KOKKOS_BACKEND_AVAILABLE_EXECUTION_SPACES "${PLSSVM_KOKKOS_BACKEND_AVAILABLE_EXECUTION_SPACES}") - set(PLSSVM_KOKKOS_MANPAGE_ENTRY " + set(PLSSVM_KOKKOS_MANPAGE_ENTRY + " .TP .B --kokkos_execution_space choose the Kokkos execution space to be used in the Kokkos backend: automatic|${PLSSVM_KOKKOS_BACKEND_AVAILABLE_EXECUTION_SPACES} (default: automatic) -") +" + ) endif () -## assemble the performance tracker manpage entry +# assemble the performance tracker manpage entry if (PLSSVM_ENABLE_PERFORMANCE_TRACKING) - set(PLSSVM_PERFORMANCE_TRACKER_MANPAGE_ENTRY " + set(PLSSVM_PERFORMANCE_TRACKER_MANPAGE_ENTRY + " .TP .B --performance_tracking choose the output YAML file where the performance tracking entries should be stored; if not provided, the results are dumped to stderr -") +" + ) endif () -## configure the manpage files -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-train.1.in - ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-train.1 - @ONLY -) +# configure the manpage files +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-train.1.in ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-train.1 @ONLY) # update manpage entry since plssvm-predict can't recognize the SYCL kernel invocation type set(PLSSVM_SYCL_MANPAGE_ENTRY "${PLSSVM_SYCL_IMPLEMENTATION_TYPE_MANPAGE_ENTRY}") -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-predict.1.in - ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-predict.1 - @ONLY -) -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-scale.1.in - ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-scale.1 - @ONLY -) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-predict.1.in ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-predict.1 @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-scale.1.in ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-scale.1 @ONLY) ######################################################################################################################## -## add support for `make install` ## +# add support for `make install` # ######################################################################################################################## include(GNUInstallDirs) -## install all necessary library targets -install(TARGETS ${PLSSVM_TARGETS_TO_INSTALL} - EXPORT plssvm_Targets - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" # all files that are neither executables, shared lib or headers - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" # all shared lib files - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" # all executables +# install all necessary library targets +install( + TARGETS ${PLSSVM_TARGETS_TO_INSTALL} + EXPORT plssvm_Targets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" # all files that are neither executables, shared lib or headers + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" # all shared lib files + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" # all executables ) -## mark header to install via 'make install' -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" -) -## install header only library igor header via 'make install' +# mark header to install via 'make install' +install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") +# install header only library igor header via 'make install' if (NOT igor_FOUND) - install(DIRECTORY "${igor_SOURCE_DIR}/include/" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - ) + install(DIRECTORY "${igor_SOURCE_DIR}/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") endif () -## mark man pages to install -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-train.1 - ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-predict.1 - ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-scale.1 +# mark man pages to install +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-train.1 ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-predict.1 ${CMAKE_CURRENT_SOURCE_DIR}/docs/plssvm-scale.1 DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" ) -## manage version comparison +# manage version comparison include(CMakePackageConfigHelpers) write_basic_package_version_file( - "plssvmConfigVersion.cmake" - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion + "plssvmConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion ) -## generate configuration file +# generate configuration file configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmConfig.cmake.in" - "${PROJECT_BINARY_DIR}/plssvmConfig.cmake" - INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/plssvm/cmake + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmConfig.cmake.in" "${PROJECT_BINARY_DIR}/plssvmConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/plssvm/cmake ) configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmHIPTargets.cmake.in" - "${PROJECT_BINARY_DIR}/plssvmHIPTargets.cmake" - INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/plssvm/cmake + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmHIPTargets.cmake.in" "${PROJECT_BINARY_DIR}/plssvmHIPTargets.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/plssvm/cmake ) -## create and copy install-targets file -install(EXPORT plssvm_Targets - FILE plssvmTargets.cmake - NAMESPACE plssvm:: - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/plssvm/cmake +# create and copy install-targets file +install( + EXPORT plssvm_Targets + FILE plssvmTargets.cmake + NAMESPACE plssvm:: + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/plssvm/cmake ) -## create file containing the build configuration and version information -install(FILES - "${PROJECT_BINARY_DIR}/plssvmConfig.cmake" - "${PROJECT_BINARY_DIR}/plssvmConfigVersion.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmCUDATargets.cmake" - "${PROJECT_BINARY_DIR}/plssvmHIPTargets.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmOpenCLTargets.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmOpenMPTargets.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmHPXTargets.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmAdaptiveCppTargets.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmDPCPPTargets.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmKokkosTargets.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmstdparTargets.cmake" - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/plssvm/cmake +# create file containing the build configuration and version information +install( + FILES "${PROJECT_BINARY_DIR}/plssvmConfig.cmake" + "${PROJECT_BINARY_DIR}/plssvmConfigVersion.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmCUDATargets.cmake" + "${PROJECT_BINARY_DIR}/plssvmHIPTargets.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmOpenCLTargets.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmOpenMPTargets.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmHPXTargets.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmAdaptiveCppTargets.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmDPCPPTargets.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmKokkosTargets.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmstdparTargets.cmake" + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/plssvm/cmake ) diff --git a/README.md b/README.md index 947ee9b2f..7325d3e00 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,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 +- [Format.cmake](https://github.com/TheLartians/Format.cmake) if auto formatting via cmake-format and clang-format is enabled; also requires at least clang-format-18 and git, additionally, needs our custom [cmake-format fork](https://github.com/vancraar/cmake_format) incorporating some patches - 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: @@ -297,7 +297,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` +- `PLSSVM_ENABLE_FORMATTING=ON|OFF` (default: `OFF`): enable automatic formatting using cmake-format and clang-format; adds additional targets `check-cmake-format`, `cmake-format`, `fix-cmake-format`, `check-clang-format`, `clang-format`, and `fix-clang-format` If `PLSSVM_ENABLE_TESTING` is set to `ON`, the following option can also be set: @@ -467,17 +467,24 @@ The resulting `html` coverage report is located in the `coverage` folder in the ### 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). +Additionally, our custom [cmake-format fork](https://github.com/vancraar/cmake_format) must be used since it has incorporated some necessary patches. +Our `cmake-format` can be installed via: + +```bash +pip install "git+https://github.com/vancraar/cmake_format@master" +``` To check whether formatting changes must be applied use: ```bash +cmake --build . --target check-cmake-format cmake --build . --target check-clang-format ``` To auto format all files use: ```bash -cmake --build . --target clang-format +cmake --build . --target fix-cmake-format cmake --build . --target fix-clang-format ``` diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index df3c80757..cbe1cbc5b 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## include(CMakeDependentOption) @@ -9,7 +9,13 @@ include(CMakeDependentOption) list(APPEND CMAKE_MESSAGE_INDENT "Bindings: ") # enable Python langauge bindings -cmake_dependent_option(PLSSVM_ENABLE_PYTHON_BINDINGS "Build langauge bindings for Python." ON "PLSSVM_ENABLE_LANGUAGE_BINDINGS" OFF) +cmake_dependent_option( + PLSSVM_ENABLE_PYTHON_BINDINGS + "Build langauge bindings for Python." + ON + "PLSSVM_ENABLE_LANGUAGE_BINDINGS" + OFF +) if (PLSSVM_ENABLE_PYTHON_BINDINGS) add_subdirectory(Python) endif () @@ -17,4 +23,4 @@ endif () # explicitly update install targets in parent scope set(PLSSVM_TARGETS_TO_INSTALL "${PLSSVM_TARGETS_TO_INSTALL}" PARENT_SCOPE) -list(POP_BACK CMAKE_MESSAGE_INDENT) \ No newline at end of file +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/bindings/Python/CMakeLists.txt b/bindings/Python/CMakeLists.txt index e87f2433d..fea4a0998 100644 --- a/bindings/Python/CMakeLists.txt +++ b/bindings/Python/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## include(${PROJECT_SOURCE_DIR}/cmake/utility_macros.cmake) @@ -10,7 +10,7 @@ message(STATUS "Building Python language bindings for PLSSVM.") find_package(Python COMPONENTS Interpreter Development) -## try finding pybind11 +# try finding pybind11 set(PLSSVM_pybind11_VERSION v2.13.3) find_package(pybind11 2.13.3 QUIET) if (pybind11_FOUND) @@ -18,25 +18,21 @@ if (pybind11_FOUND) else () message(STATUS "Couldn't find package pybind11. Building version ${PLSSVM_pybind11_VERSION} from source.") # fetch pybind11 library for creating Python bindings - FetchContent_Declare(pybind11 - GIT_REPOSITORY https://github.com/pybind/pybind11.git - GIT_TAG ${PLSSVM_pybind11_VERSION} - GIT_SHALLOW TRUE - QUIET + FetchContent_Declare( + pybind11 + GIT_REPOSITORY https://github.com/pybind/pybind11.git + GIT_TAG ${PLSSVM_pybind11_VERSION} + GIT_SHALLOW TRUE + QUIET ) FetchContent_MakeAvailable(pybind11) - target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC - $ - $ - ) + target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC $ $) endif () # set source files that are always used set(PLSSVM_PYTHON_BINDINGS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/exceptions/exceptions.cpp - ${CMAKE_CURRENT_LIST_DIR}/version/version.cpp - ${CMAKE_CURRENT_LIST_DIR}/backend_types.cpp ${CMAKE_CURRENT_LIST_DIR}/classification_types.cpp ${CMAKE_CURRENT_LIST_DIR}/csvm.cpp @@ -50,9 +46,7 @@ set(PLSSVM_PYTHON_BINDINGS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/solver_types.cpp ${CMAKE_CURRENT_LIST_DIR}/target_platforms.cpp ${CMAKE_CURRENT_LIST_DIR}/verbosity_levels.cpp - ${CMAKE_CURRENT_LIST_DIR}/sklearn.cpp - ${CMAKE_CURRENT_LIST_DIR}/main.cpp ) @@ -71,12 +65,15 @@ if (TARGET ${PLSSVM_HPX_BACKEND_LIBRARY_NAME}) list(APPEND PLSSVM_PYTHON_BINDINGS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/backends/hpx_csvm.cpp) endif () if (TARGET ${PLSSVM_STDPAR_BACKEND_LIBRARY_NAME}) - + # AdaptiveCpp stdpar only support on the CPU when using our Python bindings if (PLSSVM_STDPAR_BACKEND STREQUAL "ACPP" AND (DEFINED PLSSVM_NVIDIA_TARGET_ARCHS OR DEFINED PLSSVM_AMD_TARGET_ARCHS OR DEFINED PLSSVM_INTEL_TARGET_ARCHS)) - message(FATAL_ERROR "The stdpar implementation using AdaptiveCpp isn't currently supported in the Python bindings when targeting something different than the CPU!") + message( + FATAL_ERROR + "The stdpar implementation using AdaptiveCpp isn't currently supported in the Python bindings when targeting something different than the CPU!" + ) endif () - + list(APPEND PLSSVM_PYTHON_BINDINGS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/backends/stdpar_csvm.cpp) endif () if (TARGET ${PLSSVM_CUDA_BACKEND_LIBRARY_NAME}) @@ -106,16 +103,23 @@ set(PLSSVM_PYTHON_BINDINGS_LIBRARY_NAME plssvm) pybind11_add_module(${PLSSVM_PYTHON_BINDINGS_LIBRARY_NAME} ${PLSSVM_PYTHON_BINDINGS_SOURCES}) # set default label type -set(PLSSVM_PYTHON_BINDINGS_POSSIBLE_LABEL_TYPE "bool;char;signed char;unsigned char;short;unsigned short;int;unsigned int;long;unsigned long;long long;unsigned long long;float;double;long double;std::string") +set(PLSSVM_PYTHON_BINDINGS_POSSIBLE_LABEL_TYPE + "bool;char;signed char;unsigned char;short;unsigned short;int;unsigned int;long;unsigned long;long long;unsigned long long;float;double;long double;std::string" +) set(PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE "std::string" CACHE STRING "The preferred type of the labels for the Python bindings.") set_property(CACHE PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE PROPERTY STRINGS ${PLSSVM_PYTHON_BINDINGS_POSSIBLE_LABEL_TYPE}) if (NOT "${PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE}" IN_LIST PLSSVM_PYTHON_BINDINGS_POSSIBLE_LABEL_TYPE) - message(FATAL_ERROR "The provided label_type \"${PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE}\" is not one of the allowed values: \"${PLSSVM_PYTHON_BINDINGS_POSSIBLE_LABEL_TYPE}\"") + message( + FATAL_ERROR + "The provided label_type \"${PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE}\" is not one of the allowed values: \"${PLSSVM_PYTHON_BINDINGS_POSSIBLE_LABEL_TYPE}\"" + ) endif () message(STATUS "The preferred label_type for the Python bindings is \"${PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE}\".") # add necessary compile definitions for the default real_type and label_type -target_compile_definitions(${PLSSVM_PYTHON_BINDINGS_LIBRARY_NAME} PRIVATE PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE=${PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE}) +target_compile_definitions( + ${PLSSVM_PYTHON_BINDINGS_LIBRARY_NAME} PRIVATE PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE=${PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE} +) if (PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE STREQUAL "std::string") target_compile_definitions(${PLSSVM_PYTHON_BINDINGS_LIBRARY_NAME} PRIVATE PLSSVM_PYTHON_BINDINGS_LABEL_TYPE_IS_STRING) endif () diff --git a/cmake/add_coverage_build_type.cmake b/cmake/add_coverage_build_type.cmake index 6ef060417..4b55fcb33 100644 --- a/cmake/add_coverage_build_type.cmake +++ b/cmake/add_coverage_build_type.cmake @@ -1,35 +1,30 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -## add new coverage build type -SET(CMAKE_CXX_FLAGS_COVERAGE - "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the C++ compiler during coverage builds." - FORCE) -SET(CMAKE_C_FLAGS_COVERAGE - "${CMAKE_C_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the C compiler during coverage builds." - FORCE) -SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE - "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -lgcov" - CACHE STRING "Flags used for linking binaries during coverage builds." - FORCE) -SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE - "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -lgcov" - CACHE STRING "Flags used by the shared libraries linker during coverage builds." - FORCE) -MARK_AS_ADVANCED( - CMAKE_CXX_FLAGS_COVERAGE - CMAKE_C_FLAGS_COVERAGE - CMAKE_EXE_LINKER_FLAGS_COVERAGE - CMAKE_SHARED_LINKER_FLAGS_COVERAGE) +# add new coverage build type +set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage" CACHE STRING "Flags used by the C++ compiler during coverage builds." + FORCE +) +set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage" CACHE STRING "Flags used by the C compiler during coverage builds." FORCE) +set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -lgcov" + CACHE STRING "Flags used for linking binaries during coverage builds." FORCE +) +set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -lgcov" + CACHE STRING "Flags used by the shared libraries linker during coverage builds." FORCE +) +mark_as_advanced(CMAKE_CXX_FLAGS_COVERAGE CMAKE_C_FLAGS_COVERAGE CMAKE_EXE_LINKER_FLAGS_COVERAGE CMAKE_SHARED_LINKER_FLAGS_COVERAGE) # update the documentation string of CMAKE_BUILD_TYPE for GUIs -set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage." - FORCE) -set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Release" "RelWithDebInfo" "MinSizeRel" "Coverage") \ No newline at end of file +set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage." FORCE) +set_property( + CACHE CMAKE_BUILD_TYPE + PROPERTY STRINGS + "Debug" + "Release" + "RelWithDebInfo" + "MinSizeRel" + "Coverage" +) diff --git a/cmake/assemble_summary_string.cmake b/cmake/assemble_summary_string.cmake index 7aa4b8d63..4c85c3cce 100644 --- a/cmake/assemble_summary_string.cmake +++ b/cmake/assemble_summary_string.cmake @@ -1,10 +1,10 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -function(assemble_summary_string out_var) +function (assemble_summary_string out_var) set(PLSSVM_SUMMARY_STRING_ASSEMBLE "") if (DEFINED PLSSVM_CPU_TARGET_ARCHS) # add cpu platform @@ -29,4 +29,4 @@ function(assemble_summary_string out_var) # remove last comma string(REGEX REPLACE ",$" "" PLSSVM_SUMMARY_STRING_ASSEMBLE "${PLSSVM_SUMMARY_STRING_ASSEMBLE}") set(${out_var} "${PLSSVM_SUMMARY_STRING_ASSEMBLE}" PARENT_SCOPE) -endfunction() \ No newline at end of file +endfunction () diff --git a/cmake/check_python_libs.cmake b/cmake/check_python_libs.cmake index 0f03a9140..05cf968c2 100644 --- a/cmake/check_python_libs.cmake +++ b/cmake/check_python_libs.cmake @@ -1,24 +1,20 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -function(check_python_libs required_libraries error_string) +function (check_python_libs required_libraries error_string) foreach (PLSSVM_PYTHON_LIB ${required_libraries}) # search for Python package - execute_process( - COMMAND ${Python3_EXECUTABLE} -c "import ${PLSSVM_PYTHON_LIB}" - RESULT_VARIABLE PLSSVM_PYTHON_LIB_EXIT_CODE - OUTPUT_QUIET) - + execute_process(COMMAND ${Python3_EXECUTABLE} -c "import ${PLSSVM_PYTHON_LIB}" RESULT_VARIABLE PLSSVM_PYTHON_LIB_EXIT_CODE OUTPUT_QUIET) + # emit error if package couldn't be found if (NOT ${PLSSVM_PYTHON_LIB_EXIT_CODE} EQUAL 0) - message(FATAL_ERROR - "The '${PLSSVM_PYTHON_LIB}' Python3 package is not installed. " - "Please install it using the following command: '${Python3_EXECUTABLE} -m pip install ${PLSSVM_PYTHON_LIB}'\n " - "${error_string}" + message(FATAL_ERROR "The '${PLSSVM_PYTHON_LIB}' Python3 package is not installed. " + "Please install it using the following command: '${Python3_EXECUTABLE} -m pip install ${PLSSVM_PYTHON_LIB}'\n " + "${error_string}" ) endif () endforeach () -endfunction() \ No newline at end of file +endfunction () diff --git a/cmake/create_documentation_shortcut.cmake b/cmake/create_documentation_shortcut.cmake index 49a724291..b985c8530 100644 --- a/cmake/create_documentation_shortcut.cmake +++ b/cmake/create_documentation_shortcut.cmake @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -file(WRITE documentation.html "") \ No newline at end of file +file(WRITE documentation.html "") diff --git a/cmake/delete_coverage_files.cmake b/cmake/delete_coverage_files.cmake index bf50691c7..9b628d521 100644 --- a/cmake/delete_coverage_files.cmake +++ b/cmake/delete_coverage_files.cmake @@ -1,10 +1,10 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## file(GLOB_RECURSE PLSSVM_COVERAGE_GCDA_FILES ${CMAKE_BINARY_DIR}/*.gcda) file(REMOVE ${PLSSVM_COVERAGE_GCDA_FILES}) file(GLOB_RECURSE PLSSVM_COVERAGE_GCNO_FILES ${CMAKE_BINARY_DIR}/*.gcno) -file(REMOVE ${PLSSVM_COVERAGE_GCNO_FILES}) \ No newline at end of file +file(REMOVE ${PLSSVM_COVERAGE_GCNO_FILES}) diff --git a/cmake/discover_tests_with_death_test_filter.cmake b/cmake/discover_tests_with_death_test_filter.cmake index fa3b942d6..65f72e406 100644 --- a/cmake/discover_tests_with_death_test_filter.cmake +++ b/cmake/discover_tests_with_death_test_filter.cmake @@ -1,29 +1,28 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -function(discover_tests_with_death_test_filter test_executable_name) +function (discover_tests_with_death_test_filter test_executable_name) if (PLSSVM_ENABLE_DEATH_TESTS) # assertions are enabled -> enable Google death tests - gtest_discover_tests(${test_executable_name} PROPERTIES - DISCOVERY_TIMEOUT 600 - DISCOVERY_MODE PRE_TEST - WORKING_DIRECTORY $) + gtest_discover_tests( + ${test_executable_name} PROPERTIES DISCOVERY_TIMEOUT 600 DISCOVERY_MODE PRE_TEST WORKING_DIRECTORY $ + ) else () # assertions are disabled -> disable Google death tests - gtest_discover_tests(${test_executable_name} TEST_FILTER -*DeathTest* PROPERTIES - DISCOVERY_TIMEOUT 600 - DISCOVERY_MODE PRE_TEST - WORKING_DIRECTORY $) + gtest_discover_tests( + ${test_executable_name} TEST_FILTER -*DeathTest* PROPERTIES DISCOVERY_TIMEOUT 600 DISCOVERY_MODE PRE_TEST + WORKING_DIRECTORY $ + ) endif () if (WIN32) add_custom_command( - TARGET ${test_executable_name} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $ - COMMAND_EXPAND_LISTS + TARGET ${test_executable_name} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ + COMMAND_EXPAND_LISTS ) endif () -endfunction() +endfunction () diff --git a/cmake/git_watcher.cmake b/cmake/git_watcher.cmake index d8a3d60f3..f935122ab 100644 --- a/cmake/git_watcher.cmake +++ b/cmake/git_watcher.cmake @@ -4,6 +4,8 @@ # Released under the MIT License. # https://raw.githubusercontent.com/andrew-hardin/cmake-git-version-tracking/master/LICENSE +# cmake-format: off + # This file defines a target that monitors the state of a git repo. # If the state changes (e.g. a commit is made), then a file gets reconfigured. # Here are the primary variables that control script behavior: @@ -356,3 +358,5 @@ endfunction() # And off we go... Main() + +# cmake-format: on diff --git a/cmake/modules/Findcxxopts.cmake b/cmake/modules/Findcxxopts.cmake index cb33eb289..082841348 100644 --- a/cmake/modules/Findcxxopts.cmake +++ b/cmake/modules/Findcxxopts.cmake @@ -1,8 +1,8 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. -## Based on: https://gist.github.com/CodeFinder2/40864be863c887e0a6dabf4f3a1fa93b +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. +# Based on: https://gist.github.com/CodeFinder2/40864be863c887e0a6dabf4f3a1fa93b ######################################################################################################################## find_package(PkgConfig) @@ -14,10 +14,7 @@ endif () # try to automatically find the header files in the standard directories if (NOT EXISTS "${cxxopts_INCLUDE_DIR}") - find_path(cxxopts_INCLUDE_DIR - NAMES cxxopts.hpp - DOC "cxxopts header-only library header files" - ) + find_path(cxxopts_INCLUDE_DIR NAMES cxxopts.hpp DOC "cxxopts header-only library header files") endif () # allow the user to specify the include directory in the CMake call (if provided, used instead of the environment variable) @@ -25,7 +22,7 @@ if (EXISTS "${cxxopts_INCLUDE_DIR}") include(FindPackageHandleStandardArgs) mark_as_advanced(cxxopts_INCLUDE_DIR) else () - #message(WARNING "Can't find package cxxopts!") + # message(WARNING "Can't find package cxxopts!") endif () # set the _FOUND variable to the correct value diff --git a/cmake/modules/Findfast_float.cmake b/cmake/modules/Findfast_float.cmake index bd118fb52..b59f8186a 100644 --- a/cmake/modules/Findfast_float.cmake +++ b/cmake/modules/Findfast_float.cmake @@ -1,8 +1,8 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. -## Based on: https://gist.github.com/CodeFinder2/40864be863c887e0a6dabf4f3a1fa93b +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. +# Based on: https://gist.github.com/CodeFinder2/40864be863c887e0a6dabf4f3a1fa93b ######################################################################################################################## find_package(PkgConfig) @@ -14,10 +14,11 @@ endif () # try to automatically find the header files in the standard directories if (NOT EXISTS "${fast_float_INCLUDE_DIR}") - find_path(fast_float_INCLUDE_DIR - NAMES fast_float/fast_float.h - PATH_SUFFIXES include - DOC "fast_float header-only library header files" + find_path( + fast_float_INCLUDE_DIR + NAMES fast_float/fast_float.h + PATH_SUFFIXES include + DOC "fast_float header-only library header files" ) endif () @@ -26,7 +27,7 @@ if (EXISTS "${fast_float_INCLUDE_DIR}") include(FindPackageHandleStandardArgs) mark_as_advanced(fast_float_INCLUDE_DIR) else () - #message(WARNING "Can't find required package fast_float!") + # message(WARNING "Can't find required package fast_float!") endif () # set the _FOUND variable to the correct value diff --git a/cmake/modules/Findigor.cmake b/cmake/modules/Findigor.cmake index be5acc109..39cb7cd8b 100644 --- a/cmake/modules/Findigor.cmake +++ b/cmake/modules/Findigor.cmake @@ -1,8 +1,8 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. -## Based on: https://gist.github.com/CodeFinder2/40864be863c887e0a6dabf4f3a1fa93b +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. +# Based on: https://gist.github.com/CodeFinder2/40864be863c887e0a6dabf4f3a1fa93b ######################################################################################################################## find_package(PkgConfig) @@ -14,10 +14,11 @@ endif () # try to automatically find the header files in the standard directories if (NOT EXISTS "${igor_INCLUDE_DIR}") - find_path(igor_INCLUDE_DIR - NAMES igor/igor.hpp - PATH_SUFFIXES include - DOC "igor header-only library header files" + find_path( + igor_INCLUDE_DIR + NAMES igor/igor.hpp + PATH_SUFFIXES include + DOC "igor header-only library header files" ) endif () @@ -26,7 +27,7 @@ if (EXISTS "${igor_INCLUDE_DIR}") include(FindPackageHandleStandardArgs) mark_as_advanced(igor_INCLUDE_DIR) else () - #message(WARNING "Can't find required package igor!") + # message(WARNING "Can't find required package igor!") endif () # set the _FOUND variable to the correct value diff --git a/cmake/parse_architecture_info.cmake b/cmake/parse_architecture_info.cmake index 05adbc792..289cfe10a 100644 --- a/cmake/parse_architecture_info.cmake +++ b/cmake/parse_architecture_info.cmake @@ -1,15 +1,15 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -function(parse_architecture_info target_platform target_archs num_archs) +function (parse_architecture_info target_platform target_archs num_archs) # transform platforms to list (e.g "nvidia:sm_70,sm_80" -> "nvidia;sm_70,sm_80") string(REPLACE ":" ";" ARCH_LIST ${target_platform}) # remove platform from list (e.g. "nvidia;sm_70,sm_80" -> "sm_70,sm_80") list(POP_FRONT ARCH_LIST) - + if (ARCH_LIST STREQUAL "") # immediately return if architecture list is empty set(${target_archs} "" PARENT_SCOPE) @@ -18,10 +18,9 @@ function(parse_architecture_info target_platform target_archs num_archs) # transform architectures to list and set output-variable (e.g. "sm_70,sm_80" -> "sm_70;sm_80") string(REPLACE "," ";" ARCH_LIST ${ARCH_LIST}) set(${target_archs} ${ARCH_LIST} PARENT_SCOPE) - + # get number of architectures and set output-variable (e.g. "sm_70;sm_80" -> 2) list(LENGTH ARCH_LIST LEN) set(${num_archs} ${LEN} PARENT_SCOPE) endif () -endfunction() - +endfunction () diff --git a/cmake/plssvm/plssvmAdaptiveCppTargets.cmake b/cmake/plssvm/plssvmAdaptiveCppTargets.cmake index 741feb296..8c124701e 100644 --- a/cmake/plssvm/plssvmAdaptiveCppTargets.cmake +++ b/cmake/plssvm/plssvmAdaptiveCppTargets.cmake @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## include(CMakeFindDependencyMacro) @@ -18,4 +18,4 @@ if (TARGET plssvm::plssvm-SYCL_adaptivecpp) else () # set COMPONENT to be NOT found set(plssvm_AdaptiveCpp_FOUND OFF) -endif () \ No newline at end of file +endif () diff --git a/cmake/plssvm/plssvmCUDATargets.cmake b/cmake/plssvm/plssvmCUDATargets.cmake index 2be0772a1..6f8362e90 100644 --- a/cmake/plssvm/plssvmCUDATargets.cmake +++ b/cmake/plssvm/plssvmCUDATargets.cmake @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## include(CMakeFindDependencyMacro) @@ -19,4 +19,4 @@ if (TARGET plssvm::plssvm-CUDA) else () # set COMPONENT to be NOT found set(plssvm_CUDA_FOUND OFF) -endif () \ No newline at end of file +endif () diff --git a/cmake/plssvm/plssvmDPCPPTargets.cmake b/cmake/plssvm/plssvmDPCPPTargets.cmake index 10e699f2f..403585807 100644 --- a/cmake/plssvm/plssvmDPCPPTargets.cmake +++ b/cmake/plssvm/plssvmDPCPPTargets.cmake @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## include(CMakeFindDependencyMacro) @@ -16,4 +16,4 @@ if (TARGET plssvm::plssvm-SYCL_dpcpp) else () # set COMPONENT to be NOT found set(plssvm_DPCPP_FOUND OFF) -endif () \ No newline at end of file +endif () diff --git a/cmake/plssvm/plssvmHPXTargets.cmake b/cmake/plssvm/plssvmHPXTargets.cmake index 8fa711790..8cdda54e2 100644 --- a/cmake/plssvm/plssvmHPXTargets.cmake +++ b/cmake/plssvm/plssvmHPXTargets.cmake @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## include(CMakeFindDependencyMacro) diff --git a/cmake/plssvm/plssvmKokkosTargets.cmake b/cmake/plssvm/plssvmKokkosTargets.cmake index 7ec32069a..ea720dfa1 100644 --- a/cmake/plssvm/plssvmKokkosTargets.cmake +++ b/cmake/plssvm/plssvmKokkosTargets.cmake @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## include(CMakeFindDependencyMacro) @@ -18,4 +18,4 @@ if (TARGET plssvm::plssvm-Kokkos) else () # set COMPONENT to be NOT found set(plssvm_Kokkos_FOUND OFF) -endif () \ No newline at end of file +endif () diff --git a/cmake/plssvm/plssvmOpenCLTargets.cmake b/cmake/plssvm/plssvmOpenCLTargets.cmake index 66bc27f09..5e3c01344 100644 --- a/cmake/plssvm/plssvmOpenCLTargets.cmake +++ b/cmake/plssvm/plssvmOpenCLTargets.cmake @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## include(CMakeFindDependencyMacro) @@ -18,4 +18,4 @@ if (TARGET plssvm::plssvm-OpenCL) else () # set COMPONENT to be NOT found set(plssvm_OpenCL_FOUND OFF) -endif () \ No newline at end of file +endif () diff --git a/cmake/plssvm/plssvmOpenMPTargets.cmake b/cmake/plssvm/plssvmOpenMPTargets.cmake index d8a6951f2..256a46eea 100644 --- a/cmake/plssvm/plssvmOpenMPTargets.cmake +++ b/cmake/plssvm/plssvmOpenMPTargets.cmake @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## include(CMakeFindDependencyMacro) diff --git a/cmake/plssvm/plssvmstdparTargets.cmake b/cmake/plssvm/plssvmstdparTargets.cmake index ed3310ed9..0be6f52ae 100644 --- a/cmake/plssvm/plssvmstdparTargets.cmake +++ b/cmake/plssvm/plssvmstdparTargets.cmake @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## include(CMakeFindDependencyMacro) @@ -24,7 +24,9 @@ if (TARGET plssvm::plssvm-stdpar) if (NOT PLSSVM_HAS_HIPSTDPAR_STDPAR_FLAG) set(plssvm_FOUND OFF) set(plssvm_stdpar_FOUND OFF) - set(plssvm_NOT_FOUND_MESSAGE "The CMAKE_CXX_COMPILER must be set to the hipstdpar patched LLVM compiler (acpp) in user code in order to use plssvm::stdpar!") + set(plssvm_NOT_FOUND_MESSAGE + "The CMAKE_CXX_COMPILER must be set to the hipstdpar patched LLVM compiler (acpp) in user code in order to use plssvm::stdpar!" + ) return() endif () elseif (PLSSVM_STDPAR_BACKEND MATCHES "IntelLLVM") @@ -55,7 +57,7 @@ if (TARGET plssvm::plssvm-stdpar) return() endif () endif () - + # set alias targets add_library(plssvm::stdpar ALIAS plssvm::plssvm-stdpar) # set COMPONENT to be found @@ -63,4 +65,4 @@ if (TARGET plssvm::plssvm-stdpar) else () # set COMPONENT to be NOT found set(plssvm_stdpar_FOUND OFF) -endif () \ No newline at end of file +endif () diff --git a/cmake/utility_macros.cmake b/cmake/utility_macros.cmake index a2a5084cb..e0b8ad5e8 100644 --- a/cmake/utility_macros.cmake +++ b/cmake/utility_macros.cmake @@ -1,11 +1,11 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## # set variable in the local and parent scope -macro(set_local_and_parent NAME VALUE) +macro (set_local_and_parent NAME VALUE) if (${ARGC} GREATER 2) set(PLSSVM_TEMP_ARGN "${ARGN}") list(JOIN PLSSVM_TEMP_ARGN " " PLSSVM_REMAINING_FLAGS) @@ -15,16 +15,16 @@ macro(set_local_and_parent NAME VALUE) set(${ARGV0} "${ARGV1}") set(${ARGV0} "${ARGV1}" PARENT_SCOPE) endif () -endmacro() +endmacro () -macro(append_local_and_parent LIST_NAME VALUE) +macro (append_local_and_parent LIST_NAME VALUE) list(APPEND ${ARGV0} ${ARGV1}) set(${ARGV0} ${${ARGV0}} PARENT_SCOPE) -endmacro() +endmacro () # test whether the provided variable contains a natural number greater than zero -macro(check_integer VARIABLE) +macro (check_integer VARIABLE) if (NOT ${${VARIABLE}} MATCHES "^[0-9]+$" OR ${${VARIABLE}} LESS_EQUAL 0) message(FATAL_ERROR "The ${VARIABLE} must be a natural number greater 0, but is \"${${VARIABLE}}\"!") endif () -endmacro() \ No newline at end of file +endmacro () diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index ec8c0c40f..51656c84a 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,18 +1,18 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## list(APPEND CMAKE_MESSAGE_INDENT "Documentation: ") ######################################################################################################################## -## setup documentation generation with doxygen ## +# setup documentation generation with doxygen # ######################################################################################################################## -## use installed doxygen +# use installed doxygen find_package(Doxygen REQUIRED OPTIONAL_COMPONENTS dot) -## configure doxygen +# configure doxygen set(DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/docs") set(DOXYGEN_IMAGE_PATH "${PROJECT_SOURCE_DIR}/docs/resources") set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "${PROJECT_SOURCE_DIR}/README.md") @@ -38,7 +38,7 @@ set(DOXYGEN_INCLUDE_GRAPH "NO") set(DOXYGEN_EXTRACT_PRIVATE "YES") set(DOXYGEN_EXAMPLE_PATH "${PROJECT_SOURCE_DIR}/docs/resources/examples") -## enable processing of specific attributes and macros +# enable processing of specific attributes and macros set(DOXYGEN_ENABLE_PREPROCESSING "YES") set(DOXYGEN_MACRO_EXPANSION "YES") set(DOXYGEN_EXPAND_ONLY_PREDEF "YES") @@ -46,41 +46,37 @@ set(DOXYGEN_EXPAND_AS_DEFINED "YES") set(DOXYGEN_PREDEFINED "__attribute__((x))=;__CUDA_ARCH__=0") set(DOXYGEN_VERBATIM_VARS DOXYGEN_ALIASES) -set(DOXYGEN_ALIASES - [[license="\par License^^\parblock^^" ]] -) +set(DOXYGEN_ALIASES [[license="\par License^^\parblock^^" ]]) # sanitize README formulas for Doxygen if the sed utility is available find_program(PLSSVM_HAS_SED "sed") if (PLSSVM_HAS_SED) - set(DOXYGEN_FILTER_PATTERNS "*.md=sed -e '1,90 s/\\$/\\\\f\\$/g' -e '/^## Table of Contents/,/^## Introduction to PLSSVM/{//!d}' -e 's/^## Table of Contents/@tableofcontents/g' -e '/^# The Python3 Bindings/,/^We currently support two kinds of Python3 bindings/{//!d}' -e 's/^# The Python3 Bindings/@tableofcontents{HTML:3}/g' -e '/^#/ s/`//g'") - list(APPEND DOXYGEN_FILTER_PATTERNS "*.cl=sed -e 's/ PLSSVM_OPENCL_KERNEL_FUNCTION_PARAMETER_LIST)/, Args... PLSSVM_OPENCL_KERNEL_FUNCTION_PARAMETER_LIST)/g'") + set(DOXYGEN_FILTER_PATTERNS + "*.md=sed -e '1,90 s/\\$/\\\\f\\$/g' -e '/^## Table of Contents/,/^## Introduction to PLSSVM/{//!d}' -e 's/^## Table of Contents/@tableofcontents/g' -e '/^# The Python3 Bindings/,/^We currently support two kinds of Python3 bindings/{//!d}' -e 's/^# The Python3 Bindings/@tableofcontents{HTML:3}/g' -e '/^#/ s/`//g'" + ) + list(APPEND DOXYGEN_FILTER_PATTERNS + "*.cl=sed -e 's/ PLSSVM_OPENCL_KERNEL_FUNCTION_PARAMETER_LIST)/, Args... PLSSVM_OPENCL_KERNEL_FUNCTION_PARAMETER_LIST)/g'" + ) endif () -## add doxygen as target +# add doxygen as target doxygen_add_docs( - doc - "${PROJECT_SOURCE_DIR}/include;${PROJECT_SOURCE_DIR}/docs/resources;${PROJECT_SOURCE_DIR}/README.md;${PROJECT_SOURCE_DIR}/bindings/Python/README.md" - ALL # add to the default build target - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" - COMMENT "Generating API documentation with Doxygen" + doc "${PROJECT_SOURCE_DIR}/include;${PROJECT_SOURCE_DIR}/docs/resources;${PROJECT_SOURCE_DIR}/README.md;${PROJECT_SOURCE_DIR}/bindings/Python/README.md" + ALL # add to the default build target + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" COMMENT "Generating API documentation with Doxygen" ) -## create shortcut for index.html +# create shortcut for index.html add_custom_command( - TARGET doc - POST_BUILD - COMMAND ${CMAKE_COMMAND} -P "${PROJECT_SOURCE_DIR}/cmake/create_documentation_shortcut.cmake" - WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" + TARGET doc + POST_BUILD + COMMAND ${CMAKE_COMMAND} -P "${PROJECT_SOURCE_DIR}/cmake/create_documentation_shortcut.cmake" + WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" ) -## install targets for the documentation +# install targets for the documentation include(GNUInstallDirs) -install(DIRECTORY "${PROJECT_SOURCE_DIR}/docs/html" - DESTINATION "${CMAKE_INSTALL_DOCDIR}" -) -install(FILES "${CMAKE_CURRENT_LIST_DIR}/documentation.html" - DESTINATION "${CMAKE_INSTALL_DOCDIR}" -) +install(DIRECTORY "${PROJECT_SOURCE_DIR}/docs/html" DESTINATION "${CMAKE_INSTALL_DOCDIR}") +install(FILES "${CMAKE_CURRENT_LIST_DIR}/documentation.html" DESTINATION "${CMAKE_INSTALL_DOCDIR}") -list(POP_BACK CMAKE_MESSAGE_INDENT) \ No newline at end of file +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index 5c2917bb2..70b904666 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -7,4 +7,4 @@ find_package(plssvm CONFIG REQUIRED) add_executable(prog main.cpp) target_compile_features(prog PUBLIC cxx_std_17) -target_link_libraries(prog PUBLIC plssvm::plssvm-all) \ No newline at end of file +target_link_libraries(prog PUBLIC plssvm::plssvm-all) diff --git a/src/plssvm/backends/CUDA/CMakeLists.txt b/src/plssvm/backends/CUDA/CMakeLists.txt index 6b5e5d28f..1408f0a8a 100644 --- a/src/plssvm/backends/CUDA/CMakeLists.txt +++ b/src/plssvm/backends/CUDA/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## list(APPEND CMAKE_MESSAGE_INDENT "CUDA: ") @@ -58,8 +58,10 @@ if (CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") elseif (CMAKE_CUDA_COMPILER_ID STREQUAL "Clang") message(STATUS "Using Clang as CUDA compiler.") # use clang to compile CUDA code + set(CMAKE_CUDA_FLAGS + "${CMAKE_CUDA_FLAGS} -Wall -Wextra -Wdouble-promotion -Wshadow -Wcast-qual -Wnull-dereference -Wextra-semi -Wunreachable-code -Wuninitialized -Wmost -Wconversion" + ) # build type specific flags - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wall -Wextra -Wdouble-promotion -Wshadow -Wcast-qual -Wnull-dereference -Wextra-semi -Wunreachable-code -Wuninitialized -Wmost -Wconversion") set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "${CMAKE_CUDA_FLAGS_RELWITHDEBINFO} -O2") set(CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS} -O3") # set fast-math if requested @@ -116,4 +118,4 @@ append_local_and_parent(PLSSVM_TARGETS_TO_INSTALL ${PLSSVM_CUDA_BACKEND_LIBRARY_ list(TRANSFORM PLSSVM_NVIDIA_TARGET_ARCHS PREPEND "sm_") set(PLSSVM_CUDA_BACKEND_SUMMARY_STRING " - CUDA: nvidia (${PLSSVM_NVIDIA_TARGET_ARCHS})" PARENT_SCOPE) -list(POP_BACK CMAKE_MESSAGE_INDENT) \ No newline at end of file +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/src/plssvm/backends/HIP/CMakeLists.txt b/src/plssvm/backends/HIP/CMakeLists.txt index 1f1b4835e..d7859fea3 100644 --- a/src/plssvm/backends/HIP/CMakeLists.txt +++ b/src/plssvm/backends/HIP/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## list(APPEND CMAKE_MESSAGE_INDENT "HIP: ") @@ -34,7 +34,9 @@ endif () # check if HIP_PLATFORM is provided as environment variable if (DEFINED ENV{HIP_PLATFORM}) # check if the environment variable is correctly defined - if ((DEFINED PLSSVM_AMD_TARGET_ARCHS AND NOT $ENV{HIP_PLATFORM} MATCHES "amd") OR (DEFINED PLSSVM_NVIDIA_TARGET_ARCHS AND NOT $ENV{HIP_PLATFORM} MATCHES "nvidia")) + if ((DEFINED PLSSVM_AMD_TARGET_ARCHS AND NOT $ENV{HIP_PLATFORM} MATCHES "amd") OR (DEFINED PLSSVM_NVIDIA_TARGET_ARCHS AND NOT $ENV{HIP_PLATFORM} MATCHES + "nvidia") + ) if (PLSSVM_ENABLE_HIP_BACKEND MATCHES "ON") message(SEND_ERROR "Found invalid \"HIP_PLATFORM\" value ($ENV{HIP_PLATFORM}) for the requested HIP backend!") else () @@ -83,13 +85,15 @@ if (NOT HIP_FOUND) endif () message(CHECK_PASS "found") -## set necessary flags +# set necessary flags set(CMAKE_HIP_STANDARD 17) set(CMAKE_HIP_STANDARD_REQUIRED ON) if (DEFINED PLSSVM_AMD_TARGET_ARCHS) - ## hipcc is used to compile the HIP code -> set flags accordingly - set(CMAKE_HIP_FLAGS "${CMAKE_HIP_FLAGS} -std=c++17 -Wall -Wextra -Wdouble-promotion -Wshadow -Wcast-qual -Wnull-dereference -Wextra-semi -Wunreachable-code -Wuninitialized -Wmost -Wconversion") + # hipcc is used to compile the HIP code -> set flags accordingly + set(CMAKE_HIP_FLAGS + "${CMAKE_HIP_FLAGS} -std=c++17 -Wall -Wextra -Wdouble-promotion -Wshadow -Wcast-qual -Wnull-dereference -Wextra-semi -Wunreachable-code -Wuninitialized -Wmost -Wconversion" + ) # build type specific flags set(CMAKE_HIP_FLAGS_RELWITHDEBINFO "${CMAKE_HIP_FLAGS_RELWITHDEBINFO} -O2") set(CMAKE_HIP_FLAGS_RELEASE "${CMAKE_HIP_FLAGS_RELEASE} -O3") @@ -98,7 +102,7 @@ if (DEFINED PLSSVM_AMD_TARGET_ARCHS) set(CMAKE_HIP_FLAGS "${CMAKE_HIP_FLAGS} -ffast-math") endif () elseif (DEFINED PLSSVM_NVIDIA_TARGET_ARCHS) - ## nvcc is used to compile the HIP code -> set flags accordingly + # nvcc is used to compile the HIP code -> set flags accordingly set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler '-fPIC' -Xcudafe --diag_suppress=unsigned_compare_with_zero -lineinfo") # build type specific flags set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -Xptxas=-v -Xptxas -dlcm=cg -Xcudafe --diag_suppress=unrecognized_gcc_pragma") @@ -130,8 +134,7 @@ set_source_files_properties(${PLSSVM_HIP_SOURCES} PROPERTIES LANGUAGE ${PLSSVM_H set_local_and_parent(PLSSVM_HIP_BACKEND_LIBRARY_NAME plssvm-HIP) add_library(${PLSSVM_HIP_BACKEND_LIBRARY_NAME} SHARED ${PLSSVM_HIP_SOURCES}) -# https://gitlab.kitware.com/cmake/cmake/-/issues/23210 -#set_target_properties(${PLSSVM_HIP_BACKEND_LIBRARY_NAME} PROPERTIES HIP_SEPARABLE_COMPILATION ON) +# set_target_properties(${PLSSVM_HIP_BACKEND_LIBRARY_NAME} PROPERTIES HIP_SEPARABLE_COMPILATION ON) #< https://gitlab.kitware.com/cmake/cmake/-/issues/23210 target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC -Wno-sign-compare) diff --git a/src/plssvm/backends/HPX/CMakeLists.txt b/src/plssvm/backends/HPX/CMakeLists.txt index 97b96046e..64455e37f 100644 --- a/src/plssvm/backends/HPX/CMakeLists.txt +++ b/src/plssvm/backends/HPX/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## list(APPEND CMAKE_MESSAGE_INDENT "HPX: ") @@ -31,11 +31,7 @@ endif () message(CHECK_PASS "found ") # explicitly set sources -set(PLSSVM_HPX_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp - ${CMAKE_CURRENT_LIST_DIR}/csvm.cpp - ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp -) +set(PLSSVM_HPX_SOURCES ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp ${CMAKE_CURRENT_LIST_DIR}/csvm.cpp ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp) # set target properties set_local_and_parent(PLSSVM_HPX_BACKEND_LIBRARY_NAME plssvm-HPX) diff --git a/src/plssvm/backends/Kokkos/CMakeLists.txt b/src/plssvm/backends/Kokkos/CMakeLists.txt index bf37122f2..2eccba7e5 100644 --- a/src/plssvm/backends/Kokkos/CMakeLists.txt +++ b/src/plssvm/backends/Kokkos/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## list(APPEND CMAKE_MESSAGE_INDENT "Kokkos: ") @@ -40,7 +40,7 @@ if (Kokkos_ENABLE_SYCL) if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "IntelLLVM") message(FATAL_ERROR "For Kokkos::SYCL to work, the compiler must be IntelLLVM, but is ${CMAKE_CXX_COMPILER}!") endif () - + # set icpx specific compiler flags based on the provided PLSSVM_TARGET_PLATFORMS set(PLSSVM_KOKKOS_SYCL_FSYCL_TARGETS "") # cpu targets @@ -73,34 +73,38 @@ if (Kokkos_ENABLE_SYCL) list(JOIN PLSSVM_KOKKOS_SYCL_FSYCL_TARGETS "," PLSSVM_KOKKOS_SYCL_FSYCL_TARGETS_STRING) target_compile_options(${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME} PRIVATE -sycl-std=2020 -fsycl -fsycl-targets=${PLSSVM_KOKKOS_SYCL_FSYCL_TARGETS_STRING}) target_link_options(${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME} PRIVATE -fsycl -fsycl-targets=${PLSSVM_KOKKOS_SYCL_FSYCL_TARGETS_STRING}) - + # add option for IntelLLVM Ahead-of-Time (AOT) compilation option(PLSSVM_KOKKOS_BACKEND_INTEL_LLVM_ENABLE_AOT "Enables Ahead-of-Time compilation for the Kokkos::SYCL execution space using IntelLLVM." ON) if (PLSSVM_KOKKOS_BACKEND_INTEL_LLVM_ENABLE_AOT) message(STATUS "Enabled Ahead-of-Time (AOT) compilation for the Kokkos::SYCL execution space using IntelLLVM.") target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PRIVATE PLSSVM_KOKKOS_BACKEND_INTEL_LLVM_ENABLE_AOT) target_compile_definitions(${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME} PUBLIC PLSSVM_KOKKOS_BACKEND_INTEL_LLVM_ENABLE_AOT) - ## set AOT compiler flags - # cpu targets + # set AOT compiler flags if (DEFINED PLSSVM_CPU_TARGET_ARCHS) - # add target specific flags for AOT + # add CPU target specific flags for AOT if (PLSSVM_NUM_CPU_TARGET_ARCHS EQUAL 1) target_compile_options(${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=spir64_x86_64 "-march=${PLSSVM_CPU_TARGET_ARCHS}") target_link_options(${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=spir64_x86_64 "-march=${PLSSVM_CPU_TARGET_ARCHS}") endif () endif () - # nvidia targets if (DEFINED PLSSVM_NVIDIA_TARGET_ARCHS) - # add target specific flags for AOT + # add NVIDIA GPU target specific flags for AOT if (NOT PLSSVM_NUM_NVIDIA_TARGET_ARCHS EQUAL 1) - message(SEND_ERROR "IntelLLVM currently only supports a single NVIDIA architecture specification for AOT but ${PLSSVM_NUM_NVIDIA_TARGET_ARCHS} were provided!") + message( + SEND_ERROR + "IntelLLVM currently only supports a single NVIDIA architecture specification for AOT but ${PLSSVM_NUM_NVIDIA_TARGET_ARCHS} were provided!" + ) endif () - target_compile_options(${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=${PLSSVM_NVIDIA_TARGET_ARCHS}) - target_link_options(${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=${PLSSVM_NVIDIA_TARGET_ARCHS}) + target_compile_options( + ${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=${PLSSVM_NVIDIA_TARGET_ARCHS} + ) + target_link_options( + ${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=${PLSSVM_NVIDIA_TARGET_ARCHS} + ) endif () - # intel targets if (DEFINED PLSSVM_INTEL_TARGET_ARCHS) - # add target specific flags for AOT + # add Intel GPU target specific flags for AOT list(JOIN PLSSVM_INTEL_TARGET_ARCHS "," PLSSVM_INTEL_TARGET_ARCHS_STRING) target_compile_options(${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=spir64_gen "-device ${PLSSVM_INTEL_TARGET_ARCHS_STRING}") target_link_options(${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=spir64_gen "-device ${PLSSVM_INTEL_TARGET_ARCHS_STRING}") @@ -121,9 +125,11 @@ target_link_libraries(${PLSSVM_ALL_LIBRARY_NAME} INTERFACE ${PLSSVM_KOKKOS_BACKE # mark backend library as install target append_local_and_parent(PLSSVM_TARGETS_TO_INSTALL ${PLSSVM_KOKKOS_BACKEND_LIBRARY_NAME}) +# ~~~ # assemble Kokkos available execution space string # also set compile definitions -> can't use KOKKOS_ENABLE_* directly inside the "constexpr_available_execution_space.hpp" # header since we can't include "Kokkos_Core.hpp" there (transitively used in the base library that doesn't know anything about Kokkos +# ~~~ set(PLSSVM_KOKKOS_BACKEND_AVAILABLE_EXECUTION_SPACES "") if (Kokkos_ENABLE_CUDA) target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_KOKKOS_BACKEND_ENABLE_CUDA) @@ -163,10 +169,14 @@ if (Kokkos_ENABLE_SERIAL) endif () set(PLSSVM_KOKKOS_BACKEND_AVAILABLE_EXECUTION_SPACES "${PLSSVM_KOKKOS_BACKEND_AVAILABLE_EXECUTION_SPACES}" PARENT_SCOPE) +# ~~~ # also set the number of available Kokkos execution spaces to explicitly set the type of the used std::array # -> necessary if NO Kokkos execution space is available and, therefore, the size of the std::array would be 0 (can't automatically be deduced) +# ~~~ list(LENGTH PLSSVM_KOKKOS_BACKEND_AVAILABLE_EXECUTION_SPACES PLSSVM_KOKKOS_BACKEND_NUM_AVAILABLE_EXECUTION_SPACES) -target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_KOKKOS_BACKEND_NUM_AVAILABLE_EXECUTION_SPACES=${PLSSVM_KOKKOS_BACKEND_NUM_AVAILABLE_EXECUTION_SPACES}) +target_compile_definitions( + ${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_KOKKOS_BACKEND_NUM_AVAILABLE_EXECUTION_SPACES=${PLSSVM_KOKKOS_BACKEND_NUM_AVAILABLE_EXECUTION_SPACES} +) # generate summary string set(PLSSVM_KOKKOS_BACKEND_SUMMARY_STRING_COMPILER " - Kokkos (${PLSSVM_KOKKOS_BACKEND_AVAILABLE_EXECUTION_SPACES}):") @@ -179,4 +189,4 @@ string(REPLACE " (${PLSSVM_AMD_TARGET_ARCHS})" "" PLSSVM_KOKKOS_BACKEND_SUMMARY_ string(REPLACE " (${PLSSVM_INTEL_TARGET_ARCHS})" "" PLSSVM_KOKKOS_BACKEND_SUMMARY_STRING_ARCHS "${PLSSVM_KOKKOS_BACKEND_SUMMARY_STRING_ARCHS}") set(PLSSVM_KOKKOS_BACKEND_SUMMARY_STRING "${PLSSVM_KOKKOS_BACKEND_SUMMARY_STRING_COMPILER}${PLSSVM_KOKKOS_BACKEND_SUMMARY_STRING_ARCHS}" PARENT_SCOPE) -list(POP_BACK CMAKE_MESSAGE_INDENT) \ No newline at end of file +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/src/plssvm/backends/OpenCL/CMakeLists.txt b/src/plssvm/backends/OpenCL/CMakeLists.txt index 2da46a145..c0b59d124 100644 --- a/src/plssvm/backends/OpenCL/CMakeLists.txt +++ b/src/plssvm/backends/OpenCL/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## list(APPEND CMAKE_MESSAGE_INDENT "OpenCL: ") @@ -39,17 +39,19 @@ add_library(${PLSSVM_OPENCL_BACKEND_LIBRARY_NAME} SHARED ${PLSSVM_OPENCL_SOURCES target_include_directories(${PLSSVM_OPENCL_BACKEND_LIBRARY_NAME} PUBLIC ${OpenCL_INCLUDE_DIRS}) target_link_libraries(${PLSSVM_OPENCL_BACKEND_LIBRARY_NAME} PUBLIC OpenCL) -target_sources(${PLSSVM_OPENCL_BACKEND_LIBRARY_NAME} PRIVATE - FILE_SET HEADERS - BASE_DIRS - "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel" - FILES - "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/cg_explicit/blas.cl" - "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/cg_explicit/kernel_matrix_assembly.cl" - "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/cg_implicit/kernel_matrix_assembly_blas.cl" - "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/kernel_functions.cl" - "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/predict_kernel.cl" - "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/predict_kernel_linear.cl" +target_sources( + ${PLSSVM_OPENCL_BACKEND_LIBRARY_NAME} + PRIVATE FILE_SET + HEADERS + BASE_DIRS + "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel" + FILES + "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/cg_explicit/blas.cl" + "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/cg_explicit/kernel_matrix_assembly.cl" + "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/cg_implicit/kernel_matrix_assembly_blas.cl" + "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/kernel_functions.cl" + "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/predict_kernel.cl" + "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel/predict_kernel_linear.cl" ) # link base library against OpenCL library @@ -59,14 +61,18 @@ target_link_libraries(${PLSSVM_OPENCL_BACKEND_LIBRARY_NAME} PUBLIC ${PLSSVM_BASE set(PLSSVM_OPENCL_KERNEL_SOURCE_DIRECTORY "${PROJECT_SOURCE_DIR}/include/plssvm/backends/OpenCL/kernel") target_compile_definitions(${PLSSVM_OPENCL_BACKEND_LIBRARY_NAME} PRIVATE PLSSVM_OPENCL_KERNEL_SOURCE_DIR="${PLSSVM_OPENCL_KERNEL_SOURCE_DIRECTORY}") -# set OpenCL library name (concatenated to the full kernel source string, to make sure that different OpenCL libraries -# are recognized by the sha256 caching algorithm) +# set OpenCL library name (concatenated to the full kernel source string, to make sure that different OpenCL libraries are recognized by the sha256 caching +# algorithm) target_compile_definitions(${PLSSVM_OPENCL_BACKEND_LIBRARY_NAME} PRIVATE PLSSVM_OPENCL_LIBRARY="${OpenCL_LIBRARY}") # option only available if NVIDIA GPUs are requested as target platforms if (PLSSVM_NUM_NVIDIA_TARGET_ARCHS GREATER 0) # add option to completely disable PTX inline assembly - option(PLSSVM_OPENCL_BACKEND_ENABLE_PTX_INLINE_ASSEMBLY "Enables the usage of PTX inline assembly on NVIDIA GPUs to greatly improve the atomicAdd performance! Only available for sm greater or equal than sm_60." ON) + option( + PLSSVM_OPENCL_BACKEND_ENABLE_PTX_INLINE_ASSEMBLY + "Enables the usage of PTX inline assembly on NVIDIA GPUs to greatly improve the atomicAdd performance! Only available for sm greater or equal than sm_60." + ON + ) if (PLSSVM_OPENCL_BACKEND_ENABLE_PTX_INLINE_ASSEMBLY) # test whether the requested sm version is new enough list(TRANSFORM PLSSVM_NVIDIA_TARGET_ARCHS REPLACE "sm_" "") @@ -75,7 +81,7 @@ if (PLSSVM_NUM_NVIDIA_TARGET_ARCHS GREATER 0) message(FATAL_ERROR "Requested PTX inline assembly to speed up the FP32/FP64 atomicAdd, but the supplied sm_${sm_value} is too old!") endif () endforeach () - + message(STATUS "Enabled PTX inline assembly on NVIDIA GPUs to greatly improve the atomicAdd performance.") target_compile_definitions(${PLSSVM_OPENCL_BACKEND_LIBRARY_NAME} PRIVATE PLSSVM_OPENCL_BACKEND_USE_PTX_INLINE_ASSEMBLY) endif () @@ -116,4 +122,4 @@ string(REPLACE " (${PLSSVM_AMD_TARGET_ARCHS})" "" PLSSVM_OPENCL_BACKEND_SUMMARY_ string(REPLACE " (${PLSSVM_INTEL_TARGET_ARCHS})" "" PLSSVM_OPENCL_BACKEND_SUMMARY_STRING_ARCHS "${PLSSVM_OPENCL_BACKEND_SUMMARY_STRING_ARCHS}") set(PLSSVM_OPENCL_BACKEND_SUMMARY_STRING "${PLSSVM_OPENCL_BACKEND_SUMMARY_STRING_COMPILER}${PLSSVM_OPENCL_BACKEND_SUMMARY_STRING_ARCHS}" PARENT_SCOPE) -list(POP_BACK CMAKE_MESSAGE_INDENT) \ No newline at end of file +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/src/plssvm/backends/OpenMP/CMakeLists.txt b/src/plssvm/backends/OpenMP/CMakeLists.txt index 450dd8cc5..24bdbe1ab 100644 --- a/src/plssvm/backends/OpenMP/CMakeLists.txt +++ b/src/plssvm/backends/OpenMP/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## list(APPEND CMAKE_MESSAGE_INDENT "OpenMP: ") @@ -31,11 +31,7 @@ endif () message(CHECK_PASS "found ") # explicitly set sources -set(PLSSVM_OPENMP_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp - ${CMAKE_CURRENT_LIST_DIR}/csvm.cpp - ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp -) +set(PLSSVM_OPENMP_SOURCES ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp ${CMAKE_CURRENT_LIST_DIR}/csvm.cpp ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp) # set target properties set_local_and_parent(PLSSVM_OPENMP_BACKEND_LIBRARY_NAME plssvm-OpenMP) @@ -43,9 +39,11 @@ add_library(${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME} SHARED ${PLSSVM_OPENMP_SOURCES # link against OpenMP if (${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC") + # ~~~ # special command line options for MSVC: - # -openmp:llvm -> enables unsigned loop indexes in OpenMP parallel for loops - # -openmp:experimental -> enables OpenMP's SIMD instructions + # - openmp:llvm -> enables unsigned loop indexes in OpenMP parallel for loops + # - openmp:experimental -> enables OpenMP's SIMD instructions + # ~~~ target_compile_options(${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME} PRIVATE -openmp:llvm -openmp:experimental) else () target_link_libraries(${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME} PRIVATE OpenMP::OpenMP_CXX) @@ -57,12 +55,13 @@ target_compile_options(${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME} PRIVATE $<$:-Wno-unknown-pragmas> + target_compile_options( + ${PLSSVM_SYCL_BACKEND_ADAPTIVECPP_LIBRARY_NAME} PRIVATE -Wno-unknown-warning-option -Wconversion $<$:-Wno-unknown-pragmas> ) - + # print note that Intel GPU architecture specifications are ignored when using AdaptiveCpp if (DEFINED PLSSVM_INTEL_TARGET_ARCHS) message(STATUS "Ignoring specified Intel architectures \"${PLSSVM_INTEL_TARGET_ARCHS}\" in favor of SPIR-V when using AdaptiveCpp!") endif () - + target_link_libraries(${PLSSVM_SYCL_BACKEND_ADAPTIVECPP_LIBRARY_NAME} PUBLIC ${PLSSVM_BASE_LIBRARY_NAME}) else () message(CHECK_FAIL "not found") -endif () \ No newline at end of file +endif () diff --git a/src/plssvm/backends/SYCL/CMakeLists.txt b/src/plssvm/backends/SYCL/CMakeLists.txt index 0bb8303e5..dc96f644d 100644 --- a/src/plssvm/backends/SYCL/CMakeLists.txt +++ b/src/plssvm/backends/SYCL/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## include(CMakeDependentOption) @@ -11,28 +11,29 @@ list(APPEND CMAKE_MESSAGE_INDENT "SYCL: ") message(CHECK_START "Checking for SYCL backend") # explicitly set sources shared between all SYCL implementations -set(PLSSVM_SYCL_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp -) +set(PLSSVM_SYCL_SOURCES ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp) # list of found SYCL implementations set(PLSSVM_SYCL_BACKEND_FOUND_IMPLEMENTATIONS "") -# check if SYCL can be enabled -## add AdaptiveCpp +######################################################################################################################## +# check if SYCL can be enabled # +######################################################################################################################## + +# add AdaptiveCpp set(PLSSVM_ENABLE_SYCL_ADAPTIVECPP_BACKEND ${PLSSVM_ENABLE_SYCL_BACKEND} CACHE STRING "Enable AdaptiveCpp as SYCL Backend") set_property(CACHE PLSSVM_ENABLE_SYCL_ADAPTIVECPP_BACKEND PROPERTY STRINGS AUTO ON OFF) if (PLSSVM_ENABLE_SYCL_ADAPTIVECPP_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_SYCL_ADAPTIVECPP_BACKEND) add_subdirectory(AdaptiveCpp) endif () -## add DPC++ +# add DPC++ set(PLSSVM_ENABLE_SYCL_DPCPP_BACKEND ${PLSSVM_ENABLE_SYCL_BACKEND} CACHE STRING "Enable DPC++ as SYCL Backend") set_property(CACHE PLSSVM_ENABLE_SYCL_DPCPP_BACKEND PROPERTY STRINGS AUTO ON OFF) if (PLSSVM_ENABLE_SYCL_DPCPP_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_SYCL_DPCPP_BACKEND) add_subdirectory(DPCPP) endif () -## check if ANY SYCL implementation has been found +# check if ANY SYCL implementation has been found if (NOT PLSSVM_SYCL_BACKEND_FOUND_IMPLEMENTATIONS) message(CHECK_FAIL "not found") if (PLSSVM_ENABLE_SYCL_BACKEND MATCHES "ON") @@ -56,7 +57,7 @@ if (TARGET ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME}) target_link_libraries(${PLSSVM_SYCL_BACKEND_LIBRARY_NAME} INTERFACE ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME}) endif () -## check if environment variables are correctly set if more than one SYCL implementation has been found +# check if environment variables are correctly set if more than one SYCL implementation has been found list(LENGTH PLSSVM_SYCL_BACKEND_FOUND_IMPLEMENTATIONS PLSSVM_SYCL_BACKEND_NUM_FOUND_IMPLEMENTATIONS) if (PLSSVM_SYCL_BACKEND_NUM_FOUND_IMPLEMENTATIONS GREATER 1) if (NOT DEFINED ENV{PLSSVM_SYCL_ADAPTIVECPP_INCLUDE_DIR}) @@ -76,7 +77,10 @@ if (DEFINED PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION) message(STATUS "Setting preferred SYCL implementation to \"${PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION}\".") else () # value not recognized - message(SEND_ERROR "\"${PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION}\" as preferred SYCL implementation unrecognized or not available! Possible values are: ${PLSSVM_SYCL_BACKEND_FOUND_IMPLEMENTATIONS}.") + message( + SEND_ERROR + "\"${PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION}\" as preferred SYCL implementation unrecognized or not available! Possible values are: ${PLSSVM_SYCL_BACKEND_FOUND_IMPLEMENTATIONS}." + ) endif () else () # no command line value provided -> try to infer preferred SYCL implementation @@ -90,12 +94,18 @@ else () message(STATUS "Setting preferred SYCL implementation to \"${PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION}\".") endif () endif () -target_compile_definitions(${PLSSVM_SYCL_BACKEND_LIBRARY_NAME} INTERFACE PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION=${PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION}) +target_compile_definitions( + ${PLSSVM_SYCL_BACKEND_LIBRARY_NAME} INTERFACE PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION=${PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION} +) if (TARGET ${PLSSVM_SYCL_BACKEND_ADAPTIVECPP_LIBRARY_NAME}) - target_compile_definitions(${PLSSVM_SYCL_BACKEND_ADAPTIVECPP_LIBRARY_NAME} PRIVATE PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION=${PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION}) + target_compile_definitions( + ${PLSSVM_SYCL_BACKEND_ADAPTIVECPP_LIBRARY_NAME} PRIVATE PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION=${PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION} + ) endif () if (TARGET ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME}) - target_compile_definitions(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION=${PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION}) + target_compile_definitions( + ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION=${PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION} + ) endif () # link against interface library @@ -119,24 +129,26 @@ foreach (SYCL_IMPLEMENTATION ${PLSSVM_SYCL_BACKEND_FOUND_IMPLEMENTATIONS}) if ("${PLSSVM_SYCL_BACKEND_LIBRARY_NAME_COMPILE_DEFINITIONS}" MATCHES ".*${SYCL_IMPLEMENTATION}.*") set(SYCL_IMPLEMENTATION "${SYCL_IMPLEMENTATION}*") endif () - + assemble_summary_string(PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS) # do not print CPU and Intel GPU target architectures when using AdaptiveCpp if ("${SYCL_IMPLEMENTATION}" MATCHES "^adaptivecpp") if (PLSSVM_SYCL_BACKEND_ADAPTIVECPP_USE_GENERIC_SSCP) - + assemble_summary_string(PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS) # do not print any special target architecture information string(REPLACE " (${PLSSVM_CPU_TARGET_ARCHS})" "" PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS "${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS}") string(REPLACE " (${PLSSVM_NVIDIA_TARGET_ARCHS})" "" PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS "${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS}") string(REPLACE " (${PLSSVM_AMD_TARGET_ARCHS})" "" PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS "${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS}") string(REPLACE " (${PLSSVM_INTEL_TARGET_ARCHS})" "" PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS "${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS}") - + # remove first whitespace from string string(LENGTH "${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS}" PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS_LENGTH) - MATH(EXPR PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS_LENGTH "${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS_LENGTH} - 1") - string(SUBSTRING "${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS}" 1 ${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS_LENGTH} PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS) - + math(EXPR PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS_LENGTH "${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS_LENGTH} - 1") + string(SUBSTRING "${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS}" 1 ${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS_LENGTH} + PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS + ) + set(PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS " generic (${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS})") else () string(REPLACE " (${PLSSVM_CPU_TARGET_ARCHS})" "" PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS "${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS}") @@ -145,9 +157,9 @@ foreach (SYCL_IMPLEMENTATION ${PLSSVM_SYCL_BACKEND_FOUND_IMPLEMENTATIONS}) elseif ("${SYCL_IMPLEMENTATION}" MATCHES "^dpcpp") set(SYCL_IMPLEMENTATION "icpx/${SYCL_IMPLEMENTATION}") endif () - + list(APPEND PLSSVM_SYCL_BACKEND_SUMMARY_STRINGS " - SYCL (${SYCL_IMPLEMENTATION}):${PLSSVM_SYCL_BACKEND_SUMMARY_STRING_ARCHS}") endforeach () set(PLSSVM_SYCL_BACKEND_SUMMARY_STRINGS "${PLSSVM_SYCL_BACKEND_SUMMARY_STRINGS}" PARENT_SCOPE) -list(POP_BACK CMAKE_MESSAGE_INDENT) \ No newline at end of file +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/src/plssvm/backends/SYCL/DPCPP/CMakeLists.txt b/src/plssvm/backends/SYCL/DPCPP/CMakeLists.txt index 4d0e5fe8f..765fea052 100644 --- a/src/plssvm/backends/SYCL/DPCPP/CMakeLists.txt +++ b/src/plssvm/backends/SYCL/DPCPP/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## message(CHECK_START "Checking for DPC++ as SYCL implementation") @@ -13,9 +13,7 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES "IntelLLVM") set(PLSSVM_SYCL_BACKEND_CHECK_FOR_DPCPP_COMPILER ON) elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") # intel llvm fork must be clang - execute_process( - COMMAND ${CMAKE_CXX_COMPILER} --help - OUTPUT_VARIABLE PLSSVM_DPCPP_CLANG_HELP_OUTPUT) + execute_process(COMMAND ${CMAKE_CXX_COMPILER} --help OUTPUT_VARIABLE PLSSVM_DPCPP_CLANG_HELP_OUTPUT) # check if help message contains DPC++ specific values if ("${PLSSVM_DPCPP_CLANG_HELP_OUTPUT}" MATCHES ".*intel.*" AND "${PLSSVM_DPCPP_CLANG_HELP_OUTPUT}" MATCHES ".*-fsycl.*") message(STATUS "Found Intel LLVM fork (https://github.com/intel/llvm).") @@ -26,33 +24,30 @@ endif () if (PLSSVM_SYCL_BACKEND_CHECK_FOR_DPCPP_COMPILER) message(CHECK_PASS "found") append_local_and_parent(PLSSVM_SYCL_BACKEND_FOUND_IMPLEMENTATIONS "dpcpp") - + # set DPC++ specific targets - set(PLSSVM_SYCL_DPCPP_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/detail/device_ptr.cpp - ${CMAKE_CURRENT_LIST_DIR}/detail/pinned_memory.cpp - ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp - ${CMAKE_CURRENT_LIST_DIR}/csvm.cpp + set(PLSSVM_SYCL_DPCPP_SOURCES ${CMAKE_CURRENT_LIST_DIR}/detail/device_ptr.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/pinned_memory.cpp + ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp ${CMAKE_CURRENT_LIST_DIR}/csvm.cpp ) - + # set target properties set(PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME plssvm-SYCL_dpcpp CACHE INTERNAL "") add_library(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} SHARED ${PLSSVM_SYCL_SOURCES} ${PLSSVM_SYCL_DPCPP_SOURCES}) append_local_and_parent(PLSSVM_TARGETS_TO_INSTALL "${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME}") - + # necessary target_*_directories if more than one SYCL implementation could be found if (DEFINED ENV{PLSSVM_SYCL_DPCPP_INCLUDE_DIR}) message(STATUS "PLSSVM_SYCL_DPCPP_INCLUDE_DIR is \"$ENV{PLSSVM_SYCL_DPCPP_INCLUDE_DIR}\"") target_include_directories(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PUBLIC $ENV{PLSSVM_SYCL_DPCPP_INCLUDE_DIR}) endif () - + # add target compile definitions for DPC++ target_compile_definitions(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PUBLIC PLSSVM_HAS_SYCL_BACKEND) target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PRIVATE PLSSVM_SYCL_BACKEND_HAS_DPCPP) target_compile_definitions(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PUBLIC PLSSVM_SYCL_BACKEND_HAS_DPCPP) target_compile_definitions(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE PLSSVM_SYCL_BACKEND_COMPILER=0) target_compile_definitions(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE PLSSVM_SYCL_BACKEND_COMPILER_NAME="DPC++") - + # set whether the kernels should be compiled with fast math enabled or not if (PLSSVM_ENABLE_FAST_MATH) target_compile_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -ffast-math) @@ -60,15 +55,27 @@ if (PLSSVM_SYCL_BACKEND_CHECK_FOR_DPCPP_COMPILER) # DPC++ does compile with fast-math by default -> explicitly disable it if not requested otherwise! target_compile_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -fno-fast-math) endif () - + # enable DPC++ SYCL support target_compile_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -sycl-std=2020 -fsycl -fno-sycl-id-queries-fit-in-int) target_link_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -fsycl) # add additional compiler warnings - target_compile_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE - -Wconversion -Wall -Wextra -Wmost -Wdouble-promotion -fno-common -Wshadow -Wcast-qual - -Wextra-semi -Wunreachable-code -Wuninitialized -Wno-ctor-dtor-privacy) - + target_compile_options( + ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} + PRIVATE -Wconversion + -Wall + -Wextra + -Wmost + -Wdouble-promotion + -fno-common + -Wshadow + -Wcast-qual + -Wextra-semi + -Wunreachable-code + -Wuninitialized + -Wno-ctor-dtor-privacy + ) + set(PLSSVM_DPCPP_FSYCL_TARGETS "") # cpu targets if (DEFINED PLSSVM_CPU_TARGET_ARCHS) @@ -92,7 +99,9 @@ if (PLSSVM_SYCL_BACKEND_CHECK_FOR_DPCPP_COMPILER) if (NOT PLSSVM_NUM_AMD_TARGET_ARCHS EQUAL 1) message(SEND_ERROR "DPC++ currently only supports a single AMD architecture specification but ${PLSSVM_NUM_AMD_TARGET_ARCHS} were provided!") endif () - target_compile_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${PLSSVM_AMD_TARGET_ARCHS}) + target_compile_options( + ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${PLSSVM_AMD_TARGET_ARCHS} + ) target_link_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${PLSSVM_AMD_TARGET_ARCHS}) endif () # intel targets @@ -104,19 +113,20 @@ if (PLSSVM_SYCL_BACKEND_CHECK_FOR_DPCPP_COMPILER) list(JOIN PLSSVM_DPCPP_FSYCL_TARGETS "," PLSSVM_DPCPP_FSYCL_TARGETS_STRING) target_compile_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -fsycl-targets=${PLSSVM_DPCPP_FSYCL_TARGETS_STRING}) target_link_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -fsycl-targets=${PLSSVM_DPCPP_FSYCL_TARGETS_STRING}) - + # add option for DPC++ Ahead-of-Time (AOT) compilation option(PLSSVM_SYCL_BACKEND_DPCPP_ENABLE_AOT "Enables Ahead-of-Time compilation for DPC++." ON) if (PLSSVM_SYCL_BACKEND_DPCPP_ENABLE_AOT) message(STATUS "Enabled Ahead-of-Time (AOT) compilation with DPC++.") target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PRIVATE PLSSVM_SYCL_BACKEND_DPCPP_ENABLE_AOT) target_compile_definitions(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PUBLIC PLSSVM_SYCL_BACKEND_DPCPP_ENABLE_AOT) - ## set AOT compiler flags - # cpu targets + # set AOT compiler flags cpu targets if (DEFINED PLSSVM_CPU_TARGET_ARCHS) # add target specific flags for AOT if (PLSSVM_NUM_CPU_TARGET_ARCHS EQUAL 1) - target_compile_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=spir64_x86_64 "-march=${PLSSVM_CPU_TARGET_ARCHS}") + target_compile_options( + ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=spir64_x86_64 "-march=${PLSSVM_CPU_TARGET_ARCHS}" + ) target_link_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=spir64_x86_64 "-march=${PLSSVM_CPU_TARGET_ARCHS}") endif () endif () @@ -124,21 +134,31 @@ if (PLSSVM_SYCL_BACKEND_CHECK_FOR_DPCPP_COMPILER) if (DEFINED PLSSVM_NVIDIA_TARGET_ARCHS) # add target specific flags for AOT if (NOT PLSSVM_NUM_NVIDIA_TARGET_ARCHS EQUAL 1) - message(SEND_ERROR "DPC++ currently only supports a single NVIDIA architecture specification for AOT but ${PLSSVM_NUM_NVIDIA_TARGET_ARCHS} were provided!") + message( + SEND_ERROR + "DPC++ currently only supports a single NVIDIA architecture specification for AOT but ${PLSSVM_NUM_NVIDIA_TARGET_ARCHS} were provided!" + ) endif () - target_compile_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=${PLSSVM_NVIDIA_TARGET_ARCHS}) - target_link_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=${PLSSVM_NVIDIA_TARGET_ARCHS}) - # -Xcuda-ptxas --verbose + target_compile_options( + ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=${PLSSVM_NVIDIA_TARGET_ARCHS} + ) + target_link_options( + ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=${PLSSVM_NVIDIA_TARGET_ARCHS} + ) endif () # intel targets if (DEFINED PLSSVM_INTEL_TARGET_ARCHS) # add target specific flags for AOT list(JOIN PLSSVM_INTEL_TARGET_ARCHS "," PLSSVM_INTEL_TARGET_ARCHS_STRING) - target_compile_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=spir64_gen "-device ${PLSSVM_INTEL_TARGET_ARCHS_STRING}") - target_link_options(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=spir64_gen "-device ${PLSSVM_INTEL_TARGET_ARCHS_STRING}") + target_compile_options( + ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=spir64_gen "-device ${PLSSVM_INTEL_TARGET_ARCHS_STRING}" + ) + target_link_options( + ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PRIVATE -Xsycl-target-backend=spir64_gen "-device ${PLSSVM_INTEL_TARGET_ARCHS_STRING}" + ) endif () endif () - + # be able to choose between the Level-Zero and OpenCL DPC++ backend for CPUs or Intel GPUs option(PLSSVM_SYCL_BACKEND_DPCPP_USE_LEVEL_ZERO "Enable DPC++'s Level-Zero backend in favor of the OpenCL backend." ON) if (PLSSVM_SYCL_BACKEND_DPCPP_USE_LEVEL_ZERO) @@ -150,7 +170,7 @@ if (PLSSVM_SYCL_BACKEND_CHECK_FOR_DPCPP_COMPILER) target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PRIVATE PLSSVM_SYCL_BACKEND_DPCPP_BACKEND_TYPE="opencl") target_compile_definitions(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PUBLIC PLSSVM_SYCL_BACKEND_DPCPP_BACKEND_TYPE="opencl") endif () - + # be able to choose between the HIP and OpenCL DPC++ backend for AMD GPUs option(PLSSVM_SYCL_BACKEND_DPCPP_GPU_AMD_USE_HIP "Enable DPC++'s HIP backend in favor of the OpenCL backend for AMD GPUs." ON) if (PLSSVM_SYCL_BACKEND_DPCPP_GPU_AMD_USE_HIP) @@ -162,8 +182,8 @@ if (PLSSVM_SYCL_BACKEND_CHECK_FOR_DPCPP_COMPILER) target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PRIVATE PLSSVM_SYCL_BACKEND_DPCPP_GPU_AMD_BACKEND_TYPE="opencl") target_compile_definitions(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PUBLIC PLSSVM_SYCL_BACKEND_DPCPP_GPU_AMD_BACKEND_TYPE="opencl") endif () - + target_link_libraries(${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME} PUBLIC ${PLSSVM_BASE_LIBRARY_NAME}) else () message(CHECK_FAIL "not found") -endif () \ No newline at end of file +endif () diff --git a/src/plssvm/backends/stdpar/AdaptiveCpp/CMakeLists.txt b/src/plssvm/backends/stdpar/AdaptiveCpp/CMakeLists.txt index efa394e47..d4a84c5b9 100644 --- a/src/plssvm/backends/stdpar/AdaptiveCpp/CMakeLists.txt +++ b/src/plssvm/backends/stdpar/AdaptiveCpp/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## message(CHECK_START "searching for AdaptiveCpp") @@ -10,14 +10,15 @@ message(CHECK_START "searching for AdaptiveCpp") find_package(TBB QUIET) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND TBB_FOUND) - # AdaptiveCpp also needs TBB # check for the AdaptiveCpp compiler include(CheckCXXCompilerFlag) check_cxx_compiler_flag("--acpp-stdpar" PLSSVM_HAS_ACPP_STDPAR_FLAG) if (NOT PLSSVM_HAS_ACPP_STDPAR_FLAG) # the stdpar flag couldn't be found! if (PLSSVM_ENABLE_STDPAR_BACKEND MATCHES "ON") - message(SEND_ERROR "Found a Clang, but AdaptiveCpp's stdpar compiler flag isn't supported (mostly likely because the used Clang isn't AdaptiveCpp)!") + message( + SEND_ERROR "Found a Clang, but AdaptiveCpp's stdpar compiler flag isn't supported (mostly likely because the used Clang isn't AdaptiveCpp)!" + ) else () message(STATUS "Found a Clang, but AdaptiveCpp's stdpar compiler flag isn't supported (mostly likely because the used Clang isn't AdaptiveCpp)!") endif () @@ -53,4 +54,4 @@ target_link_libraries(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE TBB:: # set AdaptiveCpp compile definition target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_STDPAR_BACKEND_HAS_ACPP) -target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_HAS_ACPP) \ No newline at end of file +target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_HAS_ACPP) diff --git a/src/plssvm/backends/stdpar/CMakeLists.txt b/src/plssvm/backends/stdpar/CMakeLists.txt index 660f6424f..f10bd289b 100644 --- a/src/plssvm/backends/stdpar/CMakeLists.txt +++ b/src/plssvm/backends/stdpar/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## list(APPEND CMAKE_MESSAGE_INDENT "stdpar: ") @@ -10,18 +10,23 @@ list(APPEND CMAKE_MESSAGE_INDENT "stdpar: ") message(CHECK_START "Checking for stdpar backend") # explicitly set general sources -set(PLSSVM_STDPAR_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp - ${CMAKE_CURRENT_LIST_DIR}/csvm.cpp - ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp -) +set(PLSSVM_STDPAR_SOURCES ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp ${CMAKE_CURRENT_LIST_DIR}/csvm.cpp ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp) # create interface library used in the sub-CMakeLists set(PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE plssvm-stdpar-interface) add_library(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE) set(PLSSVM_STDPAR_BACKEND_IMPLEMENTATION AUTO CACHE STRING "Set the stdpar implementation that should be used.") -set_property(CACHE PLSSVM_STDPAR_BACKEND_IMPLEMENTATION PROPERTY STRINGS AUTO NVHPC roc-stdpar IntelLLVM ACPP GNU_TBB) +set_property( + CACHE PLSSVM_STDPAR_BACKEND_IMPLEMENTATION + PROPERTY STRINGS + AUTO + NVHPC + roc-stdpar + IntelLLVM + ACPP + GNU_TBB +) # try finding a stdpar backend if (PLSSVM_STDPAR_BACKEND_IMPLEMENTATION MATCHES "NVHPC") @@ -137,4 +142,4 @@ elseif (PLSSVM_STDPAR_BACKEND STREQUAL "GNU_TBB") endif () set(PLSSVM_STDPAR_BACKEND_SUMMARY_STRING " - stdpar (${PLSSVM_STDPAR_BACKEND_NAME}):${PLSSVM_STDPAR_BACKEND_SUMMARY_STRING_ARCHS}" PARENT_SCOPE) -list(POP_BACK CMAKE_MESSAGE_INDENT) \ No newline at end of file +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/src/plssvm/backends/stdpar/GNU_TBB/CMakeLists.txt b/src/plssvm/backends/stdpar/GNU_TBB/CMakeLists.txt index fdf1f3e19..42fde8030 100644 --- a/src/plssvm/backends/stdpar/GNU_TBB/CMakeLists.txt +++ b/src/plssvm/backends/stdpar/GNU_TBB/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## message(CHECK_START "searching for GNU GCC + TBB") @@ -10,7 +10,6 @@ message(CHECK_START "searching for GNU GCC + TBB") find_package(TBB QUIET) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND TBB_FOUND) - # GNU GCC also needs TBB # GNU GCC + TBB needs either a CPU target if (NOT DEFINED PLSSVM_CPU_TARGET_ARCHS) if (PLSSVM_ENABLE_STDPAR_BACKEND MATCHES "ON") @@ -32,7 +31,7 @@ endif () # add stdpar implementation specific source file to library append_local_and_parent(PLSSVM_STDPAR_SOURCES ${CMAKE_CURRENT_LIST_DIR}/csvm.cpp) -## try finding Boost atomic +# try finding Boost atomic if (POLICY CMP0144) cmake_policy(SET CMP0144 OLD) # suppress cmake warning endif () @@ -49,4 +48,4 @@ target_link_libraries(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE TBB:: # set GNU GCC + TBB compile definition target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_STDPAR_BACKEND_HAS_GNU_TBB) -target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_HAS_GNU_TBB) \ No newline at end of file +target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_HAS_GNU_TBB) diff --git a/src/plssvm/backends/stdpar/IntelLLVM/CMakeLists.txt b/src/plssvm/backends/stdpar/IntelLLVM/CMakeLists.txt index 15eaa58c5..f30a26494 100644 --- a/src/plssvm/backends/stdpar/IntelLLVM/CMakeLists.txt +++ b/src/plssvm/backends/stdpar/IntelLLVM/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## message(CHECK_START "searching for Intel LLVM (icpx)") @@ -47,18 +47,38 @@ if (DEFINED PLSSVM_CPU_TARGET_ARCHS) message(STATUS "CPU target platform provided, setting: \"-fsycl-pstl-offload=cpu\"") set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG -fsycl -fsycl-pstl-offload=cpu -fsycl-targets=spir64_x86_64) if (PLSSVM_NUM_CPU_TARGET_ARCHS EQUAL 1) - set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG} -Xsycl-target-backend=spir64_x86_64 "-march=${PLSSVM_CPU_TARGET_ARCHS}") + set_local_and_parent( + PLSSVM_STDPAR_BACKEND_COMPILER_FLAG ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG} -Xsycl-target-backend=spir64_x86_64 "-march=${PLSSVM_CPU_TARGET_ARCHS}" + ) endif () else () message(STATUS "A GPU target platform provided, setting: \"-fsycl-pstl-offload=gpu\"") set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG -fsycl -fsycl-pstl-offload=gpu) - + if (DEFINED PLSSVM_NVIDIA_TARGET_ARCHS) - set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG} -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=${PLSSVM_NVIDIA_TARGET_ARCHS}) + set_local_and_parent( + PLSSVM_STDPAR_BACKEND_COMPILER_FLAG + ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG} + -fsycl-targets=nvptx64-nvidia-cuda + -Xsycl-target-backend=nvptx64-nvidia-cuda + --offload-arch=${PLSSVM_NVIDIA_TARGET_ARCHS} + ) elseif (DEFINED PLSSVM_AMD_TARGET_ARCHS) - set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG} -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${PLSSVM_AMD_TARGET_ARCHS}) + set_local_and_parent( + PLSSVM_STDPAR_BACKEND_COMPILER_FLAG + ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG} + -fsycl-targets=amdgcn-amd-amdhsa + -Xsycl-target-backend=amdgcn-amd-amdhsa + --offload-arch=${PLSSVM_AMD_TARGET_ARCHS} + ) elseif (DEFINED PLSSVM_INTEL_TARGET_ARCHS) - set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG} -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen "-device ${PLSSVM_INTEL_TARGET_ARCHS}") + set_local_and_parent( + PLSSVM_STDPAR_BACKEND_COMPILER_FLAG + ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG} + -fsycl-targets=spir64_gen + -Xsycl-target-backend=spir64_gen + "-device ${PLSSVM_INTEL_TARGET_ARCHS}" + ) endif () endif () if (PLSSVM_ENABLE_FAST_MATH) @@ -76,4 +96,4 @@ target_link_libraries(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC oneDPL) # set Intel LLVM compile definition target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_STDPAR_BACKEND_HAS_INTEL_LLVM) -target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_HAS_INTEL_LLVM) \ No newline at end of file +target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_HAS_INTEL_LLVM) diff --git a/src/plssvm/backends/stdpar/NVHPC/CMakeLists.txt b/src/plssvm/backends/stdpar/NVHPC/CMakeLists.txt index 3d49aec5d..8fb253a25 100644 --- a/src/plssvm/backends/stdpar/NVHPC/CMakeLists.txt +++ b/src/plssvm/backends/stdpar/NVHPC/CMakeLists.txt @@ -1,13 +1,13 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## message(CHECK_START "searching for NVHPC (nvc++)") +# check for NVIDIA's nvhpc compiler if (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC") - # check for NVIDIA's nvhpc compiler # nvhpc needs either a CPU or an NVIDIA GPU as target if (NOT DEFINED PLSSVM_CPU_TARGET_ARCHS AND NOT DEFINED PLSSVM_NVIDIA_TARGET_ARCHS) if (PLSSVM_ENABLE_STDPAR_BACKEND MATCHES "ON") @@ -44,19 +44,19 @@ if (DEFINED PLSSVM_CPU_TARGET_ARCHS) message(STATUS "CPU target platform provided, setting: \"-stdpar=multicore -tp=native\"") set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG -stdpar=multicore) set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG} -tp=native) - + target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_NVHPC_CPU) elseif (DEFINED PLSSVM_NVIDIA_TARGET_ARCHS) message(STATUS "NVIDIA GPU target platform provided, setting: \"-stdpar=gpu\"") set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG -stdpar=gpu) - - # TODO: if supported by the device, this may fix the performance tracking error in our tests? - # set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG -gpu=unified) - + + # set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG -gpu=unified) #< TODO: if supported by the device, this may fix the performance tracking error in + # our tests? + if (PLSSVM_ENABLE_FAST_MATH) set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG} -gpu=fastmath) endif () - + target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_NVHPC_GPU) endif () separate_arguments(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG UNIX_COMMAND ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG}) @@ -67,4 +67,4 @@ find_package(CUDAToolkit) # set NVHPC compile definition target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_STDPAR_BACKEND_HAS_NVHPC) -target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_HAS_NVHPC) \ No newline at end of file +target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_HAS_NVHPC) diff --git a/src/plssvm/backends/stdpar/roc-stdpar/CMakeLists.txt b/src/plssvm/backends/stdpar/roc-stdpar/CMakeLists.txt index 136c5f2b5..d8e02018d 100644 --- a/src/plssvm/backends/stdpar/roc-stdpar/CMakeLists.txt +++ b/src/plssvm/backends/stdpar/roc-stdpar/CMakeLists.txt @@ -1,16 +1,20 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## message(CHECK_START "searching for roc-stdpar") # check whether the roc-stdpar include path has been provided if (DEFINED PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH) - set(PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH ${PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH} CACHE STRING "The roc-stdpar path (--hipstdpar-path) necessary to compile the roc-stdpar backend." FORCE) + set(PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH ${PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH} + CACHE STRING "The roc-stdpar path (--hipstdpar-path) necessary to compile the roc-stdpar backend." FORCE + ) elseif (DEFINED ENV{PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH}) - set(PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH $ENV{PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH} CACHE STRING "The roc-stdpar path (--hipstdpar-path) necessary to compile the roc-stdpar backend." FORCE) + set(PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH $ENV{PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH} + CACHE STRING "The roc-stdpar path (--hipstdpar-path) necessary to compile the roc-stdpar backend." FORCE + ) endif () if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH) @@ -52,8 +56,10 @@ endif () append_local_and_parent(PLSSVM_STDPAR_SOURCES ${CMAKE_CURRENT_LIST_DIR}/csvm.cpp) # set global roc-stdpar compiler flags +set_local_and_parent( + PLSSVM_STDPAR_BACKEND_COMPILER_FLAG -hipstdpar --hipstdpar-path=${PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH} --offload-arch=${PLSSVM_AMD_TARGET_ARCHS} +) # TODO: The flag "--hipstdpar-interpose-alloc" may be necessary for older AMD GPUs -set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG -hipstdpar --hipstdpar-path=${PLSSVM_STDPAR_BACKEND_HIPSTDPAR_PATH} --offload-arch=${PLSSVM_AMD_TARGET_ARCHS}) if (PLSSVM_ENABLE_FAST_MATH) set_local_and_parent(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG ${PLSSVM_STDPAR_BACKEND_COMPILER_FLAG} -ffast-math) @@ -62,4 +68,4 @@ separate_arguments(PLSSVM_STDPAR_BACKEND_COMPILER_FLAG UNIX_COMMAND ${PLSSVM_STD # set roc-stdpar compile definition target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_STDPAR_BACKEND_HAS_HIPSTDPAR) -target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_HAS_HIPSTDPAR) \ No newline at end of file +target_compile_definitions(${PLSSVM_STDPAR_BACKEND_LIBRARY_INTERFACE} INTERFACE PLSSVM_STDPAR_BACKEND_HAS_HIPSTDPAR) diff --git a/src/plssvm/detail/tracking/CMakeLists.txt b/src/plssvm/detail/tracking/CMakeLists.txt index c71462b3d..c5a3fdcf3 100644 --- a/src/plssvm/detail/tracking/CMakeLists.txt +++ b/src/plssvm/detail/tracking/CMakeLists.txt @@ -1,32 +1,33 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## list(APPEND CMAKE_MESSAGE_INDENT "Tracking: ") message(STATUS "Enabled performance tracking to YAML files for the PLSSVM executables plssvm-train, plssvm-predict, and plssvm-scale.") -target_sources(${PLSSVM_BASE_LIBRARY_NAME} PRIVATE $) +target_sources( + ${PLSSVM_BASE_LIBRARY_NAME} PRIVATE $ +) -## add target definitions +# add target definitions target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_PERFORMANCE_TRACKER_ENABLED) option(PLSSVM_ENABLE_HARDWARE_SAMPLING "Enable hardware sampling (like clock frequency or power draw)." OFF) if (PLSSVM_ENABLE_HARDWARE_SAMPLING) - ## enable hardware sampling + # enable hardware sampling target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_HARDWARE_SAMPLING_ENABLED) - + include(${PROJECT_SOURCE_DIR}/cmake/utility_macros.cmake) - ## option for the used sampling interval - set(PLSSVM_HARDWARE_SAMPLING_INTERVAL "100" CACHE STRING "The interval in milliseconds in which the hardware information (like clock frequency or power draw) are queried.") + # option for the used sampling interval + set(PLSSVM_HARDWARE_SAMPLING_INTERVAL "100" + CACHE STRING "The interval in milliseconds in which the hardware information (like clock frequency or power draw) are queried." + ) check_integer(PLSSVM_HARDWARE_SAMPLING_INTERVAL) target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_HARDWARE_SAMPLING_INTERVAL=${PLSSVM_HARDWARE_SAMPLING_INTERVAL}ms) - + include(FetchContent) set(PLSSVM_hws_VERSION v1.0.3) find_package(hws QUIET) @@ -38,19 +39,20 @@ if (PLSSVM_ENABLE_HARDWARE_SAMPLING) set(HWS_ENABLE_ERROR_CHECKS ${PLSSVM_ENABLE_ASSERTS} CACHE INTERNAL "" FORCE) set(HWS_SAMPLING_INTERVAL ${PLSSVM_HARDWARE_SAMPLING_INTERVAL} CACHE INTERNAL "" FORCE) set(HWS_ENABLE_PYTHON_BINDINGS OFF CACHE INTERNAL "" FORCE) - FetchContent_Declare(hws - GIT_REPOSITORY https://github.com/SC-SGS/hardware_sampling - GIT_TAG ${PLSSVM_hws_VERSION} - QUIET + FetchContent_Declare( + hws + GIT_REPOSITORY https://github.com/SC-SGS/hardware_sampling + GIT_TAG ${PLSSVM_hws_VERSION} + QUIET ) FetchContent_MakeAvailable(hws) add_dependencies(${PLSSVM_BASE_LIBRARY_NAME} hws) endif () target_link_libraries(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC hws::hws) - - ## mark backend library as install target + + # mark backend library as install target list(APPEND PLSSVM_TARGETS_TO_INSTALL "${PLSSVM_HARDWARE_TRACKING_LIBRARY_NAME}") set(PLSSVM_TARGETS_TO_INSTALL ${PLSSVM_TARGETS_TO_INSTALL} PARENT_SCOPE) endif () -list(POP_BACK CMAKE_MESSAGE_INDENT) \ No newline at end of file +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4ffcaa87e..d476b01dd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,12 +1,12 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## list(APPEND CMAKE_MESSAGE_INDENT "Tests: ") -## setup testing wit GoogleTest +# setup testing wit GoogleTest set(PLSSVM_googletest_VERSION v1.15.2) find_package(GTest 1.15.2 QUIET) if (GTEST_FOUND) @@ -20,11 +20,12 @@ else () set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") # fetch testing framework GoogleTest include(FetchContent) - FetchContent_Declare(googletest - GIT_REPOSITORY https://github.com/google/googletest - GIT_TAG ${PLSSVM_googletest_VERSION} - GIT_SHALLOW TRUE - QUIET + FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest + GIT_TAG ${PLSSVM_googletest_VERSION} + GIT_SHALLOW TRUE + QUIET ) FetchContent_MakeAvailable(googletest) # For Windows: Prevent overriding the parent project's compiler/linker settings @@ -43,10 +44,13 @@ if (PLSSVM_GENERATE_TEST_FILE) check_integer(PLSSVM_TEST_FILE_NUM_FEATURES) set(PLSSVM_TEST_FILE_NUM_CLASSES "4" CACHE STRING "number of classes for the test file generator") check_integer(PLSSVM_TEST_FILE_NUM_CLASSES) - + # set test file name based on requested sizes - set(PLSSVM_TEST_FILE "${PROJECT_SOURCE_DIR}/tests/data/${PLSSVM_TEST_FILE_NUM_DATA_POINTS}x${PLSSVM_TEST_FILE_NUM_FEATURES}_${PLSSVM_TEST_FILE_NUM_CLASSES}.libsvm" CACHE STRING "Path including name of the test file" FORCE) - + set(PLSSVM_TEST_FILE + "${PROJECT_SOURCE_DIR}/tests/data/${PLSSVM_TEST_FILE_NUM_DATA_POINTS}x${PLSSVM_TEST_FILE_NUM_FEATURES}_${PLSSVM_TEST_FILE_NUM_CLASSES}.libsvm" + CACHE STRING "Path including name of the test file" FORCE + ) + # check if the requested test file already exists and is not zero based indexed (otherwise create new test file) if (EXISTS "${PLSSVM_TEST_FILE}") file(READ "${PLSSVM_TEST_FILE}" PLSSVM_TEST_FILE_CONTENT) @@ -60,40 +64,42 @@ if (PLSSVM_GENERATE_TEST_FILE) if (NOT EXISTS "${PLSSVM_TEST_FILE}") # find necessary Python3 packages to use the test file generator find_package(Python3 REQUIRED COMPONENTS Interpreter Development) - + include(${PROJECT_SOURCE_DIR}/cmake/check_python_libs.cmake) set(PLSSVM_TEST_REQUIRED_LIBS argparse sklearn humanize numpy) message(STATUS "Checking required Python3 libraries (${PLSSVM_TEST_REQUIRED_LIBS}) to to generate the test file.") check_python_libs("${PLSSVM_TEST_REQUIRED_LIBS}" "or set PLSSVM_GENERATE_TEST_FILE to OFF.") - + # generate test file message(STATUS "Generating test file: ${PLSSVM_TEST_FILE}.") execute_process( - COMMAND ${Python3_EXECUTABLE} "${PROJECT_SOURCE_DIR}/utility_scripts/generate_data.py" "--output" "${PLSSVM_TEST_FILE}" "--format" "libsvm" "--samples" "${PLSSVM_TEST_FILE_NUM_DATA_POINTS}" "--features" "${PLSSVM_TEST_FILE_NUM_FEATURES}" "--classes" "${PLSSVM_TEST_FILE_NUM_CLASSES}" - OUTPUT_QUIET) + COMMAND ${Python3_EXECUTABLE} "${PROJECT_SOURCE_DIR}/utility_scripts/generate_data.py" "--output" "${PLSSVM_TEST_FILE}" "--format" "libsvm" + "--samples" "${PLSSVM_TEST_FILE_NUM_DATA_POINTS}" "--features" "${PLSSVM_TEST_FILE_NUM_FEATURES}" "--classes" + "${PLSSVM_TEST_FILE_NUM_CLASSES}" OUTPUT_QUIET + ) endif () else () # set test file to default test file set(PLSSVM_TEST_FILE "${PROJECT_SOURCE_DIR}/tests/data/libsvm/500x200_4.libsvm" CACHE STRING "Path including name of the test file") endif () -## warn if PLSSVM_ENABLE_FAST_MATH is set and tests are enabled +# warn if PLSSVM_ENABLE_FAST_MATH is set and tests are enabled if (PLSSVM_ENABLE_FAST_MATH) - message(WARNING "PLSSVM_ENABLE_FAST_MATH is set while also testing is enabled. This may result in tests failing due to increased floating point inaccuracies.") + message( + WARNING "PLSSVM_ENABLE_FAST_MATH is set while also testing is enabled. This may result in tests failing due to increased floating point inaccuracies." + ) endif () -## create base test library +# create base test library set(PLSSVM_BASE_TEST_LIBRARY_NAME base_tests_lib) # list all necessary sources -set(PLSSVM_BASE_TEST_LIBRARY_NAME_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/backends/ground_truth.cpp -) +set(PLSSVM_BASE_TEST_LIBRARY_NAME_SOURCES ${CMAKE_CURRENT_LIST_DIR}/backends/ground_truth.cpp) # create base test library add_library(${PLSSVM_BASE_TEST_LIBRARY_NAME} SHARED ${PLSSVM_BASE_TEST_LIBRARY_NAME_SOURCES}) -## optionally use a reduced number of label types in the tests +# optionally use a reduced number of label types in the tests option(PLSSVM_TEST_WITH_REDUCED_LABEL_TYPES "Reduce the number of tested label types to speed up compilation and actual tests." OFF) if (PLSSVM_TEST_WITH_REDUCED_LABEL_TYPES) message(STATUS "Reducing the number of tested label types.") @@ -113,27 +119,23 @@ target_link_libraries(${PLSSVM_BASE_TEST_LIBRARY_NAME} PUBLIC ${PLSSVM_ALL_LIBRA # link against gtest target_link_libraries(${PLSSVM_BASE_TEST_LIBRARY_NAME} PUBLIC GTest::gmock) -## create base tests +# create base tests set(PLSSVM_BASE_TEST_NAME Base_tests) # list all necessary sources set(PLSSVM_BASE_TEST_SOURCES - ## it is unnecessary to test the execution range for each backend + # it is unnecessary to test the execution range for each backend ${CMAKE_CURRENT_LIST_DIR}/backends/execution_range.cpp - - ## since the SYCL implementation_type and kernel_invocation_type enumerations are used even if no SYCL backend - ## is available these are also tested in the base library + # since the SYCL implementation_type and kernel_invocation_type enumerations are used even if no SYCL backend is available these are also tested in the base + # library ${CMAKE_CURRENT_LIST_DIR}/backends/SYCL/implementation_types.cpp ${CMAKE_CURRENT_LIST_DIR}/backends/SYCL/kernel_invocation_types.cpp - ## since the stdpar implementation_type enumeration is used even if no stdpar backend - ## is available this is also tested in the base library + # since the stdpar implementation_type enumeration is used even if no stdpar backend is available this is also tested in the base library ${CMAKE_CURRENT_LIST_DIR}/backends/stdpar/implementation_types.cpp - ${CMAKE_CURRENT_LIST_DIR}/detail/cmd/data_set_variants.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/cmd/parser_predict.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/cmd/parser_scale.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/cmd/parser_train.cpp - ${CMAKE_CURRENT_LIST_DIR}/detail/io/libsvm_model_parsing/data_parse_valid.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/io/libsvm_model_parsing/data_parse_invalid.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/io/libsvm_model_parsing/data_write.cpp @@ -145,7 +147,6 @@ set(PLSSVM_BASE_TEST_SOURCES ${CMAKE_CURRENT_LIST_DIR}/detail/io/file_reader.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/io/libsvm_parsing.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/io/scaling_factors_parsing.cpp - ${CMAKE_CURRENT_LIST_DIR}/detail/arithmetic_type_name.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/assert.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/data_distribution.cpp @@ -160,13 +161,10 @@ set(PLSSVM_BASE_TEST_SOURCES ${CMAKE_CURRENT_LIST_DIR}/detail/type_list.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/type_traits.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp - ${CMAKE_CURRENT_LIST_DIR}/exceptions/exceptions.cpp ${CMAKE_CURRENT_LIST_DIR}/exceptions/source_location.cpp - ${CMAKE_CURRENT_LIST_DIR}/version/git_metadata/git_metadata.cpp ${CMAKE_CURRENT_LIST_DIR}/version/version.cpp - ${CMAKE_CURRENT_LIST_DIR}/backend_types.cpp ${CMAKE_CURRENT_LIST_DIR}/classification_report.cpp ${CMAKE_CURRENT_LIST_DIR}/classification_types.cpp @@ -226,16 +224,16 @@ add_test(NAME MainScale/executable_version COMMAND ${PLSSVM_EXECUTABLE_SCALE_NAM # add minimal run test add_test(NAME MainTrain/executable_minimal COMMAND ${PLSSVM_EXECUTABLE_TRAIN_NAME} "${PLSSVM_TEST_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/test.libsvm.model") -add_test(NAME MainPredict/executable_minimal COMMAND ${PLSSVM_EXECUTABLE_PREDICT_NAME} - "${CMAKE_CURRENT_LIST_DIR}/data/predict/50x20.libsvm" # test file - "${CMAKE_CURRENT_LIST_DIR}/data/predict/50x20_double_linear_oaa.libsvm.model" # model file - "${CMAKE_CURRENT_BINARY_DIR}/test.libsvm.predict" # predict file (result) +add_test(NAME MainPredict/executable_minimal + COMMAND ${PLSSVM_EXECUTABLE_PREDICT_NAME} "${CMAKE_CURRENT_LIST_DIR}/data/predict/50x20.libsvm" # test file + "${CMAKE_CURRENT_LIST_DIR}/data/predict/50x20_double_linear_oaa.libsvm.model" # model file + "${CMAKE_CURRENT_BINARY_DIR}/test.libsvm.predict" # predict file (result) ) add_test(NAME MainScale/executable_minimal COMMAND ${PLSSVM_EXECUTABLE_SCALE_NAME} "${PLSSVM_TEST_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/scaled.libsvm.model") -add_test(NAME MainScale/executable_save_scaling_factors COMMAND ${PLSSVM_EXECUTABLE_SCALE_NAME} - -s "${CMAKE_CURRENT_BINARY_DIR}/scaling_parameter.txt" # the file the scaling parameters are saved to - "${PLSSVM_TEST_FILE}" # the file to scale - "${CMAKE_CURRENT_BINARY_DIR}/scaled.libsvm.model" # the scaled file (result) +add_test(NAME MainScale/executable_save_scaling_factors + COMMAND ${PLSSVM_EXECUTABLE_SCALE_NAME} -s "${CMAKE_CURRENT_BINARY_DIR}/scaling_parameter.txt" # the file the scaling parameters are saved to + "${PLSSVM_TEST_FILE}" # the file to scale + "${CMAKE_CURRENT_BINARY_DIR}/scaled.libsvm.model" # the scaled file (result) ) # add failing test (must return with a non-zero exit code) diff --git a/tests/backends/CMakeLists.txt b/tests/backends/CMakeLists.txt index dffe57615..657bedb40 100644 --- a/tests/backends/CMakeLists.txt +++ b/tests/backends/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## # create OpenMP tests if the OpenMP backend is available diff --git a/tests/backends/CUDA/CMakeLists.txt b/tests/backends/CUDA/CMakeLists.txt index f02738701..78b120390 100644 --- a/tests/backends/CUDA/CMakeLists.txt +++ b/tests/backends/CUDA/CMakeLists.txt @@ -1,10 +1,10 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -## create CUDA tests +# create CUDA tests set(PLSSVM_CUDA_TEST_NAME CUDA_tests) # list all necessary sources @@ -33,4 +33,4 @@ discover_tests_with_death_test_filter(${PLSSVM_CUDA_TEST_NAME}) # add test as coverage dependency if (TARGET coverage) add_dependencies(coverage ${PLSSVM_CUDA_TEST_NAME}) -endif () \ No newline at end of file +endif () diff --git a/tests/backends/HIP/CMakeLists.txt b/tests/backends/HIP/CMakeLists.txt index 28d1079fb..e70d488af 100644 --- a/tests/backends/HIP/CMakeLists.txt +++ b/tests/backends/HIP/CMakeLists.txt @@ -1,10 +1,10 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -## create HIP tests +# create HIP tests set(PLSSVM_HIP_TEST_NAME HIP_tests) if (DEFINED PLSSVM_NVIDIA_TARGET_ARCHS) @@ -53,7 +53,6 @@ target_link_libraries(${PLSSVM_HIP_BACKEND_TEST_LIBRARY_NAME} PUBLIC ${PLSSVM_BA add_executable(${PLSSVM_HIP_TEST_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../main.cpp) target_link_libraries(${PLSSVM_HIP_TEST_NAME} PRIVATE ${PLSSVM_HIP_BACKEND_TEST_LIBRARY_NAME}) - # add tests to google test include(GoogleTest) include(${PROJECT_SOURCE_DIR}/cmake/discover_tests_with_death_test_filter.cmake) @@ -62,4 +61,4 @@ discover_tests_with_death_test_filter(${PLSSVM_HIP_TEST_NAME}) # add test as coverage dependency if (TARGET coverage) add_dependencies(coverage ${PLSSVM_HIP_TEST_NAME}) -endif () \ No newline at end of file +endif () diff --git a/tests/backends/HPX/CMakeLists.txt b/tests/backends/HPX/CMakeLists.txt index 194c132fe..171c5ff23 100644 --- a/tests/backends/HPX/CMakeLists.txt +++ b/tests/backends/HPX/CMakeLists.txt @@ -1,20 +1,16 @@ -## Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## find_package(HPX 1.9.0 REQUIRED) -## create HPX tests +# create HPX tests set(PLSSVM_HPX_TEST_NAME HPX_tests) # list all necessary sources -set(PLSSVM_HPX_TEST_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp - ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp - ${CMAKE_CURRENT_LIST_DIR}/hpx_csvm.cpp -) +set(PLSSVM_HPX_TEST_SOURCES ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp ${CMAKE_CURRENT_LIST_DIR}/hpx_csvm.cpp) # add test executable add_executable(${PLSSVM_HPX_TEST_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../hpx_main.cpp ${PLSSVM_HPX_TEST_SOURCES}) diff --git a/tests/backends/Kokkos/CMakeLists.txt b/tests/backends/Kokkos/CMakeLists.txt index f29367a27..b6a5a1c0c 100644 --- a/tests/backends/Kokkos/CMakeLists.txt +++ b/tests/backends/Kokkos/CMakeLists.txt @@ -1,10 +1,10 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -## create Kokkos tests +# create Kokkos tests set(PLSSVM_KOKKOS_TEST_NAME Kokkos_tests) # list all necessary sources @@ -30,7 +30,7 @@ add_executable(${PLSSVM_KOKKOS_TEST_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../main.c if (Kokkos_ENABLE_CUDA) # fix template limit when using Kokkos::Cuda target_compile_options(${PLSSVM_KOKKOS_TEST_NAME} PRIVATE -Xcudafe --pending_instantiations=0) - + # tests won't compile with nvcc if (NOT PLSSVM_TEST_WITH_REDUCED_LABEL_TYPES) message(FATAL_ERROR "Due to template instantiation limits within nvcc, only reduced label type tests are currently supported!") @@ -51,4 +51,4 @@ discover_tests_with_death_test_filter(${PLSSVM_KOKKOS_TEST_NAME}) # add test as coverage dependency if (TARGET coverage) add_dependencies(coverage ${PLSSVM_KOKKOS_TEST_NAME}) -endif () \ No newline at end of file +endif () diff --git a/tests/backends/OpenCL/CMakeLists.txt b/tests/backends/OpenCL/CMakeLists.txt index 614c6ddad..d656b6237 100644 --- a/tests/backends/OpenCL/CMakeLists.txt +++ b/tests/backends/OpenCL/CMakeLists.txt @@ -1,10 +1,10 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -## create OpenCL tests +# create OpenCL tests set(PLSSVM_OPENCL_TEST_NAME OpenCL_tests) # list all necessary sources @@ -31,4 +31,4 @@ discover_tests_with_death_test_filter(${PLSSVM_OPENCL_TEST_NAME}) # add test as coverage dependency if (TARGET coverage) add_dependencies(coverage ${PLSSVM_OPENCL_TEST_NAME}) -endif () \ No newline at end of file +endif () diff --git a/tests/backends/OpenMP/CMakeLists.txt b/tests/backends/OpenMP/CMakeLists.txt index 65cc3f263..12f09273b 100644 --- a/tests/backends/OpenMP/CMakeLists.txt +++ b/tests/backends/OpenMP/CMakeLists.txt @@ -1,18 +1,14 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -## create OpenMP tests +# create OpenMP tests set(PLSSVM_OPENMP_TEST_NAME OpenMP_tests) # list all necessary sources -set(PLSSVM_OPENMP_TEST_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp - ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp - ${CMAKE_CURRENT_LIST_DIR}/openmp_csvm.cpp -) +set(PLSSVM_OPENMP_TEST_SOURCES ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp ${CMAKE_CURRENT_LIST_DIR}/openmp_csvm.cpp) # add test executable add_executable(${PLSSVM_OPENMP_TEST_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../main.cpp ${PLSSVM_OPENMP_TEST_SOURCES}) @@ -28,4 +24,4 @@ discover_tests_with_death_test_filter(${PLSSVM_OPENMP_TEST_NAME}) # add test as coverage dependency if (TARGET coverage) add_dependencies(coverage ${PLSSVM_OPENMP_TEST_NAME}) -endif () \ No newline at end of file +endif () diff --git a/tests/backends/SYCL/AdaptiveCpp/CMakeLists.txt b/tests/backends/SYCL/AdaptiveCpp/CMakeLists.txt index 8bd9da455..3f32feb92 100644 --- a/tests/backends/SYCL/AdaptiveCpp/CMakeLists.txt +++ b/tests/backends/SYCL/AdaptiveCpp/CMakeLists.txt @@ -1,10 +1,10 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -### create SYCL tests +# create SYCL tests set(PLSSVM_SYCL_ADAPTIVECPP_TEST_NAME SYCL_AdaptiveCpp_tests) # list all necessary sources @@ -14,10 +14,12 @@ set(PLSSVM_SYCL_ADAPTIVECPP_TEST_SOURCES ${CMAKE_CURRENT_LIST_DIR}/detail/pinned_memory.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp ${CMAKE_CURRENT_LIST_DIR}/adaptivecpp_csvm.cpp - ## since the SYCL implementation_type and kernel_invocation_type enumerations are used even if no SYCL backend - ## is available these are also tested in the base library + # ~~~ + # since the SYCL implementation_type and kernel_invocation_type enumerations are used even if no SYCL backend + # is available these are also tested in the base library # ${CMAKE_CURRENT_LIST_DIR}/../implementation_types.cpp # ${CMAKE_CURRENT_LIST_DIR}/../kernel_invocation_types.cpp + # ~~~ ) # add test executable @@ -38,4 +40,4 @@ discover_tests_with_death_test_filter(${PLSSVM_SYCL_ADAPTIVECPP_TEST_NAME}) # add test as coverage dependency if (TARGET coverage) add_dependencies(coverage ${PLSSVM_SYCL_ADAPTIVECPP_TEST_NAME}) -endif () \ No newline at end of file +endif () diff --git a/tests/backends/SYCL/CMakeLists.txt b/tests/backends/SYCL/CMakeLists.txt index c595fc61c..23770701c 100644 --- a/tests/backends/SYCL/CMakeLists.txt +++ b/tests/backends/SYCL/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## # create AdaptiveCpp tests if the SYCL implementation backend is available @@ -12,4 +12,4 @@ endif () # create DPC++ tests if the SYCL implementation backend is available if (TARGET ${PLSSVM_SYCL_BACKEND_DPCPP_LIBRARY_NAME}) add_subdirectory(DPCPP) -endif () \ No newline at end of file +endif () diff --git a/tests/backends/SYCL/DPCPP/CMakeLists.txt b/tests/backends/SYCL/DPCPP/CMakeLists.txt index 22c486040..bdfc317ad 100644 --- a/tests/backends/SYCL/DPCPP/CMakeLists.txt +++ b/tests/backends/SYCL/DPCPP/CMakeLists.txt @@ -1,10 +1,10 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -### create SYCL tests +# create SYCL tests set(PLSSVM_SYCL_DPCPP_TEST_NAME SYCL_DPCPP_tests) # list all necessary sources @@ -14,10 +14,12 @@ set(PLSSVM_SYCL_DPCPP_TEST_SOURCES ${CMAKE_CURRENT_LIST_DIR}/detail/pinned_memory.cpp ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp ${CMAKE_CURRENT_LIST_DIR}/dpcpp_csvm.cpp - ## since the SYCL implementation_type and kernel_invocation_type enumerations are used even if no SYCL backend - ## is available these are also tested in the base library + # ~~~ + # since the SYCL implementation_type and kernel_invocation_type enumerations are used even if no SYCL backend + # is available these are also tested in the base library # ${CMAKE_CURRENT_LIST_DIR}/../implementation_types.cpp # ${CMAKE_CURRENT_LIST_DIR}/../kernel_invocation_types.cpp + # ~~~ ) # add test executable @@ -38,4 +40,4 @@ discover_tests_with_death_test_filter(${PLSSVM_SYCL_DPCPP_TEST_NAME}) # add test as coverage dependency if (TARGET coverage) add_dependencies(coverage ${PLSSVM_SYCL_DPCPP_TEST_NAME}) -endif () \ No newline at end of file +endif () diff --git a/tests/backends/stdpar/CMakeLists.txt b/tests/backends/stdpar/CMakeLists.txt index d39d9a946..ad41ef59d 100644 --- a/tests/backends/stdpar/CMakeLists.txt +++ b/tests/backends/stdpar/CMakeLists.txt @@ -1,7 +1,7 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## # death tests are currently not supported for the stdpar implementations due to GoogleTest internal SegFaults @@ -11,20 +11,23 @@ endif () # performance tracker not supported with NVHPC if (PLSSVM_ENABLE_PERFORMANCE_TRACKING AND PLSSVM_STDPAR_BACKEND AND PLSSVM_STDPAR_BACKEND STREQUAL "NVHPC") - message(FATAL_ERROR "The (global) performance tracker is currently not supported with GTest and NVHPC. Please set \"PLSSVM_ENABLE_PERFORMANCE_TRACKING=OFF\" or use another stdpar implementation!") + message( + FATAL_ERROR + "The (global) performance tracker is currently not supported with GTest and NVHPC. Please set \"PLSSVM_ENABLE_PERFORMANCE_TRACKING=OFF\" or use another stdpar implementation!" + ) endif () -## create stdpar tests +# create stdpar tests set(PLSSVM_STDPAR_TEST_NAME stdpar_tests) # list all necessary sources set(PLSSVM_STDPAR_TEST_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp - ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp - ${CMAKE_CURRENT_LIST_DIR}/stdpar_csvm.cpp - ## since the stdpar implementation_type enumeration is used even if no stdpar backend - ## is available this is also tested in the base library + ${CMAKE_CURRENT_LIST_DIR}/detail/utility.cpp ${CMAKE_CURRENT_LIST_DIR}/exceptions.cpp ${CMAKE_CURRENT_LIST_DIR}/stdpar_csvm.cpp + # ~~~ + # since the stdpar implementation_type enumeration is used even if no stdpar backend + # is available this is also tested in the base library # ${CMAKE_CURRENT_LIST_DIR}/implementation_types.cpp + # ~~~ ) # add stdpar implementation specific test files containing tests for the stdpar::csvm constructors @@ -54,4 +57,4 @@ discover_tests_with_death_test_filter(${PLSSVM_STDPAR_TEST_NAME}) # add test as coverage dependency if (TARGET coverage) add_dependencies(coverage ${PLSSVM_STDPAR_TEST_NAME}) -endif () \ No newline at end of file +endif () diff --git a/tests/detail/tracking/CMakeLists.txt b/tests/detail/tracking/CMakeLists.txt index b2d6b909d..b6f23664a 100644 --- a/tests/detail/tracking/CMakeLists.txt +++ b/tests/detail/tracking/CMakeLists.txt @@ -1,17 +1,15 @@ -## Authors: Alexander Van Craen, Marcel Breyer -## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved -## License: This file is part of the PLSSVM project which is released under the MIT license. -## See the LICENSE.md file in the project root for full license information. +# Authors: Alexander Van Craen, Marcel Breyer +# Copyright (C): 2018-today The PLSSVM project - All Rights Reserved +# License: This file is part of the PLSSVM project which is released under the MIT license. +# See the LICENSE.md file in the project root for full license information. ######################################################################################################################## -## create specific hardware sampler tests +# create specific hardware sampler tests set(PLSSVM_PERFORMANCE_TRACKING_TEST_NAME performance_tracking_tests) # list all necessary sources -set(PLSSVM_PERFORMANCE_TRACKING_TEST_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/events.cpp - ${CMAKE_CURRENT_LIST_DIR}/performance_tracker.cpp - ${CMAKE_CURRENT_LIST_DIR}/utility.cpp +set(PLSSVM_PERFORMANCE_TRACKING_TEST_SOURCES ${CMAKE_CURRENT_LIST_DIR}/events.cpp ${CMAKE_CURRENT_LIST_DIR}/performance_tracker.cpp + ${CMAKE_CURRENT_LIST_DIR}/utility.cpp ) # add test executable @@ -29,6 +27,3 @@ discover_tests_with_death_test_filter(${PLSSVM_PERFORMANCE_TRACKING_TEST_NAME}) if (TARGET coverage) add_dependencies(coverage ${PLSSVM_PERFORMANCE_TRACKING_TEST_NAME}) endif () - - -