Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ARM(SVE) CPU support with reference backend #2614

Merged
merged 80 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
270cd0f
Set up CI with Azure Pipelines
ajay-fuji Sep 19, 2023
1eb1c9d
[aarch64] include arch in compiler make files name and modify makefil…
ajay-fuji Dec 12, 2023
7107ec2
[aarch64] add compiler file for arm
ajay-fuji Dec 13, 2023
b7926f3
[aarch64] Introduced arm sve cpu and modify code to compile on arm
ajay-fuji Dec 13, 2023
9139d2b
[aarch64] buildable daal and oneapi_c. Fix build issue and update code
ajay-fuji Dec 13, 2023
d157592
[aarch64] Build config file updates
ajay-fuji Dec 13, 2023
864e15e
[aarch64] examples setup file update
ajay-fuji Dec 13, 2023
53fff91
[aarch64] add tbb build script for arm and update .ci scripts for arm…
ajay-fuji Dec 14, 2023
bc9d0cf
[aarch64] add copyright declaration
ajay-fuji Dec 14, 2023
737c083
[aarch64] fix - resuse of var cause path value conflict
ajay-fuji Dec 14, 2023
6328902
[aarch64] Add code to download/build tbb for arm and remove tbb.sh fo…
ajay-fuji Dec 15, 2023
ab24899
[aarch64] minor updates
ajay-fuji Dec 15, 2023
eb78bfc
fix ARCH value error for plat=mac32e
ajay-fuji Dec 18, 2023
034e0e4
Clang-format: run code format
ajay-fuji Dec 18, 2023
9bebaed
changed CPU_ARG to DAAL_BASE_CPU
rakshithgb-fujitsu Dec 29, 2023
637884c
Update build system with x86 as primary i/f and separate tbb build sc…
ajay-fuji Dec 29, 2023
9057a4e
Remove azure-pipeline test file.(unwanted)
ajay-fuji Dec 29, 2023
3452423
correction of arm file
rakshithgb-fujitsu Jan 2, 2024
aff1938
removed unwanted macros for arm and x86
rakshithgb-fujitsu Jan 2, 2024
712c3fe
added exit:
rakshithgb-fujitsu Jan 3, 2024
dd2f543
added DAAL_HOST_CPUID macro for env detection
rakshithgb-fujitsu Jan 3, 2024
dfddeab
removed sve definitions in jaccard, uses default path now for arm
rakshithgb-fujitsu Jan 3, 2024
dfe4b0d
added 0 shift to sve enum in policy
rakshithgb-fujitsu Jan 3, 2024
386b0e1
isolated arm and x86 structs
rakshithgb-fujitsu Jan 3, 2024
0bb39cc
changed to uintptr_t and consistent macro use
rakshithgb-fujitsu Jan 4, 2024
a916e25
removed sve function since its same as default path
rakshithgb-fujitsu Jan 4, 2024
1266cfe
removed sve function since its same as default path
rakshithgb-fujitsu Jan 4, 2024
7318d5f
changed to DAAL_CPU_TYPE, block size optimisation for arm will be don…
rakshithgb-fujitsu Jan 4, 2024
70fede4
documentation
rakshithgb-fujitsu Jan 4, 2024
4ac729e
rebased kernel files according to PR #2617
rakshithgb-fujitsu Jan 4, 2024
82d12b6
Renamed sub dir var to arch dir
ajay-fuji Jan 4, 2024
0e08af8
use string matching instead of regex
ajay-fuji Jan 4, 2024
206e364
using same -march value for gnu and clang for consitency
ajay-fuji Jan 4, 2024
118014c
Minor fix
ajay-fuji Jan 4, 2024
8ec8a2f
use CXX env variable for compiler selection and add help message flag -h
ajay-fuji Jan 4, 2024
275e448
clang-format
ajay-fuji Jan 5, 2024
ae52b5e
using builtin clz and population count function for arm arch
ajay-fuji Jan 8, 2024
4da3196
fix tbb-build script call for arm
ajay-fuji Jan 10, 2024
56d97fa
Update cpp/daal/include/algorithms/algorithm_container_base_batch.h
rakshithgb-fujitsu Jan 16, 2024
6b822fe
make tbb.sh generic
ajay-fuji Jan 17, 2024
fbad7de
Update deploy/local/dal
ajay-fuji Jan 17, 2024
d749850
introduced new macros TARGET_X86_64 and TARGET_ARM to isolate code th…
rakshithgb-fujitsu Jan 17, 2024
811baf4
new macros to isolate arch
rakshithgb-fujitsu Jan 18, 2024
d1c4c89
Update daal_defined.h with arm macros
ajay-fuji Jan 18, 2024
39a11bc
isolate common code into kernel_config
rakshithgb-fujitsu Jan 18, 2024
31931c3
Update var_lnx.sh to not depend on identify_os.sh and use native code…
ajay-fuji Jan 17, 2024
b58708d
Update prepare_dal_nuget.sh to have single platform value for x64 and…
ajay-fuji Jan 18, 2024
0631fc0
Update openblas.sh to run non-interactively
ajay-fuji Jan 18, 2024
8cb5d35
new sub directories for archs and isolation of daal_kernel code based…
rakshithgb-fujitsu Jan 18, 2024
caf85cd
adding new folders
rakshithgb-fujitsu Jan 18, 2024
2321a99
clang-format
ajay-fuji Jan 19, 2024
0366fb2
revert isolation of arch components, fix ci bug temporarily
rakshithgb-fujitsu Jan 19, 2024
02cc4a3
clang-format
rakshithgb-fujitsu Jan 19, 2024
ef840fd
policy fix
rakshithgb-fujitsu Jan 19, 2024
f91ce0c
clang format fixes, todo comment
rakshithgb-fujitsu Jan 19, 2024
9ac2c65
fix windows build error
ajay-fuji Jan 23, 2024
2801ac0
Update test.sh with exit condition for unknown architecture
ajay-fuji Jan 23, 2024
2f51bdb
typo fix
ajay-fuji Jan 24, 2024
05c0d99
Fix CMakeConfig for windows
ajay-fuji Jan 24, 2024
1049fb7
Update deploy/local/vars_lnx.sh
rakshithgb-fujitsu Jan 25, 2024
48914e1
Update deploy/local/vars_lnx.sh
rakshithgb-fujitsu Jan 25, 2024
875e349
Update deploy/local/vars_lnx.sh
rakshithgb-fujitsu Jan 25, 2024
5e02867
comments clean up
rakshithgb-fujitsu Jan 25, 2024
f096211
Update cpp/daal/src/algorithms/kernel_inst_arm.h
rakshithgb-fujitsu Jan 25, 2024
69fdade
Update cpp/daal/src/threading/export_lnxarm.ref.def
rakshithgb-fujitsu Jan 25, 2024
70f5b3a
split to arch files
rakshithgb-fujitsu Jan 25, 2024
8b24d4d
Update cpp/daal/include/services/internal/daal_kernel_defines.h
rakshithgb-fujitsu Jan 26, 2024
bc0bd16
bazel build fixes
rakshithgb-fujitsu Jan 26, 2024
1b22c0d
Update dev/make/cmplr.clang.ref.arm.mk
rakshithgb-fujitsu Jan 26, 2024
d83725b
Update cpp/daal/include/services/internal/x86_64/x86_64_kernel_defines.h
rakshithgb-fujitsu Jan 26, 2024
067aef3
Update dev/bazel/config/cpudetect.cpp
rakshithgb-fujitsu Jan 27, 2024
7bf3655
ci fixes
rakshithgb-fujitsu Jan 27, 2024
163fd52
cla changes
rakshithgb-fujitsu Jan 30, 2024
1a583e7
change cpudetect to try and fix internal ci
rakshithgb-fujitsu Feb 5, 2024
a765d97
cla changes
rakshithgb-fujitsu Feb 7, 2024
de34cf7
arch dir changes
rakshithgb-fujitsu Feb 8, 2024
b96ff60
trying cmake examples revert...
ethanglaser Feb 9, 2024
e53115d
cmake reversions
ethanglaser Feb 9, 2024
b86d408
reverting previous 2 commits
ethanglaser Feb 9, 2024
7fbf4ed
Merge branch 'oneapi-src:main' into enable-arm-build-with-ref-backend
rakshithgb-fujitsu Feb 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/env/openblas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#===============================================================================

sudo apt-get update
sudo apt-get install build-essential gcc gfortran
sudo apt-get -y install build-essential gcc gfortran
git clone https://github.com/xianyi/OpenBLAS.git
CoreCount=$(lscpu -p | grep -Ev '^#' | wc -l)
pushd OpenBLAS
Expand Down
83 changes: 83 additions & 0 deletions .ci/env/tbb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
#===============================================================================
# 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.
#===============================================================================

# Function to display help
show_help() {
echo "Usage: $0 [-h]"
echo " -h Display this information"
echo " Set CC and CXX environment variables to change the compiler. Default is GNU."
}

# Check for command-line options
while getopts ":h" opt; do
case $opt in
h)
show_help
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
show_help
exit 1
;;
esac
done

# Set default values for CXX and CC
CXX="${CXX:-g++}"
CC="${CC:-gcc}"

echo "CXX is set to: $CXX"
echo "CC is set to: $CC"

TBB_VERSION="v2021.10.0"

arch=$(uname -m)
if [ "${arch}" == "x86_64" ]; then
arch_dir="intel64"
elif [ "${arch}" == "aarch64" ]; then
arch_dir="arm"
else
arch_dir=${arch}
fi

sudo apt-get update
sudo apt-get install build-essential gcc gfortran cmake -y
git clone --depth 1 --branch ${TBB_VERSION} https://github.com/oneapi-src/oneTBB.git onetbb-src

CoreCount=$(lscpu -p | grep -Ev '^#' | wc -l)
ajay-fuji marked this conversation as resolved.
Show resolved Hide resolved

rm -rf __deps/tbb
pushd onetbb-src
mkdir build
pushd build
cmake -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_BUILD_TYPE=Release -DTBB_TEST=OFF -DTBB_STRICT_PROTOTYPES=OFF -DCMAKE_INSTALL_PREFIX=../../__deps/tbb ..
make -j${CoreCount}
make install
popd
popd
rm -rf onetbb-src

pushd __deps/tbb
mkdir -p lnx
mv lib/ lnx/
mv include/ lnx/
pushd lnx
mkdir -p lib/${arch_dir}/gcc4.8
mv lib/libtbb* lib/${arch_dir}/gcc4.8
popd
popd
2 changes: 1 addition & 1 deletion .ci/scripts/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Buil
echo make %1 -j%CPUCOUNT% COMPILER=%2 PLAT=win32e REQCPU=%3
make %1 -j%CPUCOUNT% COMPILER=%2 PLAT=win32e REQCPU=%3

cmake -DINSTALL_DIR=__release_win_vc\daal\latest\lib\cmake\oneDAL -P cmake\scripts\generate_config.cmake
cmake -DINSTALL_DIR=__release_win_vc\daal\latest\lib\cmake\oneDAL -DARCH_DIR=intel64 -P cmake\scripts\generate_config.cmake
20 changes: 20 additions & 0 deletions .ci/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#! /bin/bash
#===============================================================================
# Copyright 2019 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 @@ -47,7 +48,17 @@ PLATFORM=$(bash dev/make/identify_os.sh)
OS=${PLATFORM::3}
ARCH=${PLATFORM:3:3}

if [[ "${ARCH}" == "32e" ]]
then
optimizations=${optimizations:-avx2}
elif [[ "${ARCH}" == "arm" ]]
then
optimizations=${optimizations:-sve}
else
echo "Unknown architecture '${ARCH}'"
exit 1
fi

backend_config=${backend_config:-mkl}
GLOBAL_RETURN=0

Expand Down Expand Up @@ -97,7 +108,16 @@ elif [ "${backend_config}" == "ref" ]; then
else
echo "Not supported backend env"
fi

#TBB setup
if [[ "${ARCH}" == "32e" ]]
then
$(pwd)/dev/download_tbb.sh
elif [[ "${ARCH}" == "arm" ]]
then
$(pwd)/.ci/env/tbb.sh
fi

echo "Calling make"
make ${target:-daal_c} ${make_op} \
COMPILER=${compiler} \
Expand Down
15 changes: 13 additions & 2 deletions .ci/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#! /bin/bash
#===============================================================================
# Copyright 2019 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 @@ -54,7 +55,17 @@ TESTING_RETURN=0
PLATFORM=$(bash dev/make/identify_os.sh)
OS=${PLATFORM::3}
ARCH=${PLATFORM:3:3}
full_arch=intel64
if [ "$ARCH" == "32e" ]; then
full_arch=intel64
arch_dir=intel_intel64
elif [ "$ARCH" == "arm" ]; then
full_arch=arm
arch_dir=arm_aarch64
else
echo "Unknown architecture ${ARCH} detected for platform ${PLATFORM}"
exit 1
fi

build_system=${build_system:-cmake}
backend=${backend:-mkl}

Expand Down Expand Up @@ -161,7 +172,7 @@ for link_mode in ${link_modes}; do
fi
output_result=
err=
cmake_results_dir="_cmake_results/intel_intel64_${lib_ext}"
cmake_results_dir="_cmake_results/${arch_dir}_${lib_ext}"
for p in ${cmake_results_dir}/*; do
e=$(basename "$p")
${p} 2>&1 > ${e}.res
Expand Down
3 changes: 2 additions & 1 deletion cmake/scripts/generate_config.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#===============================================================================
# Copyright 2021 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 @@ -19,7 +20,7 @@ set(DAL_ROOT_REL_PATH "../../..")
set(INC_REL_PATH "include")
set(LIB_REL_PATH "lib")
set(DLL_REL_PATH "redist")
set(SUB_DIR "intel64")
set(ARCH_DIR_ONEDAL "${ARCH_DIR_ONEDAL}")

# Parse version info if possible
if (NOT "$ENV{DALROOT}" STREQUAL "")
Expand Down
4 changes: 2 additions & 2 deletions cmake/templates/oneDALConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ foreach (_dal_component ${DAL_LIBS})
find_library(
_dal_lib
NAMES "${LIB_PREFIX}${_dal_component}${LIB_EXT}"
PATH_SUFFIXES "lib/intel64"
PATH_SUFFIXES "lib/@ARCH_DIR_ONEDAL@"
PATHS "${_dal_root}")
elseif (${ONEDAL_LINK} STREQUAL "dynamic")
add_library(oneDAL::${_dal_component} SHARED IMPORTED)
find_library(
_dal_lib
NAMES "${LIB_PREFIX}${_dal_component}${DLL_EXT}"
PATH_SUFFIXES "lib/intel64"
PATH_SUFFIXES "lib/@ARCH_DIR_ONEDAL@"
PATHS "${_dal_root}")
endif()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* file: algorithm_container_base_batch.h */
/*******************************************************************************
* Copyright 2014 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 @@ -142,11 +143,18 @@ class AlgorithmContainerImpl<batch> : public AlgorithmContainer<batch>
* \tparam sse42Container Implementation for Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2)
* \tparam avx2Container Implementation for Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2)
* \tparam avx512Container Implementation for Intel(R) Xeon(R) processors based on Intel AVX-512
ajay-fuji marked this conversation as resolved.
Show resolved Hide resolved
* \tparam sve Implementation for ARM processors based on Arm Scalable Vector Extension
*/

#if defined(TARGET_X86_64)
template <typename sse2Container DAAL_KERNEL_SSE42_ONLY(typename sse42Container) DAAL_KERNEL_AVX2_ONLY(typename avx2Container)
DAAL_KERNEL_AVX512_ONLY(typename avx512Container)>
class DAAL_EXPORT AlgorithmDispatchContainer<batch, sse2Container DAAL_KERNEL_SSE42_ONLY(sse42Container) DAAL_KERNEL_AVX2_ONLY(avx2Container)
DAAL_KERNEL_AVX512_ONLY(avx512Container)> : public AlgorithmContainerImpl<batch>
#elif defined(TARGET_ARM)
template <typename SVEContainer DAAL_KERNEL_SVE_ONLY(typename sveContainer)>
class DAAL_EXPORT AlgorithmDispatchContainer<batch, SVEContainer DAAL_KERNEL_SVE_ONLY(sveContainer)> : public AlgorithmContainerImpl<batch>
#endif
{
public:
/**
Expand Down
19 changes: 16 additions & 3 deletions cpp/daal/include/algorithms/algorithm_container_base_common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* file: algorithm_container_base_common.h */
/*******************************************************************************
* Copyright 2014 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,6 +25,8 @@
#ifndef __ALGORITHM_CONTAINER_BASE_COMMON_H__
#define __ALGORITHM_CONTAINER_BASE_COMMON_H__

#include "services/daal_defines.h"

#include "algorithms/algorithm_container_base.h"
#include "services/error_handling.h"
#include "services/internal/gpu_support_checker.h"
Expand Down Expand Up @@ -53,8 +56,13 @@ namespace interface1
* \tparam avx2Container Implementation for Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2)
* \tparam avx512Container Implementation for Intel(R) Xeon(R) processors based on Intel AVX-512
*/

#if defined(TARGET_X86_64)
template <ComputeMode mode, typename sse2Container DAAL_KERNEL_SSE42_ONLY(typename sse42Container) DAAL_KERNEL_AVX2_ONLY(typename avx2Container)
DAAL_KERNEL_AVX512_ONLY(typename avx512Container)>
#elif defined(TARGET_ARM)
template <ComputeMode mode, typename SVEContainer DAAL_KERNEL_SVE_ONLY(typename sveContainer)>
#endif
class DAAL_EXPORT AlgorithmDispatchContainer : public AlgorithmContainerImpl<mode>
{
public:
Expand Down Expand Up @@ -99,10 +107,15 @@ class DAAL_EXPORT AlgorithmDispatchContainer : public AlgorithmContainerImpl<mod
AlgorithmDispatchContainer & operator=(const AlgorithmDispatchContainer &);
};

#define __DAAL_ALGORITHM_CONTAINER(Mode, ContainerTemplate, ...) \
algorithms::AlgorithmDispatchContainer<Mode, ContainerTemplate<__VA_ARGS__, sse2> DAAL_KERNEL_SSE42_CONTAINER(ContainerTemplate, __VA_ARGS__) \
DAAL_KERNEL_AVX2_CONTAINER(ContainerTemplate, __VA_ARGS__) \
#if defined(TARGET_X86_64)
#define __DAAL_ALGORITHM_CONTAINER(Mode, ContainerTemplate, ...) \
algorithms::AlgorithmDispatchContainer<Mode, ContainerTemplate<__VA_ARGS__, sse2> DAAL_KERNEL_SSE42_CONTAINER( \
ContainerTemplate, __VA_ARGS__) DAAL_KERNEL_AVX2_CONTAINER(ContainerTemplate, __VA_ARGS__) \
DAAL_KERNEL_AVX512_CONTAINER(ContainerTemplate, __VA_ARGS__)>
#elif defined(TARGET_ARM)
#define __DAAL_ALGORITHM_CONTAINER(Mode, ContainerTemplate, ...) \
algorithms::AlgorithmDispatchContainer<Mode, ContainerTemplate<__VA_ARGS__, sve> DAAL_KERNEL_SVE_CONTAINER(ContainerTemplate, __VA_ARGS__)>
#endif

/** @} */
} // namespace interface1
Expand Down
11 changes: 11 additions & 0 deletions cpp/daal/include/services/daal_defines.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* file: daal_defines.h */
/*******************************************************************************
* Copyright 2014 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 @@ -28,6 +29,14 @@

#include <cstddef> // for size_t

#if defined(__x86_64__) || defined(__x86_64) || defined(__amd64) || defined(_M_AMD64)
#define TARGET_X86_64
#endif

#if defined(__ARM_ARCH) || defined(__aarch64__)
#define TARGET_ARM
#endif

#if (defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)) && !defined(SYCL_LANGUAGE_VERSION)
#define DAAL_INTEL_CPP_COMPILER
#endif
Expand Down Expand Up @@ -65,6 +74,8 @@
#if !defined(DAAL_INT)
#if defined(_WIN64) || defined(__x86_64__)
#define DAAL_INT __int64
#elif defined(TARGET_ARM)
#define DAAL_INT __int64
#else
#define DAAL_INT __int32
#endif
Expand Down
18 changes: 16 additions & 2 deletions cpp/daal/include/services/env_detect.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* file: env_detect.h */
/*******************************************************************************
* Copyright 2014 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 @@ -42,11 +43,16 @@ namespace daal
*/
enum CpuType
{
#if defined(TARGET_X86_64)
sse2 = 0, /*!< Intel(R) Streaming SIMD Extensions 2 (Intel(R) SSE2) */
sse42 = 2, /*!< Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) */
avx2 = 4, /*!< Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) */
avx512 = 6, /*!< Intel(R) Xeon(R) processors based on Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512) */
lastCpuType = avx512
#elif defined(TARGET_ARM)
sve = 0, /*!< ARM(R) processors based on Arm's Scalable Vector Extension (SVE) */
lastCpuType = sve
#endif
};

namespace services
Expand Down Expand Up @@ -91,7 +97,12 @@ class DAAL_EXPORT Environment : public Base
enum CpuTypeEnable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CpuTypeEnable is only used in a few locations, and it feels like it is duplicating some of the other definitions. Maybe something to have a look at in another pull request, but as there is already the CpuType enum defined in this file, and it could be changed to have the same functionality as required here by defining an extra item in the enum:

enum CpuType
{
#ifdef __ARM_ARCH
    sve         = 0, /*!< ARM processors based on Arm's Scalable Vector Extension (SVE) */
    lastCpuType = sve,
#else
    sse2        = 0, /*!< Intel(R) Streaming SIMD Extensions 2 (Intel(R) SSE2) */
    sse42       = 2, /*!< Intel(R) Streaming SIMD Extensions 4.2 (Intel(R) SSE4.2) */
    avx2        = 4, /*!< Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) */
    avx512      = 6, /*!< Intel(R) Xeon(R) processors based on Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512) */
    lastCpuType = avx512,
#endif
    defaultCpu
};

And then, where necessary, we can use the identifier for the default CPU instead. @napetrov what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vika-F might be remember more, why there is CpuType and CpuTypeEnable.

I think this is along lines of - we might use not matching codepath on cpu. i.e. cpu would be avx512 but we will be forcing sse2 ISA.

{
cpu_default = 0, /*!< Default processor type */
avx512 = 2 /*!< Intel(R) Xeon(R) processors based on Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512) \DAAL_DEPRECATED */

#if defined(TARGET_X86_64)
avx512 = 2 /*!< Intel(R) Xeon(R) processors based on Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512) \DAAL_DEPRECATED */
#elif defined(TARGET_ARM)
sve = 2, /*!< ARM(R) processors based on Arm's Scalable Vector Extension (SVE) */
#endif
};

/**
Expand Down Expand Up @@ -167,7 +178,10 @@ class DAAL_EXPORT Environment : public Base
_executionContext = internal::ImplAccessor::getImplPtr<services::internal::sycl::ExecutionContextIface>(ctx);
}

services::internal::sycl::ExecutionContextIface & getDefaultExecutionContext() { return *_executionContext; }
services::internal::sycl::ExecutionContextIface & getDefaultExecutionContext()
{
return *_executionContext;
}

private:
Environment();
Expand Down
Loading
Loading