Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/shared_memory' into 2D_tiling
Browse files Browse the repository at this point in the history
  • Loading branch information
breyerml committed Nov 20, 2023
2 parents e4f9f14 + 0c5f5cb commit caf75a0
Show file tree
Hide file tree
Showing 303 changed files with 22,588 additions and 11,724 deletions.
47 changes: 47 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated from CLion Inspection settings
---
Checks: '-*,
cert-*,
misc-*,
mpi-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
google-default-arguments,
google-runtime-operator,
google-explicit-constructor,
hicpp-multiway-paths-covered,
hicpp-exception-baseclass,
modernize-*,
-modernize-use-trailing-return-type,
-modernize-avoid-c-arrays,
-modernize-use-using,
-modernize-use-default-member-init,
-modernize-macro-to-enum,
portability-simd-intrinsics,
readability-*,
-readability-redundant-preprocessor,
-readability-named-parameter,
-readability-function-size,
-readability-simplify-boolean-expr,
-readability-identifier-length,
-readability-duplicate-include,
-readability-magic-numbers,
-readability-braces-around-statements,
-readability-redundant-member-init,
-readability-suspicious-call-argument,
-readability-qualified-auto,
-readability-isolate-declaration,
-readability-uppercase-literal-suffix,
-readability-container-data-pointer,
-readability-else-after-return,
-readability-redundant-access-specifiers,
-readability-function-cognitive-complexity,
-readability-implicit-bool-conversion,
-readability-container-contains,
-readability-identifier-naming,
bugprone-*'

CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: true
28 changes: 15 additions & 13 deletions .github/workflows/msvc_windows.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
name: Windows CPU
name: Windows MSVC CPU
on: push
jobs:
MSVC-Test:
runs-on: windows-latest
steps:
- name: "Install MSVC 14.29"
uses: ilammy/[email protected]
with:
toolset: 14.29
- name: "Install cmake 3.22.2"
uses: lukka/[email protected]
- name: "Clone Step"
- name: "Install latest MSVC compiler"
uses: ilammy/[email protected]
- name: "Install cmake 3.25.2"
uses: lukka/[email protected]
- name: "Clone the PLSSVM repository into PLSSVM/"
uses: actions/checkout@v2
with:
path: PLSSVM
- name: "CMake Step"
- name: "Install Python dependencies"
uses: py-actions/py-dependency-install@v4
with:
path: "PLSSVM/.github/workflows/requirements.txt"
- name: "Configure PLSSVM using CMake"
run: |
mkdir PLSSVM/build
cd PLSSVM/build
cmake -DCMAKE_BUILD_TYPE=Debug -DPLSSVM_TARGET_PLATFORMS="cpu" -DPLSSVM_ENABLE_TESTING=ON -DPLSSVM_GENERATE_TEST_FILE=OFF -DPLSSVM_ENABLE_LTO=OFF -DPLSSVM_ENABLE_ASSERTS=ON ..
- name: "Build Step"
cmake -DCMAKE_BUILD_TYPE=Release -DPLSSVM_TARGET_PLATFORMS="cpu" -DPLSSVM_ENABLE_TESTING=ON -DPLSSVM_TEST_FILE_NUM_DATA_POINTS=50 -DPLSSVM_TEST_FILE_NUM_FEATURES=20 -DPLSSVM_ENABLE_LTO=OFF -DPLSSVM_ENABLE_ASSERTS=ON ..
- name: "Build PLSSVM"
run: |
cd PLSSVM/build
cmake --build .
- name: "Test Step"
- name: "Run tests"
run: |
cd PLSSVM/build
ctest --output-on-failure -C Debug
ctest -j 2 -E ".*Exceptions\.|SourceLocation" --output-on-failure -C Release
5 changes: 5 additions & 0 deletions .github/workflows/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### required python packages for the Windows MSVC tests
argparse
scikit-learn
numpy
humanize
51 changes: 33 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,28 @@ target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC
)

## set library cxx standard
if ($ENV{CLION_IDE})
# somehow necessary for CLion to detect the C++ standard as 17
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
$<$<COMPILE_LANGUAGE:CXX>:$<$<CXX_COMPILER_ID:GNU,Clang>:-Wall -Wextra -Wdouble-promotion -fno-common -Wshadow -Wcast-qual
-Wnull-dereference -Wctor-dtor-privacy -Wnon-virtual-dtor -Wextra-semi -Wunreachable-code -Wuninitialized
-Wnull-dereference -Wctor-dtor-privacy -Wnon-virtual-dtor -Wextra-semi -Wunreachable-code -Wuninitialized -Wno-ctor-dtor-privacy
-fPIC>
$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wsuggest-override -Wstrict-null-sentinel -Wlogical-op -Wduplicated-branches -Wimplicit-fallthrough=5>
$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-Wdocumentation -Wmost>
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/W4 /bigobj /wd4459>>
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/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
$<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Werror=switch -fstrict-enums>
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/we4062 /wd4005>
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/we4062 /wd4005 /wd4702 /wd4849 /wd4127>
# /wd4702: prevent warning for unreachable code in tests (the tests that currently skip the cg_streaming and cg_implicit tests)
# /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 additional optimization flags only in RELEASE mode
target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC
Expand All @@ -110,13 +117,14 @@ target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:NOMINMAX>
)

## enable standard library debug modes if compiled in debug
if (CMAKE_BUILD_TYPE MATCHES Debug)
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.")
# GCC standard library (libstdc++): _GLIBCXX_DEBUG
# LLVM standard library (libc++): LIBCXX_ENABLE_DEBUG_MODE
# MSVC standard library: _ITERATOR_DEBUG_LEVEL
target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC _GLIBCXX_DEBUG LIBCXX_ENABLE_DEBUG_MODE _ITERATOR_DEBUG_LEVEL)
target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC ${PLSSVM_STL_DEBUG_MODE_FLAGS})
endif ()


Expand Down Expand Up @@ -233,23 +241,27 @@ else ()
endif ()

## try finding fmt
find_package(fmt 10.0.0 QUIET)
find_package(fmt 10.1.1 QUIET)
if (fmt_FOUND)
message(STATUS "Found package fmt.")
else ()
message(STATUS "Couldn't find package fmt. Building from source ...")
set(PLSSVM_fmt_VERSION 10.0.0)
message(STATUS "Couldn't find package fmt. Building from source ...") # TODO: change to next release; bug fix commit
set(PLSSVM_fmt_VERSION d9063baf227882da0f48c761abcbb08247eb1296)
if (PLSSVM_ENABLE_STL_DEBUG_MODE)
set(CMAKE_CXX_FLAGS_OLD "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLSSVM_STL_DEBUG_MODE_FLAGS}")
endif ()
# fetch string formatting library fmt
FetchContent_Declare(fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG ${PLSSVM_fmt_VERSION}
GIT_SHALLOW TRUE
# GIT_SHALLOW TRUE
QUIET

set (FMT_TEST OFF CACHE BOOL "" FORCE)
set (FMT_DOC OFF CACHE BOOL "" FORCE)
set (FMT_INSTALL OFF CACHE BOOL "" FORCE)
set (FMT_SYSTEM_HEADERS ON CACHE BOOL "" FORCE)
# set (FMT_TEST OFF CACHE BOOL "" FORCE)
# set (FMT_DOC OFF CACHE BOOL "" FORCE)
# set (FMT_INSTALL OFF CACHE BOOL "" FORCE)
# set (FMT_SYSTEM_HEADERS ON CACHE BOOL "" FORCE)
)
FetchContent_MakeAvailable(fmt)
set_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON)
Expand All @@ -261,6 +273,9 @@ else ()
# append fmt to installed targets if build from source
list(APPEND PLSSVM_TARGETS_TO_INSTALL "fmt")
message(STATUS "Installing {fmt} version ${PLSSVM_fmt_VERSION}.")
if (PLSSVM_ENABLE_STL_DEBUG_MODE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_OLD}")
endif ()
endif ()
target_link_libraries(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC fmt::fmt)

Expand Down Expand Up @@ -688,7 +703,7 @@ choose the SYCL implementation to be used in the SYCL backend: ${PLSSVM_SYCL_BAC
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|hierarchical (default: automatic)
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}")
Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ General dependencies:

- a C++17 capable compiler (e.g. [`gcc`](https://gcc.gnu.org/) or [`clang`](https://clang.llvm.org/))
- [CMake](https://cmake.org/) 3.21 or newer
- [cxxopts ≥ v3.0.0](https://github.com/jarro2783/cxxopts), [fast_float](https://github.com/fastfloat/fast_float), [{fmt} ≥ v8.1.1](https://github.com/fmtlib/fmt), and [igor](https://github.com/bluescarni/igor) (all four are automatically build during the CMake configuration if they couldn't be found using the respective `find_package` call)
- [cxxopts ≥ v3.1.1](https://github.com/jarro2783/cxxopts), [fast_float ≥ v3.10.0](https://github.com/fastfloat/fast_float), [{fmt} ≥ v10.1.1](https://github.com/fmtlib/fmt), and [igor](https://github.com/bluescarni/igor) (all four are automatically build during the CMake configuration if they couldn't be found using the respective `find_package` call)
- [GoogleTest ≥ v1.11.0](https://github.com/google/googletest) if testing is enabled (automatically build during the CMake configuration if `find_package(GTest)` wasn't successful)
- [doxygen](https://www.doxygen.nl/index.html) if documentation generation is enabled
- [Pybind11 ≥ v2.10.3](https://github.com/pybind/pybind11) if Python bindings are enabled
- [Pybind11 ≥ v2.11.1](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)
- multiple Python modules used in the utility scripts, to install all modules use `pip install --user -r install/python_requirements.txt`

Expand Down Expand Up @@ -88,6 +88,12 @@ Additional dependencies if `PLSSVM_ENABLE_TESTING` and `PLSSVM_GENERATE_TEST_FIL

### Building

Download and install all *necessary* Python3 dependencies:

```bash
pip install -r install/python_requirements.txt
```

Building the library can be done using the normal CMake approach:

```bash
Expand Down Expand Up @@ -198,6 +204,7 @@ The `[optional_options]` can be one or multiple of:
- `PLSSVM_ENABLE_PERFORMANCE_TRACKING`: enable gathering performance characteristics for the three executables using YAML files; example Python3 scripts to perform performance measurements and to process the resulting YAML files can be found in the `utility_scripts/` directory (requires the Python3 modules [wrapt-timeout-decorator](https://pypi.org/project/wrapt-timeout-decorator/), [`pyyaml`](https://pyyaml.org/), and [`pint`](https://pint.readthedocs.io/en/stable/))
- `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 ABI!)

If `PLSSVM_ENABLE_TESTING` is set to `ON`, the following options can also be set:

Expand Down Expand Up @@ -229,9 +236,9 @@ To use DPC++ for SYCL simply set the `CMAKE_CXX_COMPILER` to the respective DPC+

If the SYCL implementation is DPC++ the following additional options are available:

- `PLSSVM_SYCL_BACKEND_DPCPP_USE_LEVEL_ZERO` (default: `ON`): use DPC++'s Level-Zero backend instead of its OpenCL backend
- `PLSSVM_SYCL_BACKEND_DPCPP_GPU_AMD_USE_HIP` (default: `ON`): use DPC++'s HIP backend instead of its OpenCL backend for AMD GPUs
- `PLSSVM_SYCL_BACKEND_DPCPP_ENABLE_AOT` (default: `ON`): enable Ahead-of-Time (AOT) compilation for the specified target platforms
- `PLSSVM_SYCL_BACKEND_DPCPP_USE_LEVEL_ZERO` (default: `ON`): use DPC++'s Level-Zero backend instead of its OpenCL backend **(only available if a CPU or Intel GPU is targeted)**
- `PLSSVM_SYCL_BACKEND_DPCPP_GPU_AMD_USE_HIP` (default: `ON`): use DPC++'s HIP backend instead of its OpenCL backend for AMD GPUs **(only available if an AMD GPU is targeted)**

If the SYCL implementation is hipSYCL the following additional option is available:

Expand Down Expand Up @@ -345,12 +352,12 @@ Usage:
-c, --cost arg set the parameter C (default: 1)
-e, --epsilon arg set the tolerance of termination criterion (default: 0.001)
-i, --max_iter arg set the maximum number of CG iterations (default: num_features)
-s, --solver arg choose the solver: automatic|cg_explicit|cg_streaming|cg_implicit (default: automatic)
-l, --solver arg choose the solver: automatic|cg_explicit|cg_streaming|cg_implicit (default: automatic)
-a, --classification arg the classification strategy to use for multi-class classification: oaa|oao (default: oaa)
-b, --backend arg choose the backend: automatic|openmp|cuda|hip|opencl|sycl (default: automatic)
-p, --target_platform arg choose the target platform: automatic|cpu|gpu_nvidia|gpu_amd|gpu_intel (default: automatic)
--sycl_kernel_invocation_type arg
choose the kernel invocation type when using SYCL as backend: automatic|nd_range|hierarchical (default: automatic)
choose the kernel invocation type when using SYCL as backend: automatic|nd_range (default: automatic)
--sycl_implementation_type arg
choose the SYCL implementation to be used in the SYCL backend: automatic|dpcpp|hipsycl (default: automatic)
--performance_tracking arg
Expand Down Expand Up @@ -404,7 +411,7 @@ The `--target_platform=automatic` option works for the different backends as fol
- `SYCL`: tries to find available devices in the following order: NVIDIA GPUs 🠦 AMD GPUs 🠦 Intel GPUs 🠦 CPU
The `--sycl_kernel_invocation_type` and `--sycl_implementation_type` flags are only used if the `--backend` is `sycl`, otherwise a warning is emitted on `stderr`.
If the `--sycl_kernel_invocation_type` is `automatic`, the `nd_range` invocation type is always used, except for hipSYCL on CPUs where the hierarchical formulation is used instead (if hipSYCL wasn't build with `omp.accelerated`).
If the `--sycl_kernel_invocation_type` is `automatic`, the `nd_range` invocation type is currently always used.
If the `--sycl_implementation_type` is `automatic`, the used SYCL implementation is determined by the `PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION` cmake flag.
### Predicting
Expand Down
8 changes: 4 additions & 4 deletions bindings/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ if (pybind11_FOUND)
message(STATUS "Found package pybind11.")
else ()
message(STATUS "Couldn't find package pybind11. Building from source ...")
set(PLSSVM_pybind11_VERSION v2.10.3)
set(PLSSVM_pybind11_VERSION v2.11.1)
# 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_MakeAvailable(pybind11)
target_include_directories(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC
$<BUILD_INTERFACE:${pybind11_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
)
message(STATUS "Installed pybind11 version ${PLSSVM_pybind11_VERSION}.")
endif ()

Expand All @@ -53,7 +53,7 @@ set(PLSSVM_PYTHON_BINDINGS_SOURCES
${CMAKE_CURRENT_LIST_DIR}/sklearn.cpp

${CMAKE_CURRENT_LIST_DIR}/main.cpp
)
)
# set backends specific source files if the respective backend is used
if (TARGET ${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME})
list(APPEND PLSSVM_PYTHON_BINDINGS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/backends/openmp_csvm.cpp)
Expand Down
Loading

0 comments on commit caf75a0

Please sign in to comment.