{"id":13574253,"url":"https://github.com/SC-SGS/PLSSVM","last_synced_at":"2025-04-04T14:32:09.421Z","repository":{"id":37809890,"uuid":"413283627","full_name":"SC-SGS/PLSSVM","owner":"SC-SGS","description":"Implementation of a parallel least squares support vector machine using multiple backends for different GPU vendors.","archived":false,"fork":false,"pushed_at":"2024-10-29T08:58:17.000Z","size":49201,"stargazers_count":34,"open_issues_count":1,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T10:03:26.416Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SC-SGS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-04T05:18:43.000Z","updated_at":"2024-10-26T18:32:34.000Z","dependencies_parsed_at":"2023-10-14T00:19:57.335Z","dependency_job_id":"4dff26ac-7532-4f7f-b5be-e154bc7cdf4c","html_url":"https://github.com/SC-SGS/PLSSVM","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SC-SGS%2FPLSSVM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SC-SGS%2FPLSSVM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SC-SGS%2FPLSSVM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SC-SGS%2FPLSSVM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SC-SGS","download_url":"https://codeload.github.com/SC-SGS/PLSSVM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247194226,"owners_count":20899448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:00:48.893Z","updated_at":"2025-04-04T14:32:04.410Z","avatar_url":"https://github.com/SC-SGS.png","language":"C++","funding_links":[],"categories":["Table of Contents"],"sub_categories":["AI - Machine Learning"],"readme":"![![PLSSVM](../resources/logo_245x150.png)](docs/resources/logo_245x150.png)\n\n# PLSSVM - Parallel Least Squares Support Vector Machine\n\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/e780a63075ce40c29c49d3df4f57c2af)](https://www.codacy.com/gh/SC-SGS/PLSSVM/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=SC-SGS/PLSSVM\u0026amp;utm_campaign=Badge_Grade) \u0026ensp; [![Generate documentation](https://github.com/SC-SGS/PLSSVM/actions/workflows/documentation.yml/badge.svg)](https://sc-sgs.github.io/PLSSVM/) \n\nA [Support Vector Machine (SVM)](https://en.wikipedia.org/wiki/Support-vector_machine) is a supervised machine learning model.\nIn its basic form SVMs are used for binary classification tasks.\nTheir fundamental idea is to learn a hyperplane which separates the two classes best, i.e., where the widest possible margin around its decision boundary is free of data.\nThis is also the reason, why SVMs are also called \"large margin classifiers\".\nTo predict to which class a new, unseen data point belongs, the SVM simply has to calculate on which side of the previously calculated hyperplane the data point lies.\nThis is very efficient since it only involves a single scalar product of the size corresponding to the numer of features of the data set.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"strong scaling CPU\" src=\".figures/support_vector_machine.png\" width=\"50%\"\u003e\n\u003c/p\u003e\n\nHowever, normal SVMs suffer in their potential parallelizability.\nDetermining the hyperplane boils down to solving a convex quadratic problem.\nFor this, most SVM implementations use Sequential Minimal Optimization (SMO), an inherently sequential algorithm.\nThe basic idea of this algorithm is that it takes a pair of data points and calculates the hyperplane between them.\nAfterward, two new data points are selected and the existing hyperplane is adjusted accordingly.\nThis procedure is repeat until a new adjustment would be smaller than some epsilon greater than zero.\n\nSome SVM implementations try to harness some parallelization potential by not drawing point pairs but group of points.\nIn this case, the hyperplane calculation inside this group is parallelized.\nHowever, even then modern highly parallel hardware can not be utilized efficiently.\n\nTherefore, we implemented a version of the original proposed SVM called [Least Squares Support Vector Machine (LS-SVM)](https://en.wikipedia.org/wiki/Least-squares_support-vector_machine).\nThe LS-SVMs reformulated the original problem such that it boils down to solving a system of linear equations.\nFor this kind of problem many highly parallel algorithms and implementations are known.\nWe decided to use the [Conjugate Gradient (CG)](https://en.wikipedia.org/wiki/Conjugate_gradient_method) to solve the system of linear equations.\n\nSince one of our main goals was performance, we parallelized the implicit matrix-vector multiplication inside the CG algorithm.\nTo do so, we use multiple different frameworks to be able to target a broad variety of different hardware platforms.\nThe currently available frameworks (also called backends in our PLSSVM implementation) are:\n\n- [OpenMP](https://www.openmp.org/)\n- [CUDA](https://developer.nvidia.com/cuda-zone)\n- [HIP](https://github.com/ROCm-Developer-Tools/HIP) (only tested on AMD GPUs)\n- [OpenCL](https://www.khronos.org/opencl/)\n- [SYCL](https://www.khronos.org/sycl/) (tested implementations are [DPC++](https://github.com/intel/llvm) and [hipSYCL](https://github.com/illuhad/hipSYCL); specifically the versions [sycl-nightly/20230110](https://github.com/intel/llvm/tree/sycl-nightly/20230110) and hipSYCL commit [eb67fc4](https://github.com/illuhad/hipSYCL/commit/eb67fc46d6732b5c4f137ce5564f6adfba57eaa1))\n\n## Getting Started\n\n### Dependencies\n\nGeneral dependencies:\n\n- a C++17 capable compiler (e.g. [`gcc`](https://gcc.gnu.org/) or [`clang`](https://clang.llvm.org/))\n- [CMake](https://cmake.org/) 3.21 or newer\n- [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)\n- [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)\n- [doxygen](https://www.doxygen.nl/index.html) if documentation generation is enabled\n- [Pybind11 ≥ v2.10.3](https://github.com/pybind/pybind11) if Python bindings are enabled\n- [OpenMP](https://www.openmp.org/) 4.0 or newer (optional) to speed-up library utilities (like file parsing)\n- multiple Python modules used in the utility scripts, to install all modules use `pip install --user -r install/python_requirements.txt`\n\nAdditional dependencies for the OpenMP backend:\n\n- compiler with OpenMP support\n\nAdditional dependencies for the CUDA backend:\n\n- CUDA SDK\n- either NVIDIA [`nvcc`](https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html) or [`clang` with CUDA support enabled](https://llvm.org/docs/CompileCudaWithLLVM.html)\n\nAdditional dependencies for the HIP backend:\n\n- working ROCm and HIP installation\n- [clang with HIP support](https://rocmdocs.amd.com/en/latest/Programming_Guides/HIP-FAQ.html)\n\nAdditional dependencies for the OpenCL backend:\n\n- OpenCL runtime and header files\n\nAdditional dependencies for the SYCL backend:\n\n- the code must be compiled with a SYCL capable compiler; currently tested with [DPC++](https://github.com/intel/llvm) and [hipSYCL](https://github.com/illuhad/hipSYCL)\n\nAdditional dependencies if `PLSSVM_ENABLE_TESTING` and `PLSSVM_GENERATE_TEST_FILE` are both set to `ON`:\n\n- [Python3](https://www.python.org/) with the [`argparse`](https://docs.python.org/3/library/argparse.html), [`timeit`](https://docs.python.org/3/library/timeit.html), [`sklearn`](https://scikit-learn.org/stable/), and [`humanize`](https://pypi.org/project/humanize/) modules\n\n### Building\n\nBuilding the library can be done using the normal CMake approach:\n\n```bash\ngit clone https://github.com/SC-SGS/PLSSVM.git\ncd PLSSVM \nmkdir build \u0026\u0026 cd build \ncmake -DPLSSVM_TARGET_PLATFORMS=\"...\" [optional_options] .. \ncmake --build . -j\n```\n\n#### Target Platform Selection\n\nThe CMake option `PLSSVM_TARGET_PLATFORMS` is used to determine for which targets the backends should be compiled.\nValid targets are:\n\n- `cpu`: compile for the CPU; an **optional** architectural specifications is allowed but only used when compiling with DPC++, e.g., `cpu:avx2`\n- `nvidia`: compile for NVIDIA GPUs; **at least one** architectural specification is necessary, e.g., `nvidia:sm_86,sm_70`\n- `amd`: compile for AMD GPUs; **at least one** architectural specification is necessary, e.g., `amd:gfx906`\n- `intel`: compile for Intel GPUs; **at least one** architectural specification is necessary, e.g., `intel:skl`\n\nAt least one of the above targets must be present. If the option `PLSSVM_TARGET_PLATFORMS` is not present, the targets \nare automatically determined using the Python3 `utility_scripts/plssvm_target_platforms.py` script (required Python3 dependencies:\n[`argparse`](https://docs.python.org/3/library/argparse.html), [`py-cpuinfo`](https://pypi.org/project/py-cpuinfo/),\n[`GPUtil`](https://pypi.org/project/GPUtil/), [`pyamdgpuinfo`](https://pypi.org/project/pyamdgpuinfo/), and\n[`pylspci`](https://pypi.org/project/pylspci/)).\n\nNote that when using DPC++ only a single architectural specification for `cpu`, `nvidia` or `amd` is allowed.\n\n\n```bash\npython3 utility_scripts/plssvm_target_platforms.py --help\nusage: plssvm_target_platforms.py [-h] [--quiet]\n\noptional arguments:\n  -h, --help  show this help message and exit\n  --quiet     only output the final PLSSVM_TARGET_PLATFORMS string\n```\n\nExample invocation:\n\n```bash\npython3 utility_scripts/plssvm_target_platforms.py\nIntel(R) Core(TM) i9-10980XE CPU @ 3.00GHz: {'avx512': True, 'avx2': True, 'avx': True, 'sse4_2': True}\n\nFound 1 NVIDIA GPU(s):\n  1x NVIDIA GeForce RTX 3080: sm_86\n\nPossible -DPLSSVM_TARGET_PLATFORMS entries:\ncpu:avx512;nvidia:sm_86\n```\n\n\nor with the `--quiet` flag given:\n\n\n```bash\npython3 utility_scripts/plssvm_target_platforms.py --quiet\ncpu:avx512;intel:dg1\n```\n\nIf the architectural information for the requested GPU could not be retrieved, one option would be to have a look at:\n\n- for NVIDIA GPUs:  [Your GPU Compute Capability](https://developer.nvidia.com/cuda-gpus)\n- for AMD GPUs: [clang AMDGPU backend usage](https://llvm.org/docs/AMDGPUUsage.html)\n- for Intel GPUs and CPUs: [Ahead of Time Compilation](https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compilation/ahead-of-time-compilation.html) and [Intel graphics processor table](https://dgpu-docs.intel.com/devices/hardware-table.html)\n\n\n#### Optional CMake Options\n\nThe `[optional_options]` can be one or multiple of:\n\n- `PLSSVM_ENABLE_OPENMP_BACKEND=ON|OFF|AUTO` (default: `AUTO`):\n  - `ON`: check for the OpenMP backend and fail if not available\n  - `AUTO`: check for the OpenMP backend but **do not** fail if not available\n  - `OFF`: do not check for the OpenMP backend\n\n- `PLSSVM_ENABLE_CUDA_BACKEND=ON|OFF|AUTO` (default: `AUTO`):\n  - `ON`: check for the CUDA backend and fail if not available\n  - `AUTO`: check for the CUDA backend but **do not** fail if not available\n  - `OFF`: do not check for the CUDA backend\n\n- `PLSSVM_ENABLE_HIP_BACKEND=ON|OFF|AUTO` (default: `AUTO`):\n  - `ON`: check for the HIP backend and fail if not available\n  - `AUTO`: check for the HIP backend but **do not** fail if not available\n  - `OFF`: do not check for the HIP backend\n\n- `PLSSVM_ENABLE_OPENCL_BACKEND=ON|OFF|AUTO` (default: `AUTO`):\n  - `ON`: check for the OpenCL backend and fail if not available\n  - `AUTO`: check for the OpenCL backend but **do not** fail if not available\n  - `OFF`: do not check for the OpenCL backend\n\n- `PLSSVM_ENABLE_SYCL_BACKEND=ON|OFF|AUTO` (default: `AUTO`):\n  - `ON`: check for the SYCL backend and fail if not available\n  - `AUTO`: check for the SYCL backend but **do not** fail if not available\n  - `OFF`: do not check for the SYCL backend\n\n**Attention:** at least one backend must be enabled and available!\n\n- `PLSSVM_ENABLE_ASSERTS=ON|OFF` (default: `OFF`): enables custom assertions regardless whether the `DEBUG` macro is defined or not\n- `PLSSVM_THREAD_BLOCK_SIZE` (default: `16`): set a specific thread block size used in the GPU kernels (for fine-tuning optimizations)\n- `PLSSVM_INTERNAL_BLOCK_SIZE` (default: `6`: set a specific internal block size used in the GPU kernels (for fine-tuning optimizations)\n- `PLSSVM_OPENMP_BLOCK_SIZE` (default: `64`): set a specific block size used in the OpenMP kernels\n- `PLSSVM_ENABLE_LTO=ON|OFF` (default: `ON`): enable interprocedural optimization (IPO/LTO) if supported by the compiler\n- `PLSSVM_ENABLE_DOCUMENTATION=ON|OFF` (default: `OFF`): enable the `doc` target using doxygen\n- `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/))\n- `PLSSVM_ENABLE_TESTING=ON|OFF` (default: `ON`): enable testing using GoogleTest and ctest\n- `PLSSVM_ENABLE_LANGUAGE_BINDINGS=ON|OFF` (default: `OFF`): enable language bindings\n\nIf `PLSSVM_ENABLE_TESTING` is set to `ON`, the following options can also be set:\n\n- `PLSSVM_GENERATE_TEST_FILE=ON|OFF` (default: `ON`): automatically generate test files\n  - `PLSSVM_TEST_FILE_NUM_DATA_POINTS` (default: `5000`): the number of data points in the test file\n  - `PLSSVM_TEST_FILE_NUM_FEATURES` (default: `2000`): the number of features per data point in the test file\n\nIf `PLSSVM_ENABLE_LANGUAGE_BINDINGS` is set to `ON`, the following option can also be set:\n\n- `PLSSVM_ENABLE_PYTHON_BINDINGS=ON|OFF` (default: `PLSSVM_ENABLE_LANGUAGE_BINDINGS`): enable Python bindings using Pybind11\n\nIf `PLSSVM_ENABLE_PYTHON_BINDINGS` is set to `ON`, the following options can also be set:\n\n- `PLSSVM_PYTHON_BINDINGS_PREFERRED_REAL_TYPE` (default: `double`): the default `real_type` used if the generic `plssvm.Model` and `plssvm.DataSet` Python classes are used\n- `PLSSVM_PYTHON_BINDINGS_PREFERRED_LABEL_TYPE` (default: `std::string`): the default `label_type` used if the generic `plssvm.Model` and `plssvm.DataSet` Python classes are used\n\nIf the SYCL backend is available additional options can be set.\n\n- `PLSSVM_ENABLE_SYCL_HIPSYCL_BACKEND=ON|OFF|AUTO` (default: `AUTO`):\n  - `ON`: check for hipSYCL as implementation for the SYCL backend and fail if not available\n  - `AUTO`: check for hipSYCL as implementation for the SYCL backend but **do not** fail if not available\n  - `OFF`: do not check for hipSYCL as implementation for the SYCL backend\n\n- `PLSSVM_ENABLE_SYCL_DPCPP_BACKEND=ON|OFF|AUTO` (default: `AUTO`):\n  - `ON`: check for DPC++ as implementation for the SYCL backend and fail if not available\n  - `AUTO`: check for DPC++ as implementation for the SYCL backend but **do not** fail if not available\n  - `OFF`: do not check for DPC++ as implementation for the SYCL backend\n\nTo use DPC++ for SYCL simply set the `CMAKE_CXX_COMPILER` to the respective DPC++ clang executable during CMake invocation.\n\nIf the SYCL implementation is DPC++ the following additional options are available:\n\n- `PLSSVM_SYCL_BACKEND_DPCPP_USE_LEVEL_ZERO` (default: `OFF`): use DPC++'s Level-Zero backend instead of its OpenCL backend\n- `PLSSVM_SYCL_BACKEND_DPCPP_GPU_AMD_USE_HIP` (default: `ON`): use DPC++'s HIP backend instead of its OpenCL backend for AMD GPUs\n- `PLSSVM_SYCL_BACKEND_DPCPP_ENABLE_AOT` (default: `ON`): enable Ahead-of-Time (AOT) compilation for the specified target platforms\n\nIf more than one SYCL implementation is available the environment variables `PLSSVM_SYCL_HIPSYCL_INCLUDE_DIR` and `PLSSVM_SYCL_DPCPP_INCLUDE_DIR`\n**must** be set to the respective SYCL include paths. Note that those paths **must not** be present in the `CPLUS_INCLUDE_PATH` environment variable or compilation will fail.\n\n- `PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION` (`dpcpp`|`hipsycl`): specify the preferred SYCL implementation if the `sycl_implementation_type` option is set to `automatic`; additional the specified SYCL implementation is used in the `plssvm::sycl` namespace, the other implementations are available in the `plssvm::dpcpp` and `plssvm::hipsycl` namespace respectively\n\n### Running the tests\n\nTo run the tests after building the library (with `PLSSVM_ENABLE_TESTING` set to `ON`) use:\n\n```bash\nctest\n```\n\n### Generating test coverage results\n\nTo enable the generation of test coverage reports using `locv` the library must be compiled using the custom `Coverage` `CMAKE_BUILD_TYPE`.\nAdditionally, it's advisable to use smaller test files to shorten the `ctest` step.\n\n```bash\ncmake -DCMAKE_BUILD_TYPE=Coverage -DPLSSVM_TARGET_PLATFORMS=\"...\" \\\n      -DPLSSVM_TEST_FILE_NUM_DATA_POINTS=100 \\\n      -DPLSSVM_TEST_FILE_NUM_FEATURES=50 ..\ncmake --build . -- coverage\n```\n\nThe resulting `html` coverage report is located in the `coverage` folder in the build directory.\n\n### Creating the documentation\n\nIf doxygen is installed and `PLSSVM_ENABLE_DOCUMENTATION` is set to `ON` the documentation can be build using\n\n```bash\ncmake --build . -- doc\n```\n\nThe documentation of the current state of the main branch can be found [here](https://sc-sgs.github.io/PLSSVM/).\n\n## Installing\n\nThe library supports the `install` target:\n\n```bash\ncmake --build . -- install\n```\n\nAfterward, the necessary exports should be performed:\n\n```bash\nexport CMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}/share/plssvm/cmake:${CMAKE_PREFIX_PATH}\nexport MANPATH=${CMAKE_INSTALL_PREFIX}/share/man:$MANPATH\n\nexport PATH=${CMAKE_INSTALL_PREFIX}/bin:${PATH}\nexport LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:${LD_LIBRARY_PATH}\n```\n\n## Usage\n\n### Generating artificial data\n\nThe repository comes with a Python3 script (in the `utility_scripts/` directory) to simply generate arbitrarily large data sets.\n\nIn order to use all functionality, the following Python3 modules must be installed:\n[`argparse`](https://docs.python.org/3/library/argparse.html), [`timeit`](https://docs.python.org/3/library/timeit.html),\n[`numpy`](https://pypi.org/project/numpy/), [`pandas`](https://pypi.org/project/pandas/),\n[`sklearn`](https://scikit-learn.org/stable/), [`arff`](https://pypi.org/project/arff/),\n[`matplotlib`](https://pypi.org/project/matplotlib/), [`mpl_toolkits`](https://pypi.org/project/matplotlib/),\nand [`humanize`](https://pypi.org/project/humanize/).\n\n```bash\npython3 utility_scripts/generate_data.py --help\nusage: generate_data.py [-h] --output OUTPUT --format FORMAT [--problem PROBLEM] --samples SAMPLES [--test_samples TEST_SAMPLES] --features FEATURES [--plot]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --output OUTPUT       the output file to write the samples to (without extension)\n  --format FORMAT       the file format; either arff or libsvm\n  --problem PROBLEM     the problem to solve; one of: blobs, blobs_merged, planes, planes_merged, ball\n  --samples SAMPLES     the number of training samples to generate\n  --test_samples TEST_SAMPLES\n                        the number of test samples to generate; default: 0\n  --features FEATURES   the number of features per data point\n  --plot                plot training samples; only possible if 0 \u003c samples \u003c= 2000 and 1 \u003c features \u003c= 3\n```\n\nAn example invocation generating a data set consisting of blobs with 1000 data points with 200 features each could look like:\n\n```bash\npython3 generate_data.py --output data_file --format libsvm --problem blobs --samples 1000 --features 200\n```\n\n### Training\n\n```bash\n./plssvm-train --help\nLS-SVM with multiple (GPU-)backends\nUsage:\n  ./plssvm-train [OPTION...] training_set_file [model_file]\n\n  -t, --kernel_type arg         set type of kernel function. \n                                         0 -- linear: u'*v\n                                         1 -- polynomial: (gamma*u'*v + coef0)^degree \n                                         2 -- radial basis function: exp(-gamma*|u-v|^2) (default: 0)\n  -d, --degree arg              set degree in kernel function (default: 3)\n  -g, --gamma arg               set gamma in kernel function (default: 1 / num_features)\n  -r, --coef0 arg               set coef0 in kernel function (default: 0)\n  -c, --cost arg                set the parameter C (default: 1)\n  -e, --epsilon arg             set the tolerance of termination criterion (default: 0.001)\n  -i, --max_iter arg            set the maximum number of CG iterations (default: num_features)\n  -b, --backend arg             choose the backend: automatic|openmp|cuda|hip|opencl|sycl (default: automatic)\n  -p, --target_platform arg     choose the target platform: automatic|cpu|gpu_nvidia|gpu_amd|gpu_intel (default: automatic)\n      --sycl_kernel_invocation_type arg\n                                choose the kernel invocation type when using SYCL as backend: automatic|nd_range|hierarchical (default: automatic)\n      --sycl_implementation_type arg\n                                choose the SYCL implementation to be used in the SYCL backend: automatic|dpcpp|hipsycl (default: automatic)\n      --performance_tracking arg\n                                the output YAML file where the performance tracking results are written to; if not provided, the results are dumped to stderr\n      --use_strings_as_labels   use strings as labels instead of plane numbers\n      --use_float_as_real_type  use floats as real types instead of doubles\n      --verbosity               choose the level of verbosity: full|timing|libsvm|quiet (default: full)\n  -q, --quiet                   quiet mode (no outputs regardless the provided verbosity level!)\n  -h, --help                    print this helper message\n  -v, --version                 print version information\n      --input training_set_file\n                                \n      --model model_file \n```\n\nThe help message only print options available based on the CMake invocation. \nFor example, if CUDA was not available during the build step, it will not show up as possible backend in the description of the `--backend` option.\n\nThe most minimal example invocation is:\n\n```bash\n./plssvm-train /path/to/data_file\n```\n\nAn example invocation using the CUDA backend could look like:\n\n```bash\n./plssvm-train --backend cuda --input /path/to/data_file\n```\n\nAnother example targeting NVIDIA GPUs using the SYCL backend looks like:\n\n```bash\n./plssvm-train --backend sycl --target_platform gpu_nvidia --input /path/to/data_file\n```\n\nThe `--backend=automatic` option works as follows:\n\n- if the `gpu_nvidia` target is available, check for existing backends in order `cuda` 🠦 `hip` 🠦 `opencl` 🠦 `sycl`\n- otherwise, if the `gpu_amd` target is available, check for existing backends in order `hip` 🠦 `opencl` 🠦 `sycl`\n- otherwise, if the `gpu_intel` target is available, check for existing backends in order `sycl` 🠦 `opencl`\n- otherwise, if the `cpu` target is available, check for existing backends in order `sycl` 🠦 `opencl` 🠦 `openmp`\n\nNote that during CMake configuration it is guaranteed that at least one of the above combinations does exist.\n\nThe `--target_platform=automatic` option works for the different backends as follows:\n\n- `OpenMP`: always selects a CPU\n- `CUDA`: always selects an NVIDIA GPU (if no NVIDIA GPU is available, throws an exception)\n- `HIP`: always selects an AMD GPU (if no AMD GPU is available, throws an exception)\n- `OpenCL`: tries to find available devices in the following order: NVIDIA GPUs 🠦 AMD GPUs 🠦 Intel GPUs 🠦 CPU\n- `SYCL`: tries to find available devices in the following order: NVIDIA GPUs 🠦 AMD GPUs 🠦 Intel GPUs 🠦 CPU\n\nThe `--sycl_kernel_invocation_type` and `--sycl_implementation_type` flags are only used if the `--backend` is `sycl`, otherwise a warning is emitted on `stderr`.\nIf 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`).\nIf the `--sycl_implementation_type` is `automatic`, the used SYCL implementation is determined by the `PLSSVM_SYCL_BACKEND_PREFERRED_IMPLEMENTATION` cmake flag.\n\n### Predicting\n\n```bash\n./plssvm-preidct --help\nLS-SVM with multiple (GPU-)backends\nUsage:\n  ./plssvm-preidct [OPTION...] test_file model_file [output_file]\n\n  -b, --backend arg             choose the backend: automatic|openmp|cuda|hip|opencl|sycl (default: automatic)\n  -p, --target_platform arg     choose the target platform: automatic|cpu|gpu_nvidia|gpu_amd|gpu_intel (default: automatic)\n      --sycl_implementation_type arg\n                                choose the SYCL implementation to be used in the SYCL backend: automatic|dpcpp|hipsycl (default: automatic)\n      --performance_tracking arg\n                                the output YAML file where the performance tracking results are written to; if not provided, the results are dumped to stderr\n      --use_strings_as_labels   use strings as labels instead of plane numbers\n      --use_float_as_real_type  use floats as real types instead of doubles\n      --verbosity               choose the level of verbosity: full|timing|libsvm|quiet (default: full)\n  -q, --quiet                   quiet mode (no outputs regardless the provided verbosity level!)\n  -h, --help                    print this helper message\n  -v, --version                 print version information\n      --test test_file          \n      --model model_file        \n      --output output_file\n```\n\nAn example invocation could look like:\n\n```bash\n./plssvm-preidct --backend cuda --test /path/to/test_file --model /path/to/model_file\n```\n\nAnother example targeting NVIDIA GPUs using the SYCL backend looks like:\n\n```bash\n./plssvm-preidct --backend sycl --target_platform gpu_nvidia --test /path/to/test_file --model /path/to/model_file\n```\n\nThe `--target_platform=automatic` and `--sycl_implementation_type` flags work like in the training (`./plssvm-train`) case.\n\n### Scaling\n\n```bash\nLS-SVM with multiple (GPU-)backends\nUsage:\n  ./plssvm-scale [OPTION...] input_file [scaled_file]\n\n  -l, --lower arg               lower is the lowest (minimal) value allowed in each dimension (default: -1)\n  -u, --upper arg               upper is the highest (maximal) value allowed in each dimension (default: 1)\n  -f, --format arg              the file format to output the scaled data set to (default: libsvm)\n  -s, --save_filename arg       the file to which the scaling factors should be saved\n  -r, --restore_filename arg    the file from which previous scaling factors should be loaded\n      --performance_tracking arg\n                                the output YAML file where the performance tracking results are written to; if not provided, the results are dumped to stderr\n      --use_strings_as_labels   use strings as labels instead of plane numbers\n      --use_float_as_real_type  use floats as real types instead of doubles\n      --verbosity               choose the level of verbosity: full|timing|libsvm|quiet (default: full)\n  -q, --quiet                   quiet mode (no outputs regardless the provided verbosity level!)\n  -h, --help                    print this helper message\n  -v, --version                 print version information\n      --input input_file        \n      --scaled scaled_file\n```\n\nAn example invocation could look like:\n\n```bash\n./plssvm-scale -l -0.5 -u 1.5 --input /path/to/input_file --scaled /path/to/scaled_file\n```\n\nAn example invocation to scale a train and test file in the same way looks like:\n\n```bash\n./plssvm-scale -l -1.0 -u 1.0 -s scaling_parameter.txt train_file.libsvm train_file_scaled.libsvm\n./plssvm-scale -r scaling_parameter.txt test_file.libsvm test_file_scaled.libsvm\n```\n\nFor more information see the `man` pages for `plssvm-train`, `plssvm-predict`, and `plssvm-scale` (which are installed via `cmake --build . -- install`).\n\n## Example code for usage as library\n\nA simple C++ program (`main.cpp`) using this library could look like:\n\n```cpp\n#include \"plssvm/core.hpp\"\n\n#include \u003cexception\u003e\n#include \u003ciostream\u003e\n#include \u003cvector\u003e\n\nint main() {\n    try {\n      \n        // create a new C-SVM parameter set, explicitly overriding the default kernel function\n        const plssvm::parameter params{ plssvm::kernel_type = plssvm::kernel_function_type::polynomial };\n\n        // create two data sets: one with the training data scaled to [-1, 1] \n        // and one with the test data scaled like the training data\n        const plssvm::data_set\u003cdouble\u003e train_data{ \"train_file.libsvm\", { -1.0, 1.0 } };\n        const plssvm::data_set\u003cdouble\u003e test_data{ \"test_file.libsvm\", train_data.scaling_factors()-\u003eget() };\n\n        // create C-SVM using the default backend and the previously defined parameter\n        const auto svm = plssvm::make_csvm(params);\n\n        // fit using the training data, (optionally) set the termination criterion\n        const plssvm::model model = svm-\u003efit(train_data, plssvm::epsilon = 10e-6);\n\n        // get accuracy of the trained model\n        const double model_accuracy = svm-\u003escore(model);\n        std::cout \u003c\u003c \"model accuracy: \" \u003c\u003c model_accuracy \u003c\u003c std::endl;\n\n        // predict the labels\n        const std::vector\u003cint\u003e label = svm-\u003epredict(model, test_data);\n\n        // write model file to disk\n        model.save(\"model_file.libsvm\");\n        \n    } catch (const plssvm::exception \u0026e) {\n        std::cerr \u003c\u003c e.what_with_loc() \u003c\u003c std::endl;\n    } catch (const std::exception \u0026e) {\n        std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n    }\n\n    return 0;\n}\n```\n\nWith a corresponding minimal CMake file:\n\n```cmake\ncmake_minimum_required(VERSION 3.16)\n\nproject(LibraryUsageExample\n        LANGUAGES CXX)\n\nfind_package(plssvm CONFIG REQUIRED)\n\nadd_executable(prog main.cpp)\n\ntarget_compile_features(prog PUBLIC cxx_std_17)\ntarget_link_libraries(prog PUBLIC plssvm::plssvm-all)\n```\n\n### Using the Python bindings\n\nRoughly the same can be achieved using our Python bindings with the following Python script:\n\n```python\nimport plssvm\n\ntry:\n    # create a new C-SVM parameter set, explicitly overriding the default kernel function\n    params = plssvm.Parameter(kernel_type=plssvm.KernelFunctionType.POLYNOMIAL)\n  \n    # create two data sets: one with the training data scaled to [-1, 1]\n    # and one with the test data scaled like the training data\n    train_data = plssvm.DataSet(\"train_data.libsvm\", scaling=(-1.0, 1.0))\n    test_data = plssvm.DataSet(\"test_data.libsvm\", scaling=train_data.scaling_factors())\n  \n    # create C-SVM using the default backend and the previously defined parameter\n    svm = plssvm.CSVM(params)\n  \n    # fit using the training data, (optionally) set the termination criterion\n    model = svm.fit(train_data, epsilon=10e-6)\n  \n    # get accuracy of the trained model\n    model_accuracy = svm.score(model)\n    print(\"model accuracy: {}\".format(model_accuracy))\n  \n    # predict labels\n    label = svm.predict(model, test_data)\n  \n    # write model file to disk\n    model.save(\"model_file.libsvm\")\nexcept plssvm.PLSSVMError as e:\n    print(e)\nexcept RuntimeError as e:\n    print(e)\n```\n\n**Note:** it may be necessary to set `PYTHONPATH` to the `lib` folder in the PLSSVM install path.\n\nWe also provide Python bindings for a `plssvm.SVC` class that offers the same interface as the  [`sklearn.svm.SVC`](https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html) class.\nNote that currently not all functionality has been implemented in PLSSVM.\nThe respective functions will throw a Python `AttributeError` if called.\n\n## Citing PLSSVM\n\nIf you use PLSSVM in your research, we kindly request you to cite:\n\n```text\n@inproceedings{9835379,\n  author={Van Craen, Alexander and Breyer, Marcel and Pfl\\\"{u}ger, Dirk},\n  booktitle={2022 IEEE International Parallel and Distributed Processing Symposium Workshops (IPDPSW)}, \n  title={PLSSVM: A (multi-)GPGPU-accelerated Least Squares Support Vector Machine}, \n  year={2022},\n  volume={},\n  number={},\n  pages={818-827},\n  doi={10.1109/IPDPSW55747.2022.00138}\n}\n```\nFor a full list of all publications involving PLSSVM see our [Wiki Page](https://github.com/SC-SGS/PLSSVM/wiki/List-of-Publications-involving-PLSSVM).\n\n## License\n\nThe PLSSVM library is distributed under the MIT [license](https://github.com/SC-SGS/PLSSVM/blob/main/LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSC-SGS%2FPLSSVM","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSC-SGS%2FPLSSVM","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSC-SGS%2FPLSSVM/lists"}