Skip to content

Commit

Permalink
Merge branch 'main' into dev/asolovev_mkl_support
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr-Solovev authored Jul 26, 2024
2 parents 72c9671 + bb9e92e commit e523d06
Show file tree
Hide file tree
Showing 44 changed files with 1,480 additions and 174 deletions.
4 changes: 2 additions & 2 deletions .ci/env/apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function add_repo {
}

function install_dpcpp {
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-2024.1
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-2024.2
sudo bash -c 'echo libintelocl.so > /etc/OpenCL/vendors/intel-cpu.icd'
}

Expand Down Expand Up @@ -63,7 +63,7 @@ function install_qemu_emulation_apt {
}

function install_qemu_emulation_deb {
qemu_deb=qemu-user-static_8.2.1+ds-1~bpo12+1_amd64.deb
qemu_deb=qemu-user-static_9.0.1+ds-1~bpo12+1_amd64.deb
set -eo pipefail
wget http://ftp.debian.org/debian/pool/main/q/qemu/${qemu_deb}
sudo dpkg -i ${qemu_deb}
Expand Down
3 changes: 1 addition & 2 deletions .ci/env/environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: ci-env
channels:
- conda-forge
- intel
- defaults
dependencies:
- impi-devel=2021.10.0
- impi-devel=2021.12.0
2 changes: 1 addition & 1 deletion .ci/pipeline/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ jobs:
displayName: 'System info'
- script: |
conda update -y -q conda
conda create -q -y -n CB -c intel python=$(python.version) tbb mpich
conda create -q -y -n CB -c conda-forge python=$(python.version) tbb mpich
displayName: 'Conda create'
- script: |
git clone https://github.com/intel/scikit-learn-intelex.git daal4py
Expand Down
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Documentation owners and reviewers
/docs/ @Vika-F @maria-Petrova @Alexsandruss @aepanchi
*.md @Vika-F @maria-Petrova @Alexsandruss @aepanchi
/docs/ @Vika-F @maria-Petrova @Alexsandruss @bdmoore1
*.md @Vika-F @maria-Petrova @Alexsandruss @bdmoore1

# TTP files
third-party* @maria-Petrova
Expand All @@ -22,7 +22,7 @@ deploy/ @Alexsandruss @napetrov @homksei @ahuber21 @ethanglaser
dev/ @Alexsandruss @napetrov @homksei @ahuber21 @ethanglaser

# C++ code
cpp/ @Alexsandruss @samir-nasibli @KulikovNikita @Alexandr-Solovev
cpp/ @Alexsandruss @samir-nasibli @Alexandr-Solovev

# Tree based methods
dtrees @razdoburdin @ahuber21 @avolkov-intel @icfaust
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@

[Installation](#installation)   |   [Documentation](#documentation)   |   [Support](#support)   |   [Examples](#examples)   |   [How to Contribute](CONTRIBUTING.md)   

[![Build Status](https://dev.azure.com/daal/DAAL/_apis/build/status/oneapi-src.oneDAL?branchName=main)](https://dev.azure.com/daal/DAAL/_build/latest?definitionId=5&branchName=main) [![License](https://img.shields.io/github/license/oneapi-src/oneDAL.svg)](https://github.com/oneapi-src/oneDAL/blob/main/LICENSE) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8859/badge)](https://www.bestpractices.dev/projects/8859) [![Join the community on GitHub Discussions](https://badgen.net/badge/join%20the%20discussion/on%20github/black?icon=github)](https://github.com/oneapi-src/oneDAL/discussions)
[![Build Status](https://dev.azure.com/daal/DAAL/_apis/build/status/oneapi-src.oneDAL?branchName=main)](https://dev.azure.com/daal/DAAL/_build/latest?definitionId=5&branchName=main)
[![License](https://img.shields.io/github/license/oneapi-src/oneDAL.svg)](https://github.com/oneapi-src/oneDAL/blob/main/LICENSE)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8859/badge)](https://www.bestpractices.dev/projects/8859)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/oneapi-src/oneDAL/badge)](https://securityscorecards.dev/viewer/?uri=github.com/oneapi-src/oneDAL)
[![Join the community on GitHub Discussions](https://badgen.net/badge/join%20the%20discussion/on%20github/black?icon=github)](https://github.com/oneapi-src/oneDAL/discussions)

oneAPI Data Analytics Library (oneDAL) is a powerful machine learning library that helps you accelerate big data analysis at all stages: **preprocessing**, **transformation**, **analysis**, **modeling**, **validation**, and **decision making**.

Expand Down
18 changes: 10 additions & 8 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

As an open-source project, we understand the importance of and responsibility
for security. This Security Policy outlines our guidelines and procedures to
ensure the highest level of security and trust for Intel(R) oneAPI Data Analytics Library.
ensure the highest level of security and trust for oneDAL

## Supported Versions

Security vulnerabilities are fixed in the [latest version][1]
and delivered as a patch release. We don't guarantee security fixes to be
back-ported to older Intel(R) oneAPI Data Analytics Library versions.
back-ported to older oneDAL versions.

## Report a Vulnerability

Expand All @@ -52,24 +52,24 @@ Along with the report, provide the following info:

### When Should I Report a Vulnerability?

* You think you discovered a potential security vulnerability in Intel(R) oneAPI Data Analytics Library.
* You are unsure how the potential vulnerability affects Intel(R) oneAPI Data Analytics Library.
* You think you discovered a potential security vulnerability in oneDAL
* You are unsure how the potential vulnerability affects oneDAL
* You think you discovered a vulnerability in another project or 3rd party
component on which Intel(R) oneAPI Data Analytics Library depends. If the issue is not fixed in the 3rd party
component on which oneDAL depends. If the issue is not fixed in the 3rd party
component, try to report directly there first.

### When Should I NOT Report a Vulnerability?

* You got an automated scan hit and are unable to provide details.
* You need help using Intel(R) oneAPI Data Analytics Library for security.
* You need help using oneDAL for security.
* You need help applying security-related updates.
* Your issue is not security-related.

## Security Reports Review Process

We aim to respond quickly to your inquiry and coordinate a fix and
disclosure with you. All confirmed security vulnerabilities will be addressed
according to severity level and impact on Intel(R) oneAPI Data Analytics Library. Normally, security issues are fixed in the next planned release.
according to severity level and impact on oneDAL Normally, security issues are fixed in the next planned release.

## Disclosure Policy

Expand All @@ -88,4 +88,6 @@ If you have any suggestions on how this Policy could be improved, submit
an issue or a pull request to this repository. **Do not** report
potential vulnerabilities or security flaws via a pull request.

[1]: https://github.com/oneapi-src/oneDAL/releases
[1]: https://github.com/oneapi-src/oneDAL/releases
[2]: https://github.com/oneapi-src/oneDAL/security/advisories/new
[3]: https://github.com/oneapi-src/oneDAL/security/advisories
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ http_archive(

http_archive(
name = "fmt",
url = "https://github.com/fmtlib/fmt/archive/10.2.1.tar.gz",
sha256 = "1250e4cc58bf06ee631567523f48848dc4596133e163f02615c97f78bab6c811",
strip_prefix = "fmt-10.2.1",
url = "https://github.com/fmtlib/fmt/archive/11.0.2.tar.gz",
sha256 = "6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f",
strip_prefix = "fmt-11.0.2",
build_file = "@onedal//dev/bazel/deps:fmt.tpl.BUILD",
)
4 changes: 4 additions & 0 deletions cpp/daal/include/services/env_detect.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ class DAAL_EXPORT Environment : public Base
void initNumberOfThreads();

env _env;
// Pointer to the oneapi::tbb::task_scheduler_handle class object, global for oneDAL.
// The oneapi::tbb::task_scheduler_handle and the oneapi::tbb::finalize function
// allow user to wait for completion of worker threads.
void * _schedulerHandle;
void * _globalControl;
SharedPtr<services::internal::sycl::ExecutionContextIface> _executionContext;
};
Expand Down
32 changes: 28 additions & 4 deletions cpp/daal/src/externals/core_threading_win_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ typedef void (*_daal_wait_task_group_t)(void * taskGroupPtr);

typedef bool (*_daal_is_in_parallel_t)();
typedef void (*_daal_tbb_task_scheduler_free_t)(void *& globalControl);
typedef void (*_daal_tbb_task_scheduler_handle_free_t)(void *& schedulerHandle);
typedef size_t (*_setNumberOfThreads_t)(const size_t, void **);
typedef size_t (*_setSchedulerHandle_t)(void **);
typedef void * (*_daal_threader_env_t)();

typedef void (*_daal_parallel_sort_int32_t)(int *, int *);
Expand Down Expand Up @@ -205,10 +207,12 @@ static _daal_del_task_group_t _daal_del_task_group_ptr = NULL;
static _daal_run_task_group_t _daal_run_task_group_ptr = NULL;
static _daal_wait_task_group_t _daal_wait_task_group_ptr = NULL;

static _daal_is_in_parallel_t _daal_is_in_parallel_ptr = NULL;
static _daal_tbb_task_scheduler_free_t _daal_tbb_task_scheduler_free_ptr = NULL;
static _setNumberOfThreads_t _setNumberOfThreads_ptr = NULL;
static _daal_threader_env_t _daal_threader_env_ptr = NULL;
static _daal_is_in_parallel_t _daal_is_in_parallel_ptr = NULL;
static _daal_tbb_task_scheduler_free_t _daal_tbb_task_scheduler_free_ptr = NULL;
static _daal_tbb_task_scheduler_handle_free_t _daal_tbb_task_scheduler_handle_free_ptr = NULL;
static _setNumberOfThreads_t _setNumberOfThreads_ptr = NULL;
static _setSchedulerHandle_t _setSchedulerHandle_ptr = NULL;
static _daal_threader_env_t _daal_threader_env_ptr = NULL;

static _daal_parallel_sort_int32_t _daal_parallel_sort_int32_ptr = NULL;
static _daal_parallel_sort_uint64_t _daal_parallel_sort_uint64_ptr = NULL;
Expand Down Expand Up @@ -657,6 +661,16 @@ DAAL_EXPORT void _daal_tbb_task_scheduler_free(void *& init)
return _daal_tbb_task_scheduler_free_ptr(init);
}

DAAL_EXPORT void _daal_tbb_task_scheduler_handle_free(void *& init)
{
load_daal_thr_dll();
if (_daal_tbb_task_scheduler_handle_free_ptr == NULL)
{
_daal_tbb_task_scheduler_handle_free_ptr = (_daal_tbb_task_scheduler_handle_free_t)load_daal_thr_func("_daal_tbb_task_scheduler_handle_free");
}
return _daal_tbb_task_scheduler_handle_free_ptr(init);
}

DAAL_EXPORT size_t _setNumberOfThreads(const size_t numThreads, void ** init)
{
load_daal_thr_dll();
Expand All @@ -667,6 +681,16 @@ DAAL_EXPORT size_t _setNumberOfThreads(const size_t numThreads, void ** init)
return _setNumberOfThreads_ptr(numThreads, init);
}

DAAL_EXPORT size_t _setSchedulerHandle(void ** init)
{
load_daal_thr_dll();
if (_setSchedulerHandle_ptr == NULL)
{
_setSchedulerHandle_ptr = (_setSchedulerHandle_t)load_daal_thr_func("_setSchedulerHandle");
}
return _setSchedulerHandle_ptr(init);
}

DAAL_EXPORT void * _daal_threader_env()
{
load_daal_thr_dll();
Expand Down
68 changes: 64 additions & 4 deletions cpp/daal/src/externals/service_stat_ref.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* file: service_stat_ref.h */
/*******************************************************************************
* Copyright 2023 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 All @@ -24,8 +25,9 @@
#ifndef __SERVICE_STAT_REF_H__
#define __SERVICE_STAT_REF_H__

typedef void (*func_type)(DAAL_INT, DAAL_INT, DAAL_INT, void *);
#include "src/externals/service_memory.h"

typedef void (*func_type)(DAAL_INT, DAAL_INT, DAAL_INT, void *);
extern "C"
{
#define __DAAL_VSL_SS_MATRIX_STORAGE_COLS 0x00020000
Expand Down Expand Up @@ -194,8 +196,37 @@ struct RefStatistics<double, cpu>

static int x2c_mom(const double * data, const __int64 nFeatures, const __int64 nVectors, double * variance, const __int64 method)
{
int errcode = 0;

// E(x-\mu)^2 = E(x^2) - \mu^2
int errcode = 0;
double * sum = (double *)daal::services::internal::service_calloc<double, cpu>(nFeatures, sizeof(double));
if (!sum) return -4;
daal::services::internal::service_memset<double, cpu>(variance, double(0), nFeatures);
DAAL_INT feature_ptr, vec_ptr;
double wtInv = (double)1 / nVectors;
double wtInvMinus = (double)1 / (nVectors - 1);
double pt = 0;
for (vec_ptr = 0; vec_ptr < nVectors; ++vec_ptr)
{
#pragma omp simd
for (feature_ptr = 0; feature_ptr < nFeatures; ++feature_ptr)
{
pt = data[vec_ptr * nFeatures + feature_ptr];
sum[feature_ptr] += pt;
variance[feature_ptr] += (pt * pt); // 2RSum
}
}
double sumSqDivN; // S^2/n = n*\mu^2
#pragma omp simd
for (feature_ptr = 0; feature_ptr < nFeatures; ++feature_ptr)
{
sumSqDivN = sum[feature_ptr];
sumSqDivN *= sumSqDivN;
sumSqDivN *= wtInv;
variance[feature_ptr] -= sumSqDivN; // (2RSum-S^2/n)
variance[feature_ptr] *= wtInvMinus;
}
daal::services::internal::service_free<double, cpu>(sum);
sum = NULL;
return errcode;
}

Expand Down Expand Up @@ -276,8 +307,37 @@ struct RefStatistics<float, cpu>

static int x2c_mom(const float * data, const __int64 nFeatures, const __int64 nVectors, float * variance, const __int64 method)
{
// E(x-\mu)^2 = E(x^2) - \mu^2
int errcode = 0;

float * sum = (float *)daal::services::internal::service_calloc<float, cpu>(nFeatures, sizeof(float));
if (!sum) return -4;
daal::services::internal::service_memset<float, cpu>(variance, float(0), nFeatures);
DAAL_INT feature_ptr, vec_ptr;
float wtInv = (float)1 / nVectors;
float wtInvMinus = (float)1 / (nVectors - 1);
float pt = 0;
for (vec_ptr = 0; vec_ptr < nVectors; ++vec_ptr)
{
#pragma omp simd
for (feature_ptr = 0; feature_ptr < nFeatures; ++feature_ptr)
{
pt = data[vec_ptr * nFeatures + feature_ptr];
sum[feature_ptr] += pt;
variance[feature_ptr] += (pt * pt); // 2RSum
}
}
float sumSqDivN; // S^2/n = n*\mu^2
#pragma omp simd
for (feature_ptr = 0; feature_ptr < nFeatures; ++feature_ptr)
{
sumSqDivN = sum[feature_ptr];
sumSqDivN *= sumSqDivN;
sumSqDivN *= wtInv;
variance[feature_ptr] -= sumSqDivN; // (2RSum-S^2/n)
variance[feature_ptr] *= wtInvMinus;
}
daal::services::internal::service_free<float, cpu>(sum);
sum = NULL;
return errcode;
}

Expand Down
15 changes: 12 additions & 3 deletions cpp/daal/src/services/env_detect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ DAAL_EXPORT void daal::services::Environment::setDynamicLibraryThreadingTypeOnWi
initNumberOfThreads();
}

DAAL_EXPORT daal::services::Environment::Environment() : _globalControl {}
DAAL_EXPORT daal::services::Environment::Environment() : _schedulerHandle {}, _globalControl {}
{
_env.cpuid_init_flag = false;
_env.cpuid = -1;
Expand All @@ -137,7 +137,14 @@ DAAL_EXPORT daal::services::Environment::Environment(const Environment & e) : da
DAAL_EXPORT void daal::services::Environment::initNumberOfThreads()
{
if (isInit) return;

// Initializes global oneapi::tbb::task_scheduler_handle object in oneDAL to prevent the unexpected
// destruction of the calling thread.
// When the oneapi::tbb::finalize function is called with an oneapi::tbb::task_scheduler_handle
// instance, it blocks the calling thread until the completion of all worker
// threads that were implicitly created by the library.
#if defined(TARGET_X86_64)
daal::setSchedulerHandle(&_schedulerHandle);
#endif
/* if HT enabled - set _numThreads to physical cores num */
if (daal::internal::ServiceInst::serv_get_ht())
{
Expand All @@ -156,7 +163,6 @@ DAAL_EXPORT void daal::services::Environment::initNumberOfThreads()
DAAL_EXPORT daal::services::Environment::~Environment()
{
daal::services::daal_free_buffers();
_daal_tbb_task_scheduler_free(_globalControl);
}

void daal::services::Environment::_cpu_detect(int enable)
Expand All @@ -171,6 +177,9 @@ void daal::services::Environment::_cpu_detect(int enable)
DAAL_EXPORT void daal::services::Environment::setNumberOfThreads(const size_t numThreads)
{
isInit = true;
#if defined(TARGET_X86_64)
daal::setSchedulerHandle(&_schedulerHandle);
#endif
daal::setNumberOfThreads(numThreads, &_globalControl);
}

Expand Down
3 changes: 3 additions & 0 deletions cpp/daal/src/threading/service_thread_pinner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ class thread_pinner_impl_t : public tbb::task_scheduler_observer
thread_pinner_impl_t::thread_pinner_impl_t(void (*read_topo)(int &, int &, int &, int **), void (*deleter)(void *))
: pinner_arena(nthreads = daal::threader_get_threads_number()), tbb::task_scheduler_observer(pinner_arena), topo_deleter(deleter)
{
#if defined(TARGET_X86_64)
pinner_arena.initialize();
#endif
do_pinning = (nthreads > 0) ? true : false;
is_pinning.set(0);

Expand Down
27 changes: 27 additions & 0 deletions cpp/daal/src/threading/threading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,33 @@ DAAL_EXPORT void _daal_tbb_task_scheduler_free(void *& globalControl)
}
}

DAAL_EXPORT void _daal_tbb_task_scheduler_handle_free(void *& schedulerHandle)
{
// Note: TBB 13 deletes task_scheduler_handle itself during the destruction of thread context

// #if defined(TARGET_X86_64)
// if (schedulerHandle)
// {
// delete reinterpret_cast<tbb::task_scheduler_handle *>(schedulerHandle);
// schedulerHandle = nullptr;
// }
// #endif
}

DAAL_EXPORT size_t _setSchedulerHandle(void ** schedulerHandle)
{
#if defined(TARGET_X86_64)
#if (TBB_INTERFACE_VERSION < 12120)
schedulerHandle = nullptr;
#else
*schedulerHandle = reinterpret_cast<void *>(new tbb::task_scheduler_handle(tbb::attach {}));
#endif
// It is necessary for initializing tbb in cases where DAAL does not use it.
tbb::task_arena {}.initialize();
#endif
return 0;
}

DAAL_EXPORT size_t _setNumberOfThreads(const size_t numThreads, void ** globalControl)
{
static tbb::spin_mutex mt;
Expand Down
Loading

0 comments on commit e523d06

Please sign in to comment.