Skip to content

Commit

Permalink
Merge branch 'oneapi-src:main' into dev/undeclared_dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
icfaust authored Oct 7, 2024
2 parents 1adca78 + 84c9bbb commit ff649dc
Show file tree
Hide file tree
Showing 18 changed files with 249 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/docker-validation-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/docker-validation-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/label-enforcement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pr-checklist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/renovate-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 36 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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
```
17 changes: 17 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
<!--
******************************************************************************
* 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.
*******************************************************************************/-->

# Introduction

This document defines roles in oneDAL project.
Expand Down
7 changes: 6 additions & 1 deletion cpp/daal/src/algorithms/svm/svm_train_common_impl.i
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
{
Expand Down
155 changes: 155 additions & 0 deletions cpp/daal/src/algorithms/svm/svm_train_common_sve_impl.i
Original file line number Diff line number Diff line change
@@ -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 <arm_sve.h>
#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<float, sve>::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<float>::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<const int8_t *>(&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
4 changes: 2 additions & 2 deletions dev/make/compiler_definitions/dpcpp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Examples

.. tab:: Python*

- :daal4py_example:`gbt_cls_traversed_model_builder.py`
- :daal4py_example:`gradient_boosted_classification_traverse.py`

Batch Processing
****************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Examples

.. tab:: Python*

- :daal4py_example:`gbt_reg_traversed_model_builder.py`
- :daal4py_example:`gradient_boosted_regression_traverse.py`


Batch Processing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ Examples

.. tab:: Python*

- :daal4py_example:`lin_reg_model.py`
- :daal4py_example:`linear_regression.py`
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ Examples

- :cpp_example:`svm_two_class_model_builder.cpp <svm/svm_two_class_model_builder.cpp>`

.. tab:: Python*

- :daal4py_example:`svm_two_class_model_builder.py`

Batch Processing
****************

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Examples

.. tab:: Python*

:daal4py_example:`svm_multi_class_model_builder.py`
:daal4py_example:`svm_multiclass.py`

Batch Processing
****************
Expand Down
1 change: 0 additions & 1 deletion docs/source/daal/data-management/data-sources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ Samples
-------

- :cpp_sample:`mysql/sources/datasource_mysql.cpp`
- :cpp_sample:`kdb/sources/datasource_kdb.cpp`

Examples
--------
Expand Down
7 changes: 7 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ff649dc

Please sign in to comment.