Skip to content

Commit 385b9b4

Browse files
authored
Merge pull request #70 from constracktor/hpx_start
Adding HPX backend (train,predict and tests) based on hpx::for_each and hpx::experimental::for_loop
2 parents 66c17a4 + c5c7dab commit 385b9b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2653
-53
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ IncludeBlocks: Regroup
7979
IncludeCategories:
8080
- Regex: '^"plssvm/'
8181
Priority: 1
82-
- Regex: '^"(cuda|hip|CL|sycl|omp)'
82+
- Regex: '^"(cuda|hip|CL|sycl|omp|hpx)'
8383
Priority: 2
8484
- Regex: '^"(tests|bindings)/'
8585
Priority: 3

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Authors: Alexander Van Craen, Marcel Breyer
1+
## Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack
22
## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved
33
## License: This file is part of the PLSSVM project which is released under the MIT license.
44
## See the LICENSE.md file in the project root for full license information.
@@ -376,6 +376,13 @@ if (PLSSVM_ENABLE_STDPAR_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_STDPAR_BACKEND)
376376
add_subdirectory(src/plssvm/backends/stdpar)
377377
endif ()
378378

379+
## check for HPX backend
380+
set(PLSSVM_ENABLE_HPX_BACKEND AUTO CACHE STRING "Enable HPX Backend")
381+
set_property(CACHE PLSSVM_ENABLE_HPX_BACKEND PROPERTY STRINGS AUTO ON OFF)
382+
if (PLSSVM_ENABLE_HPX_BACKEND MATCHES "AUTO" OR PLSSVM_ENABLE_HPX_BACKEND)
383+
add_subdirectory(src/plssvm/backends/HPX)
384+
endif ()
385+
379386
## check for CUDA backend
380387
set(PLSSVM_ENABLE_CUDA_BACKEND AUTO CACHE STRING "Enable CUDA Backend")
381388
set_property(CACHE PLSSVM_ENABLE_CUDA_BACKEND PROPERTY STRINGS AUTO ON OFF)
@@ -705,6 +712,10 @@ if (TARGET ${PLSSVM_STDPAR_BACKEND_LIBRARY_NAME})
705712
message(STATUS "${PLSSVM_STDPAR_BACKEND_SUMMARY_STRING}")
706713
list(APPEND PLSSVM_BACKEND_NAME_LIST "stdpar")
707714
endif ()
715+
if (TARGET ${PLSSVM_HPX_BACKEND_LIBRARY_NAME})
716+
message(STATUS "${PLSSVM_HPX_BACKEND_SUMMARY_STRING}")
717+
list(APPEND PLSSVM_BACKEND_NAME_LIST "hpx")
718+
endif ()
708719
if (TARGET ${PLSSVM_CUDA_BACKEND_LIBRARY_NAME})
709720
message(STATUS "${PLSSVM_CUDA_BACKEND_SUMMARY_STRING}")
710721
list(APPEND PLSSVM_BACKEND_NAME_LIST "cuda")
@@ -852,6 +863,7 @@ install(FILES
852863
"${PROJECT_BINARY_DIR}/plssvmHIPTargets.cmake"
853864
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmOpenCLTargets.cmake"
854865
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmOpenMPTargets.cmake"
866+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmHPXTargets.cmake"
855867
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmAdaptiveCppTargets.cmake"
856868
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmDPCPPTargets.cmake"
857869
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/plssvm/plssvmstdparTargets.cmake"

CMakePresets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"version": 6,
33
"include": [
44
"cmake/presets/openmp.json",
5+
"cmake/presets/hpx.json",
56
"cmake/presets/stdpar.json",
67
"cmake/presets/stdpar_gcc.json",
78
"cmake/presets/stdpar_nvhpc.json",
@@ -15,4 +16,4 @@
1516
"cmake/presets/dpcpp.json",
1617
"cmake/presets/all.json"
1718
]
18-
}
19+
}

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ The main highlights of our SVM implementations are:
5757
1. Drop-in replacement for LIBSVM's `svm-train`, `svm-predict`, and `svm-scale` (some features currently not implemented).
5858
2. Support of multiple different programming frameworks for parallelization (also called backends in our PLSSVM implementation) which allows us to target GPUs and CPUs from different vendors like NVIDIA, AMD, or Intel:
5959
- [OpenMP](https://www.openmp.org/)
60+
- [HPX](https://hpx.stellar-group.org/)
6061
- [stdpar](https://en.cppreference.com/w/cpp/algorithm) (supported implementations are [nvc++](https://developer.nvidia.com/hpc-sdk) from NVIDIA's HPC SDK, [roc-stdpar](https://github.com/ROCm/roc-stdpar) as a patched LLVM, [icpx](https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler.html) as Intel's oneAPI compiler, [AdaptiveCpp](https://github.com/AdaptiveCpp/AdaptiveCpp), and [GNU GCC](https://gcc.gnu.org/) using TBB). <br>
6162
**Note**: due to the nature of the used USM mechanics in the `stdpar` implementations, the `stdpar` backend **can't** be enabled together with **any** other backend! <br>
6263
**Note**: since every translation units need to be compiled with the same flag, we currently globally set `CMAKE_CXX_FLAGS` although it's discouraged in favor of `target_compile_options`.
@@ -105,6 +106,10 @@ Additional dependencies for the stdpar backend:
105106

106107
- compiler with stdpar support
107108

109+
Additional dependencies for the HPX backend:
110+
111+
- [HPX ≥ v1.9.0](https://hpx.stellar-group.org/)
112+
108113
Additional dependencies for the CUDA backend:
109114

110115
- CUDA SDK
@@ -355,6 +360,9 @@ Available configure presets:
355360
"openmp" - OpenMP backend
356361
"openmp_python" - OpenMP backend + Python bindings
357362
"openmp_test" - OpenMP backend tests
363+
"hpx" - HPX backend
364+
"hpx_python" - HPX backend + Python bindings
365+
"hpx_test" - HPX backend tests
358366
"cuda" - CUDA backend
359367
"cuda_python" - CUDA backend + Python bindings
360368
"cuda_test" - CUDA backend tests
@@ -545,7 +553,7 @@ Usage:
545553
-i, --max_iter arg set the maximum number of CG iterations (default: num_features)
546554
-l, --solver arg choose the solver: automatic|cg_explicit|cg_implicit (default: automatic)
547555
-a, --classification arg the classification strategy to use for multi-class classification: oaa|oao (default: oaa)
548-
-b, --backend arg choose the backend: automatic|openmp|cuda|hip|opencl|sycl|stdpar (default: automatic)
556+
-b, --backend arg choose the backend: automatic|openmp|hpx|cuda|hip|opencl|sycl|stdpar (default: automatic)
549557
-p, --target_platform arg choose the target platform: automatic|cpu|gpu_nvidia|gpu_amd|gpu_intel (default: automatic)
550558
--sycl_kernel_invocation_type arg
551559
choose the kernel invocation type when using SYCL as backend: automatic|nd_range (default: automatic)
@@ -589,13 +597,14 @@ The `--backend=automatic` option works as follows:
589597
- if the `gpu_nvidia` target is available, check for existing backends in order `cuda` 🠦 `hip` 🠦 `opencl` 🠦 `sycl` 🠦 `stdpar`
590598
- otherwise, if the `gpu_amd` target is available, check for existing backends in order `hip` 🠦 `opencl` 🠦 `sycl` 🠦 `stdpar`
591599
- otherwise, if the `gpu_intel` target is available, check for existing backends in order `sycl` 🠦 `opencl` 🠦 `stdpar`
592-
- otherwise, if the `cpu` target is available, check for existing backends in order `sycl` 🠦 `opencl` 🠦 `openmp` 🠦 `stdpar`
600+
- otherwise, if the `cpu` target is available, check for existing backends in order `sycl` 🠦 `opencl` 🠦 `openmp` 🠦 `hpx` 🠦 `stdpar`
593601

594602
Note that during CMake configuration it is guaranteed that at least one of the above combinations does exist.
595603

596604
The `--target_platform=automatic` option works for the different backends as follows:
597605

598606
- `OpenMP`: always selects a CPU
607+
- `HPX`: always selects a CPU
599608
- `CUDA`: always selects an NVIDIA GPU (if no NVIDIA GPU is available, throws an exception)
600609
- `HIP`: always selects an AMD GPU (if no AMD GPU is available, throws an exception)
601610
- `OpenCL`: tries to find available devices in the following order: NVIDIA GPUs 🠦 AMD GPUs 🠦 Intel GPUs 🠦 CPU

bindings/Python/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Authors: Alexander Van Craen, Marcel Breyer
1+
## Authors: Alexander Van Craen, Marcel Breyer, Alexander Strack
22
## Copyright (C): 2018-today The PLSSVM project - All Rights Reserved
33
## License: This file is part of the PLSSVM project which is released under the MIT license.
44
## See the LICENSE.md file in the project root for full license information.
@@ -68,6 +68,9 @@ endif ()
6868
if (TARGET ${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME})
6969
list(APPEND PLSSVM_PYTHON_BINDINGS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/backends/openmp_csvm.cpp)
7070
endif ()
71+
if (TARGET ${PLSSVM_HPX_BACKEND_LIBRARY_NAME})
72+
list(APPEND PLSSVM_PYTHON_BINDINGS_SOURCES ${CMAKE_CURRENT_LIST_DIR}/backends/hpx_csvm.cpp)
73+
endif ()
7174
if (TARGET ${PLSSVM_STDPAR_BACKEND_LIBRARY_NAME})
7275

7376
# AdaptiveCpp stdpar only support on the CPU when using our Python bindings
@@ -125,4 +128,4 @@ target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC $<$<COMPILE_LANG_AND_I
125128
target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC -fPIC)
126129

127130
# append pybind11 bindings library to installed targets
128-
append_local_and_parent(PLSSVM_TARGETS_TO_INSTALL ${PLSSVM_PYTHON_BINDINGS_LIBRARY_NAME})
131+
append_local_and_parent(PLSSVM_TARGETS_TO_INSTALL ${PLSSVM_PYTHON_BINDINGS_LIBRARY_NAME})

bindings/Python/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- [plssvm.Parameter](#plssvmparameter)
1111
- [plssvm.DataSet](#plssvmdataset)
1212
- [plssvm.CSVM](#plssvmcsvm)
13-
- [plssvm.openmp.CSVM, plssvm.stdpar.CSVM, plssvm.cuda.CSVM, plssvm.hip.CSVM, plssvm.opencl.CSVM, plssvm.sycl.CSVM, plssvm.dpcpp.CSVM, plssvm.adaptivecpp.CSVM](#plssvmopenmpcsvm-plssvmcudacsvm-plssvmhipcsvm-plssvmopenclcsvm-plssvmsyclcsvm-plssvmdpcppcsvm-plssvmadaptivecppcsvm)
13+
- [plssvm.openmp.CSVM, plssvm.hpx.CSVM, plssvm.stdpar.CSVM, plssvm.cuda.CSVM, plssvm.hip.CSVM, plssvm.opencl.CSVM, plssvm.sycl.CSVM, plssvm.dpcpp.CSVM, plssvm.adaptivecpp.CSVM](#plssvmopenmpcsvm-plssvmhpxcsvm-plssvmcudacsvm-plssvmhipcsvm-plssvmopenclcsvm-plssvmsyclcsvm-plssvmdpcppcsvm-plssvmadaptivecppcsvm)
1414
- [plssvm.Model](#plssvmmodel)
1515
- [plssvm.Version](#plssvmversion)
1616
- [plssvm.environment.ScopeGuard](#plssvmenvironmentscopeguard)
@@ -196,7 +196,7 @@ The following table lists all PLSSVM enumerations exposed on the Python side:
196196
| `FileFormatType` | `LIBSVM`, `ARFF` | The different supported file format types (default: `LIBSVM`). |
197197
| `GammaCoefficientType` | `AUTOMATIC`, `SCALE` | The different modes for the dynamic gamma calculation (default: `AUTOMATIC`). |
198198
| `ClassificationType` | `OAA`, `OAO` | The different supported multi-class classification strategies (default: `LIBSVM`). |
199-
| `BackendType` | `AUTOMATIC`, `OPENMP`, `CUDA`, `HIP`, `OPENCL`, `SYCL` | The different supported backends (default: `AUTOMATIC`). If `AUTOMATIC` is provided, the selected backend depends on the used target platform. |
199+
| `BackendType` | `AUTOMATIC`, `OPENMP`, `HPX`, `CUDA`, `HIP`, `OPENCL`, `SYCL` | The different supported backends (default: `AUTOMATIC`). If `AUTOMATIC` is provided, the selected backend depends on the used target platform. |
200200
| `VerbosityLevel` | `QUIET`, `LIBSVM`, `TIMING`, `FULL` | The different supported log levels (default: `FULL`). `QUIET` means no output, `LIBSVM` output that is as conformant as possible with LIBSVM's output, `TIMING` all timing related outputs, and `FULL` everything. Can be combined via bit-wise operations. |
201201
| `Status` | `UNINITIALIZED`, `INITIALIZED`, `FINALIZED`, `UNNECESSARY` | The different environment status values. **Note**: located in the `plssvm.environment` module. | |
202202

@@ -337,6 +337,10 @@ If the most performant backend should be used, it is sufficient to use `plssvm.C
337337
`sycl_implementation_type` to choose between DPC++ and AdaptiveCpp as SYCL implementations
338338
and `sycl_kernel_invocation_type` to choose between the two different SYCL kernel invocation types.
339339

340+
**Note**: if the backend type is `plssvm.BackendType.HPX` it is necessary to initialize and finalize the HPX runtime.
341+
The runtime can be manually managed using `plssvm.environment.initialize()` and `plssvm.environment.finalize()`.
342+
We recommend utilizing `plssvm.environment.ScopeGuard()` to manage the lifetime of the HPX runtime automatically.
343+
340344
| methods | description |
341345
|----------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
342346
| `set_params(params)` | Replace the current `plssvm.Parameter` with the provided one. |
@@ -349,7 +353,7 @@ and `sycl_kernel_invocation_type` to choose between the two different SYCL kerne
349353
| `score(model)` | Score the model with respect to itself returning its accuracy. |
350354
| `score(model, data_set)` | Score the model given the provided data set returning its accuracy. |
351355

352-
#### `plssvm.openmp.CSVM`, `plssvm.stdpar.CSVM`, plssvm.cuda.CSVM`, `plssvm.hip.CSVM`, `plssvm.opencl.CSVM`, `plssvm.sycl.CSVM`, `plssvm.dpcpp.CSVM`, `plssvm.adaptivecpp.CSVM`
356+
#### `plssvm.openmp.CSVM`, `plssvm.hpx.CSVM`, `plssvm.stdpar.CSVM`, plssvm.cuda.CSVM`, `plssvm.hip.CSVM`, `plssvm.opencl.CSVM`, `plssvm.sycl.CSVM`, `plssvm.dpcpp.CSVM`, `plssvm.adaptivecpp.CSVM`
353357

354358
These classes represent the backend specific CSVMs.
355359
**Note**: they are only available if the respective backend has been enabled during PLSSVM's build step.
@@ -560,4 +564,4 @@ The PLSSVM Python3 bindings define a few new exception types:
560564
| `ClassificationReportError` | If something in the classification report went wrong. **Note**: shouldn't occur in user code. |
561565
| `EnvironmentError` | If something during environment initialization or finalization went wrong. |
562566

563-
Depending on the available backends, additional `BackendError`s are also available (e.g., `plssvm.cuda.BackendError`).
567+
Depending on the available backends, additional `BackendError`s are also available (e.g., `plssvm.cuda.BackendError`).

bindings/Python/backend_types.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @author Alexander Van Craen
33
* @author Marcel Breyer
4+
* @author Alexander Strack
45
* @copyright 2018-today The PLSSVM project - All Rights Reserved
56
* @license This file is part of the PLSSVM project which is released under the MIT license.
67
* See the LICENSE.md file in the project root for full license information.
@@ -20,6 +21,7 @@ void init_backend_types(py::module_ &m) {
2021
py::enum_<plssvm::backend_type>(m, "BackendType")
2122
.value("AUTOMATIC", plssvm::backend_type::automatic, "the default backend; depends on the specified target platform")
2223
.value("OPENMP", plssvm::backend_type::openmp, "OpenMP to target CPUs only (currently no OpenMP target offloading support)")
24+
.value("HPX", plssvm::backend_type::hpx, "HPX to target CPUs only (currently no GPU executor support)")
2325
.value("STDPAR", plssvm::backend_type::stdpar, "C++ standard parallelism to target CPUs and GPUs from different vendors based on the used stdpar implementation; supported implementations are: nvhpc (nvc++), roc-stdpar, AdaptiveCpp, Intel LLVM (icpx), and GNU GCC + TBB")
2426
.value("CUDA", plssvm::backend_type::cuda, "CUDA to target NVIDIA GPUs only")
2527
.value("HIP", plssvm::backend_type::hip, "HIP to target AMD and NVIDIA GPUs")

0 commit comments

Comments
 (0)