diff --git a/.github/workflows/docker-validation-ci.yml b/.github/workflows/docker-validation-ci.yml index 380172f82a5..09e258e6245 100644 --- a/.github/workflows/docker-validation-ci.yml +++ b/.github/workflows/docker-validation-ci.yml @@ -11,6 +11,10 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name }}-${{ github.event.number || github.sha }} + cancel-in-progress: true + jobs: validate: name: Docker validation diff --git a/.github/workflows/docker-validation-nightly.yml b/.github/workflows/docker-validation-nightly.yml index ea6ec499025..be2815af656 100644 --- a/.github/workflows/docker-validation-nightly.yml +++ b/.github/workflows/docker-validation-nightly.yml @@ -23,6 +23,10 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name }}-${{ github.event.number || github.sha }} + cancel-in-progress: true + jobs: validate: name: Docker validation diff --git a/.github/workflows/label-enforcement.yml b/.github/workflows/label-enforcement.yml index c862f64b798..7b393035e45 100644 --- a/.github/workflows/label-enforcement.yml +++ b/.github/workflows/label-enforcement.yml @@ -6,6 +6,10 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name }}-${{ github.event.number || github.sha }} + cancel-in-progress: true + jobs: label_checker: name: Please include labels on your pull request diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index 0e9026bcfdc..85b745e30b0 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -20,6 +20,10 @@ on: pull_request: types: [opened, edited, synchronize] +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name }}-${{ github.event.number || github.sha }} + cancel-in-progress: true + jobs: checklist: name: Close all checkboxes before moving from draft diff --git a/.github/workflows/renovate-validation.yml b/.github/workflows/renovate-validation.yml index 3d273fcce43..d44fa96ed22 100644 --- a/.github/workflows/renovate-validation.yml +++ b/.github/workflows/renovate-validation.yml @@ -17,6 +17,10 @@ on: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name }}-${{ github.event.number || github.sha }} + cancel-in-progress: true + jobs: validate: name: Renovate validation diff --git a/INSTALL.md b/INSTALL.md index 6cf464f1389..3727c7b32bb 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -19,7 +19,9 @@ Required Software: * C/C++ Compiler -* [DPC++ Compiler](https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler.html) +* [DPC++ Compiler](https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler.html) if building with SYCL support +* Python version 3.9 or higher +* TBB library (repository contains script to download it) * Microsoft Visual Studio\* (Windows\* only) * [MSYS2](http://msys2.github.io) (Windows\* only) * Python @@ -92,7 +94,7 @@ is available as an alternative to the manual setup. ./dev/download_tbb.sh -6. Download and install Python (version 3.7 or higher). +6. Download and install Python (version 3.9 or higher). 7. Build oneDAL via command-line interface. Choose the appropriate commands based on the interface, platform, and the compiler you use. Interface and platform are required arguments of makefile while others are optional. Below you can find the set of examples for building oneDAL. You may use a combination of them to get the desired build configuration: @@ -138,3 +140,35 @@ It is possible to build oneDAL libraries with selected set of algorithms and/or **NOTE:** Built libraries are located in the `__release_{os_name}[_{compiler_name}]/daal` directory. --- + +After having built the library, if one wishes to use it for building [scikit-learn-intelex](https://github.com/intel/scikit-learn-intelex/tree/main) or for executing the usage examples, one can set the required environment variables to point to the generated build by sourcing the script that it creates under the `env` folder. The script will be located under `__release_{os_name}[_{compiler_name}]/daal/latest/env/vars.sh` and can be sourced with a POSIX-compliant shell such as `bash`, by executing something like the following from inside the `__release*` folder: + +```shell +cd daal/latest +source env/vars.sh +``` + +The provided unit tests for the library can be executed through the Bazel system - see the [Bazel docs](https://github.com/oneapi-src/oneDAL/tree/main/dev/bazel) for more information. + +Examples of library usage will also be auto-generated as part of the build under path `daal/latest/examples/daal/cpp/source`. These can be built through CMake - assuming one starts from the release path `__release_{os_name}[_{compiler_name}]`, the following would do: + +```shell +cd daal/latest/examples/daal/cpp +mkdir -p build +cd build +cmake .. +make -j$(nproc) +``` + +This will generate executables under path `daal/latest/examples/daal/cpp/_cmake_results/{platform_name}`. They can be executed as follows (note that they require access to the data files under `daal/latest/examples/daal/data`), assuming that one starts from inside the `build` folder (as at the end of the previous step): + +```shell +cd .. +./_cmake_results/{platform_name}/{example} +``` + +For example, in a Linux platform, assuming one wishes to execute the `adaboost_dense_batch` example: + +```shell +./_cmake_results/intel_intel64_so/adaboost_dense_batch +``` diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 0f925d7702a..d5b9835c0bf 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -1,3 +1,20 @@ + + # Introduction This document defines roles in oneDAL project. diff --git a/cpp/daal/src/algorithms/svm/svm_train_common_impl.i b/cpp/daal/src/algorithms/svm/svm_train_common_impl.i index e158b6640d4..adbc9388e66 100644 --- a/cpp/daal/src/algorithms/svm/svm_train_common_impl.i +++ b/cpp/daal/src/algorithms/svm/svm_train_common_impl.i @@ -1,6 +1,7 @@ /* file: svm_train_common_impl.i */ /******************************************************************************* * Copyright 2020 Intel Corporation +* Copyright contributors to the oneDAL project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +42,11 @@ #endif // __CPUID__(DAAL_CPU) == __avx512__ #endif // defined (_M_AMD64) || defined (__amd64) || defined (__x86_64) || defined (__x86_64__) -#endif // DAAL_INTEL_CPP_COMPILER +#elif defined(TARGET_ARM) + #if (__CPUID__(DAAL_CPU) == __sve__) + #include "src/algorithms/svm/svm_train_common_sve_impl.i" + #endif // __CPUID__(DAAL_CPU) == __sve__ +#endif namespace daal { diff --git a/cpp/daal/src/algorithms/svm/svm_train_common_sve_impl.i b/cpp/daal/src/algorithms/svm/svm_train_common_sve_impl.i new file mode 100644 index 00000000000..2bf597ef4bd --- /dev/null +++ b/cpp/daal/src/algorithms/svm/svm_train_common_sve_impl.i @@ -0,0 +1,155 @@ +/******************************************************************************* +* Copyright contributors to the oneDAL project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*******************************************************************************/ +/* + * Contains SVE optimizations for WSSj (Working Set Selection) algorithm. +*/ + +#include +#include "src/services/service_data_utils.h" + +namespace daal +{ +namespace algorithms +{ +namespace svm +{ +namespace training +{ +namespace internal +{ + +/** + * \brief Working set selection (WSSj) function. + * Select an index j from a pair of indices B = {i, j} using WSS algorithm. + * + * \return The function implicitly returns GMax, which represents: + * M(alpha) = max { (GMin - (-y[j]*grad[j]))^2 / (2 * (Kii + Kjj - 2Kij)) } : j belongs to I_LOW(alpha) + */ +template <> +inline void HelperTrainSVM::WSSjLocal(const size_t jStart, const size_t jEnd, const float * KiBlock, const float * kernelDiag, + const float * grad, const char * I, const float GMin, const float Kii, const float tau, int & Bj, + float & GMax, float & GMax2, float & delta, SignNuType signNuType) +{ + const int w = (int)svcntw(); //vector length + float fpMax = MaxVal::get(); + float GMax2Local = -fpMax; // store min(grad[i]) or max(y[i]*grad[i]), y[i]*grad[i] = -GMin2 + float GMaxLocal = -fpMax; // store min(-b^2/a) or max(b^2/a), b^2/a = -GMin + float GMinLocal = GMin; + + float zero(0.0); + float two(2.0); + + const char sign = getSign(signNuType); + + svbool_t pgf = svptrue_b32(); //predicate for float + + svfloat32_t valGMax2 = svdup_f32(GMax2Local); + svfloat32_t valGMax = svdup_f32(GMaxLocal); + svfloat32_t valGMin = svdup_f32(GMinLocal); + svint32_t Bj_vec = svdup_s32(-1); + + // some constants used during optimization + // enum SVMVectorStatus low = 0x2 + svint32_t vecSignLow; + if (signNuType == SignNuType::none) + { + vecSignLow = svdup_n_s32(low); + } + else + { + DAAL_ASSERT((sign & (sign - 1)) == 0) // used to make sure sign is always having 1 bit set + svint32_t t1 = svdup_n_s32(low); + svint32_t t2 = svdup_n_s32(sign); + vecSignLow = svorr_s32_z(pgf, t1, t2); + } + + svfloat32_t two_vec = svdup_f32(two); + svfloat32_t Kii_vec = svdup_f32(Kii); + svfloat32_t tau_vec = svdup_f32(tau); + + for (size_t j_cur = jStart; j_cur < jEnd; j_cur += w) + { + svint32_t Bj_vec_cur = svindex_s32(j_cur, 1); // Bj value starts with j_cur + svbool_t pg2 = svwhilelt_b32(j_cur, jEnd); // adapts to vector length + + svint32_t vec_I = svld1sb_s32(pg2, reinterpret_cast(&I[j_cur])); // load chars + + // Combine 2 if conditions + // cond1: !(I[j]&sign) {continue} + // cond2: (I[j]&low)!=low {continue} + // combined: (I[j] & (sign | low)) == (sign | low) + // assertion @L63 is a prerequisite for the combined condition to satisfy + svint32_t result_of_and32 = svand_s32_m(pg2, vec_I, vecSignLow); + pg2 = svcmpeq_s32(pg2, result_of_and32, vecSignLow); // if pg2 bit is 0 then continue; + + svfloat32_t valGrad = svld1_f32(pg2, &grad[j_cur]); // load grads + // if (gradj > GMax2) { GMax2 = gradj; } + valGMax2 = svmax_f32_m(pg2, valGMax2, valGrad); + // cond3: if (gradj < GMin) { continue; } + svbool_t cond3 = svcmpge_f32(pg2, valGrad, valGMin); + pg2 = svand_b_z(pg2, pg2, cond3); // combine all 3 conditions + + svfloat32_t b_vec = svsub_f32_x(pg2, valGMin, valGrad); // b = Gmin - grad + + svfloat32_t KiBlock_vec = svld1_f32(pg2, KiBlock + j_cur - jStart); // load kiBlocs + svfloat32_t kernelDiag_vec = svld1_f32(pg2, &kernelDiag[j_cur]); // load kernelDiags + svfloat32_t a_vec = svnmls_f32_x(pg2, kernelDiag_vec, two_vec, KiBlock_vec); // a_tmp = two * KiBlock[j - jStart] - kernelDiag[j] + + // originally, if a < 0, a = tau + // mask3_ : 1 if Kii > a_tmp + // if mask3_ : 1, a = Kii - a_tmp, else a = tau. + svbool_t mask3_ = svcmpgt_f32(pg2, Kii_vec, a_vec); + a_vec = svsel_f32(mask3_, svsub_f32_x(mask3_, Kii_vec, a_vec), tau_vec); + + svfloat32_t dt_vec = svdiv_f32_x(pg2, b_vec, a_vec); // b/a = delta. + svfloat32_t objFunc_vec = svmul_f32_x(pg2, dt_vec, b_vec); // objFunc = b * delta + + svbool_t mask4_ = svcmpgt_f32(pg2, objFunc_vec, valGMax); // if (objFunc > GMax) + valGMax = svsel_f32(mask4_, objFunc_vec, valGMax); // if mask is 1, valGMax = objFunc_vec, else valGMax original value + Bj_vec = svsel_s32(mask4_, Bj_vec_cur, Bj_vec); // if mask is 1, Bj_vec = Bj_vec_cur, else Bj_vec original value + } + + // reductions + GMax = svmaxv_f32(pgf, valGMax); + GMax2 = svmaxv_f32(pgf, valGMax2); + svbool_t tmp_mask = svcmpeq(pgf, svdup_f32(GMax), valGMax); + Bj = svmaxv_s32(tmp_mask, Bj_vec); + + if (Bj != -1) + { + const double gradBj = grad[Bj]; + const double b = GMin - gradBj; + double a = Kii + kernelDiag[Bj] - two * KiBlock[Bj - jStart]; + if (a <= zero) + { + a = tau; + } + delta = b / a; + GMax = b * delta; + } + else + { + GMax = -fpMax; + GMax2 = -fpMax; + } + delta = -delta; +} + +} // namespace internal +} // namespace training +} // namespace svm +} // namespace algorithms +} // namespace daal diff --git a/dev/make/compiler_definitions/dpcpp.mk b/dev/make/compiler_definitions/dpcpp.mk index 848f36c2db1..78ec5da36fe 100644 --- a/dev/make/compiler_definitions/dpcpp.mk +++ b/dev/make/compiler_definitions/dpcpp.mk @@ -33,8 +33,8 @@ COMPILER.lnx.dpcpp = icpx -fsycl -m64 -stdlib=libstdc++ -fgnu-runtime -fwrapv \ COMPILER.win.dpcpp = icx -fsycl $(if $(MSVC_RT_is_release),-MD, -MDd /debug:none) -nologo -WX \ -Wno-deprecated-declarations -fsycl-device-code-split=per_kernel -link.dynamic.lnx.dpcpp = icpx -fsycl -m64 -fsycl-device-code-split=per_kernel -link.dynamic.win.dpcpp = icx -fsycl -m64 -fsycl-device-code-split=per_kernel +link.dynamic.lnx.dpcpp = icpx -fsycl -m64 -fsycl-device-code-split=per_kernel -fsycl-max-parallel-link-jobs=$(SYCL_LINK_PRL) +link.dynamic.win.dpcpp = icx -fsycl -m64 -fsycl-device-code-split=per_kernel -fsycl-max-parallel-link-jobs=$(SYCL_LINK_PRL) pedantic.opts.lnx.dpcpp = -pedantic \ -Wall \ diff --git a/docs/source/daal/algorithms/decision_forest/decision-forest-classification.rst b/docs/source/daal/algorithms/decision_forest/decision-forest-classification.rst index 42d5fc06177..521010667fc 100644 --- a/docs/source/daal/algorithms/decision_forest/decision-forest-classification.rst +++ b/docs/source/daal/algorithms/decision_forest/decision-forest-classification.rst @@ -160,8 +160,8 @@ Examples .. tab:: Python* - - :daal4py_example:`df_cls_dense_batch_model_builder.py` - - :daal4py_example:`df_cls_traversed_model_builder.py` + - :daal4py_example:`decision_forest_classification_default_dense.py` + - :daal4py_example:`decision_forest_classification_traverse.py` Batch Processing ================ diff --git a/docs/source/daal/algorithms/gradient_boosted_trees/gradient-boosted-trees-classification.rst b/docs/source/daal/algorithms/gradient_boosted_trees/gradient-boosted-trees-classification.rst index 356e6906511..d3a9e84de47 100644 --- a/docs/source/daal/algorithms/gradient_boosted_trees/gradient-boosted-trees-classification.rst +++ b/docs/source/daal/algorithms/gradient_boosted_trees/gradient-boosted-trees-classification.rst @@ -108,7 +108,7 @@ Examples .. tab:: Python* - - :daal4py_example:`gbt_cls_traversed_model_builder.py` + - :daal4py_example:`gradient_boosted_classification_traverse.py` Batch Processing **************** diff --git a/docs/source/daal/algorithms/gradient_boosted_trees/gradient-boosted-trees-regression.rst b/docs/source/daal/algorithms/gradient_boosted_trees/gradient-boosted-trees-regression.rst index d096cd14f01..491b78998ec 100644 --- a/docs/source/daal/algorithms/gradient_boosted_trees/gradient-boosted-trees-regression.rst +++ b/docs/source/daal/algorithms/gradient_boosted_trees/gradient-boosted-trees-regression.rst @@ -91,7 +91,7 @@ Examples .. tab:: Python* - - :daal4py_example:`gbt_reg_traversed_model_builder.py` + - :daal4py_example:`gradient_boosted_regression_traverse.py` Batch Processing diff --git a/docs/source/daal/algorithms/linear_ridge_regression/linear-regression.rst b/docs/source/daal/algorithms/linear_ridge_regression/linear-regression.rst index 90a93d65beb..8b6be6b9ec2 100644 --- a/docs/source/daal/algorithms/linear_ridge_regression/linear-regression.rst +++ b/docs/source/daal/algorithms/linear_ridge_regression/linear-regression.rst @@ -108,4 +108,4 @@ Examples .. tab:: Python* - - :daal4py_example:`lin_reg_model.py` + - :daal4py_example:`linear_regression.py` diff --git a/docs/source/daal/algorithms/svm/support-vector-machine-classifier.rst b/docs/source/daal/algorithms/svm/support-vector-machine-classifier.rst index f04871e8fc7..b73f12af07a 100644 --- a/docs/source/daal/algorithms/svm/support-vector-machine-classifier.rst +++ b/docs/source/daal/algorithms/svm/support-vector-machine-classifier.rst @@ -127,10 +127,6 @@ Examples - :cpp_example:`svm_two_class_model_builder.cpp ` - .. tab:: Python* - - - :daal4py_example:`svm_two_class_model_builder.py` - Batch Processing **************** diff --git a/docs/source/daal/algorithms/svm_multi_class/multi-class-classifier.rst b/docs/source/daal/algorithms/svm_multi_class/multi-class-classifier.rst index 6c5405fe720..8da25c7cf70 100644 --- a/docs/source/daal/algorithms/svm_multi_class/multi-class-classifier.rst +++ b/docs/source/daal/algorithms/svm_multi_class/multi-class-classifier.rst @@ -108,7 +108,7 @@ Examples .. tab:: Python* - :daal4py_example:`svm_multi_class_model_builder.py` + :daal4py_example:`svm_multiclass.py` Batch Processing **************** diff --git a/docs/source/daal/data-management/data-sources.rst b/docs/source/daal/data-management/data-sources.rst index 51a155a53c9..2f07c4c1c79 100644 --- a/docs/source/daal/data-management/data-sources.rst +++ b/docs/source/daal/data-management/data-sources.rst @@ -305,7 +305,6 @@ Samples ------- - :cpp_sample:`mysql/sources/datasource_mysql.cpp` -- :cpp_sample:`kdb/sources/datasource_kdb.cpp` Examples -------- diff --git a/makefile b/makefile index 2984ec4eba9..3ea7f0453ac 100644 --- a/makefile +++ b/makefile @@ -44,6 +44,13 @@ MSVC_RUNTIME_VERSIONs = release debug MSVC_RUNTIME_VERSION ?= release $(if $(filter $(MSVC_RUNTIME_VERSIONs),$(MSVC_RUNTIME_VERSION)),,$(error MSVC_RUNTIME_VERSION must be one of $(MSVC_RUNTIME_VERSIONs))) +MAKE_PID := $(shell echo $$PPID) +JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)"))) +MAKE_JOBS := $(subst -j,,$(JOB_FLAG)) +MAKE_JOBS := $(if $(filter $(MAKE_JOBS),$(shell seq 1 999)),$(MAKE_JOBS),$(shell nproc)) + +SYCL_LINK_PRL := $(MAKE_JOBS) + COMPILER_is_$(COMPILER) := yes COMPILER_is_cross := $(if $(filter $(PLAT),$(IDENTIFIED_PLAT)),no,yes) OS_is_$(_OS) := yes