diff --git a/.ci/env/openrng.sh b/.ci/env/openrng.sh index a4f4dfd2ed4..ac3800adbab 100755 --- a/.ci/env/openrng.sh +++ b/.ci/env/openrng.sh @@ -18,12 +18,18 @@ SCRIPT_PATH=$(readlink -f "${BASH_SOURCE[0]}") SCRIPT_DIR=$(dirname "${SCRIPT_PATH}") ONEDAL_DIR=$(readlink -f "${SCRIPT_DIR}/../..") OPENRNG_DEFAULT_SOURCE_DIR="${ONEDAL_DIR}/__work/openrng" +OPENRNG_DEFAULT_VERSION="v24.04" show_help() { echo "Usage: $0 [--help]" column -t -s":" <<< '--help:Display this information --rng-src:The path to an existing OpenRNG source dircetory. The source is cloned if this parameter is omitted --prefix:The path where OpenRNG will be installed +--CC :Path to the C compiler executable to use +--CXX :Path to the CXX compiler executable to use +--target-arch :Target architecture name for cross-compilation. Use only with '--cross-compile'. Must be one of [x86_64, aarch64] +--cross-compile:Indicates that we are doing cross compilation +--version :The version of OpenRNG to fetch and build. Must be a valid git reference in the upstream OpenRNG repo ' } @@ -37,6 +43,24 @@ while [[ $# -gt 0 ]]; do --prefix) PREFIX="$2" shift;; + --CXX) + CXX="$2" + shift;; + --CC) + CC="$2" + shift;; + --LD) + LD="$2" + shift;; + --target-arch) + target="$2" + shift;; + --cross-compile) + cross_compile="yes" + ;; + --version) + OPENRNG_VERSION="$2" + shift;; --help) show_help exit 0 @@ -49,21 +73,41 @@ while [[ $# -gt 0 ]]; do shift done -OPENRNG_DEFAULT_PREFIX="${ONEDAL_DIR}"/__deps/openrng +CXX="${CXX:-g++}" +CC="${CC:-gcc}" +target="${target:-aarch64}" +OPENRNG_VERSION="${OPENRNG_VERSION:-${OPENRNG_DEFAULT_VERSION}}" +OPENRNG_DEFAULT_PREFIX="${ONEDAL_DIR}/__deps/openrng" rng_prefix="${PREFIX:-${OPENRNG_DEFAULT_PREFIX}}" rng_src_dir=${rng_src_dir:-$OPENRNG_DEFAULT_SOURCE_DIR} if [[ ! -d "${rng_src_dir}" ]] ; then - git clone https://git.gitlab.arm.com/libraries/openrng.git "${rng_src_dir}" + git clone --depth 1 --branch "${OPENRNG_VERSION}" https://git.gitlab.arm.com/libraries/openrng.git "${rng_src_dir}" +fi + +if [ "${cross_compile}" == "yes" ]; then + cmake_options=(-DCMAKE_INSTALL_PREFIX="${rng_prefix}" + -DCMAKE_CXX_COMPILER="${CXX}" + -DCMAKE_C_COMPILER="${CC}" + -DCMAKE_SYSTEM_PROCESSOR="${target}" + -DCMAKE_SYSTEM_NAME=linux + -DCMAKE_BUILD_TYPE=Release + -DBUILD_TESTING=OFF + ) +else + cmake_options=(-DCMAKE_INSTALL_PREFIX="${rng_prefix}" + -DCMAKE_CXX_COMPILER="${CXX}" + -DCMAKE_C_COMPILER="${CC}" + -DCMAKE_BUILD_TYPE=Release + ) fi -echo $rng_src_dir -echo $rng_prefix pushd "${rng_src_dir}" rm -rf build mkdir build pushd build - cmake -DCMAKE_INSTALL_PREFIX="${rng_prefix}" ./../ + echo "${cmake_options[@]}" + cmake "${cmake_options[@]}" ./../ make install popd popd diff --git a/.ci/pipeline/ci.yml b/.ci/pipeline/ci.yml index b0d1433d9d5..8f823f74bc8 100755 --- a/.ci/pipeline/ci.yml +++ b/.ci/pipeline/ci.yml @@ -25,6 +25,7 @@ pr: variables: OPENBLAS_VERSION : 'v0.3.27' + OPENRNG_VERSION: 'v24.04' TBB_VERSION : 'v2021.10.0' VM_IMAGE : 'ubuntu-22.04' SYSROOT_OS: 'jammy' @@ -180,6 +181,90 @@ jobs: condition: failed() continueOnError: true +- job: 'LinuxMakeGNU_OpenBLAS_OpenRNG_ARM' + timeoutInMinutes: 0 + variables: + release.dir: '__release_lnx_gnu' + platform.type : 'lnxarm' + OPENBLAS_CACHE_DIR: $(Pipeline.Workspace)/openblas-aarch64-gnu + OPENRNG_CACHE_DIR: $(Pipeline.Workspace)/openrng-aarch64-gnu + TBB_CACHE_DIR: $(Pipeline.Workspace)/tbb-aarch64-gnu + pool: + vmImage: '$(VM_IMAGE)' + steps: + - script: | + .ci/env/apt.sh dev-base + displayName: 'apt-get and conda install' + - script: | + .ci/env/apt.sh gnu-cross-compilers aarch64 + displayName: 'arm-compiler installation' + - script: | + .ci/env/apt.sh qemu-apt + displayName: 'qemu-emulation installation' + - script: | + .ci/scripts/describe_system.sh + displayName: 'System info' + - task: Cache@2 + inputs: + key: '"gcc" | "aarch64" | "openblas" | "$(OPENBLAS_VERSION)" | "$(VM_IMAGE)" | "ILP64"' + path: $(OPENBLAS_CACHE_DIR) + cacheHitVar: OPENBLAS_RESTORED + - script: | + .ci/env/openblas.sh --target ARMV8 --host-compiler gcc --compiler aarch64-linux-gnu-gcc --cflags -march=armv8-a+sve --cross-compile --target-arch aarch64 --prefix $(OPENBLAS_CACHE_DIR) --version $(OPENBLAS_VERSION) + displayName: 'Build OpenBLAS' + condition: ne(variables.OPENBLAS_RESTORED, 'true') + - task: Cache@2 + inputs: + key: '"gcc" | "aarch64" | "openrng" | "$(OPENRNG_VERSION)" | "$(VM_IMAGE)"' + path: $(OPENRNG_CACHE_DIR) + cacheHitVar: OPENRNG_RESTORED + - script: | + .ci/env/openrng.sh --CC aarch64-linux-gnu-gcc --CXX aarch64-linux-gnu-g++ --cross-compile --target-arch aarch64 --version $(OPENRNG_VERSION) --prefix $(OPENRNG_CACHE_DIR) + displayName: 'Build OpenRNG' + condition: ne(variables.OPENRNG_RESTORED, 'true') + - task: Cache@2 + inputs: + key: '"gcc" | "aarch64" | "tbb" | "$(TBB_VERSION)" | "$(VM_IMAGE)"' + path: $(TBB_CACHE_DIR) + cacheHitVar: TBB_RESTORED + - script: | + .ci/env/tbb.sh --cross-compile --toolchain-file $(Build.Repository.LocalPath)/.ci/env/arm-gnu-crosscompile-toolchain.cmake --target-arch aarch64 --prefix $(TBB_CACHE_DIR) --version $(TBB_VERSION) + displayName: 'Build oneTBB' + condition: ne(variables.TBB_RESTORED, 'true') + - script: | + .ci/scripts/build.sh --compiler gnu --optimizations sve --target daal --backend-config ref --conda-env ci-env --cross-compile --use-openrng yes --plat lnxarm --blas-dir $(OPENBLAS_CACHE_DIR) --tbb-dir $(TBB_CACHE_DIR) --openrng-dir $(OPENRNG_CACHE_DIR) + displayName: 'make daal' + - script: | + .ci/scripts/build.sh --compiler gnu --optimizations sve --target onedal_c --backend-config ref --cross-compile --use-openrng yes --plat lnxarm --blas-dir $(OPENBLAS_CACHE_DIR) --tbb-dir $(TBB_CACHE_DIR) --openrng-dir $(OPENRNG_CACHE_DIR) + displayName: 'make onedal_c' + - task: PublishPipelineArtifact@1 + inputs: + artifactName: '$(platform.type) ARM OpenBLAS OpenRNG gnu build' + targetPath: '$(Build.Repository.LocalPath)/$(release.dir)' + displayName: 'Upload build artifacts' + continueOnError: true + - script: | + export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu + export QEMU_CPU="max,sve-default-vector-length=256" + export TBBROOT=$(TBB_CACHE_DIR) + export ARCH_ONEDAL=aarch64 + .ci/scripts/test.sh --test-kind examples --build-dir $(release.dir) --compiler gnu --interface daal/cpp --build-system cmake --platform lnxarm --cross-compile --backend ref --rng-backend openrng + displayName: 'daal/cpp examples' + - script: | + export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu + export QEMU_CPU="max,sve-default-vector-length=256" + export TBBROOT=$(TBB_CACHE_DIR) + export ARCH_ONEDAL=aarch64 + .ci/scripts/test.sh --test-kind examples --build-dir $(release.dir) --compiler gnu --interface oneapi/cpp --build-system cmake --platform lnxarm --cross-compile --backend ref --rng-backend openrng + displayName: 'oneapi/cpp examples' + - task: PublishPipelineArtifact@1 + inputs: + artifactName: '$(platform.type) fail' + targetPath: '$(Build.Repository.LocalPath)/$(release.dir)' + displayName: 'Uploading on fail' + condition: failed() + continueOnError: true + - job: 'LinuxMakeLLVM_OpenBLAS_ARM' timeoutInMinutes: 0 variables: diff --git a/.ci/scripts/build.sh b/.ci/scripts/build.sh index 0a62509c3a2..3d4aed5518f 100755 --- a/.ci/scripts/build.sh +++ b/.ci/scripts/build.sh @@ -35,6 +35,7 @@ show_help() { --blas-dir:The BLAS installation directory to use to build oneDAL with in the case that the backend is given as `ref`. If the installation directory does not exist, attempts to build this from source --tbb-dir:The TBB installation directory to use to build oneDAL with in the case that the backend is given as `ref`. If the installation directory does not exist, attempts to build this from source --use-openrng:Set this to yes if openrng is to be used as RNG backend. Use this only with the `ref` backend. +--openrng-dir:The directory in which openrng is installed. Only to be used with `ref` backend and `--use-openrng yes`. --sysroot:The sysroot to use, in the case that clang is used as the cross-compiler ' } @@ -67,6 +68,9 @@ while [[ $# -gt 0 ]]; do --blas-dir) BLAS_INSTALL_DIR=$(readlink -f "$2") shift;; + --openrng-dir) + OPENRNG_INSTALL_DIR=$(readlink -f "$2") + shift;; --tbb-dir) TBB_INSTALL_DIR=$(readlink -f "$2") shift;; @@ -190,18 +194,30 @@ elif [ "${backend_config}" == "ref" ]; then "${ONEDAL_DIR}"/.ci/env/openblas.sh "${openblas_options[@]}" fi export OPENBLASROOT="${ONEDAL_DIR}/__deps/openblas_${ARCH}" - if [ "${use_openrng}" == "yes" ]; then - echo "Sourcing ref(openrng) env" - if [ ! -d "${ONEDAL_DIR}"/__deps/openrng ]; then - echo "${ONEDAL_DIR}"/.ci/env/openrng.sh - "${ONEDAL_DIR}"/.ci/env/openrng.sh - fi - export OPENRNGROOT="${ONEDAL_DIR}"/__deps/openrng - fi else echo "Not supported backend env" fi +echo "Sourcing ref(openrng) env" +if [ "${backend_config}" == "ref" ] && [ "${use_openrng}" == "yes" ]; then + if [ ! -z "${OPENRNG_INSTALL_DIR}" ]; then + export OPENRNGROOT="${OPENRNG_INSTALL_DIR}" + elif [ "${ARCH}" != "arm" ]; then + echo "OpenRNG backend is currently only supported on ARM" + exit 1 + elif [ ! -d "${ONEDAL_DIR}"/__deps/openrng ]; then + openrng_options=(--target-arch aarch64) + if [ "${cross_compile}" == "yes" ] ; then + openrng_options+=(--cross-compile --CC aarch64-linux-gnu-gcc --CXX aarch64-linux-gnu-g++) + fi + echo "${ONEDAL_DIR}"/.ci/env/openrng.sh "${openrng_options[@]}" + "${ONEDAL_DIR}"/.ci/env/openrng.sh "${openrng_options[@]}" + export OPENRNGROOT="${ONEDAL_DIR}/__deps/openrng" + else + export OPENRNGROOT="${ONEDAL_DIR}/__deps/openrng" + fi +fi + # TBB setup if [[ ! -z "${TBB_INSTALL_DIR}" ]] ; then export TBBROOT="${TBB_INSTALL_DIR}" diff --git a/.ci/scripts/test.sh b/.ci/scripts/test.sh index 65d2d5d3e0c..f514a25de55 100755 --- a/.ci/scripts/test.sh +++ b/.ci/scripts/test.sh @@ -30,6 +30,7 @@ function show_help_text { --conda-env:The Conda environment to load --build-system:The type of build to perform, e.g. cmake --backend:The backend C library to use. Must be one of [mkl, ref] +--rng-backend:The RNG backend library to use. Must be one of [mkl, ref, openrng] --platform:Explicitly pass the platform. This is the same as is passed to the top-level oneDAL build script --cross-compile:Indicates whether cross-compilation is being performed ' @@ -67,6 +68,10 @@ while [[ $# -gt 0 ]]; do backend="$2" shift ;; + --rng-backend) + rng_backend="$2" + shift + ;; --platform) platform="$2" shift @@ -107,6 +112,11 @@ fi build_system=${build_system:-cmake} backend=${backend:-mkl} +if [ "${backend}" == "mkl" ]; then + rng_backend=mkl +else + rng_backend=${rng_backend:-ref} +fi if [ "${OS}" == "lnx" ]; then if [ -f /usr/share/miniconda/etc/profile.d/conda.sh ] ; then @@ -205,6 +215,11 @@ for link_mode in "${link_modes[@]}"; do if [ "${backend}" == "ref" ] ; then ref_backend="ON" + if [ "${rng_backend}" == "openrng" ]; then + openrng_backend="ON" + else + openrng_backend="OFF" + fi else ref_backend="OFF" fi @@ -213,7 +228,8 @@ for link_mode in "${link_modes[@]}"; do -S . -G "Unix Makefiles" -DONEDAL_LINK="${link_mode}" - -DREF_BACKEND="${ref_backend}") + -DREF_BACKEND="${ref_backend}" + -DOPENRNG_BACKEND="${openrng_backend}") if [ "${cross_compile}" == "yes" ] ; then # Set the cmake toolchain file to set up the cross-compilation diff --git a/dev/make/deps.ref.mk b/dev/make/deps.ref.mk index 9cfdcf719af..7319a343e52 100644 --- a/dev/make/deps.ref.mk +++ b/dev/make/deps.ref.mk @@ -42,6 +42,9 @@ ifeq ($(RNG_OPENRNG), yes) daaldep.rng_backend.lib := $(OPENRNGDIR.libia)/libopenrng.$a daaldep.math_backend.incdir += $(daaldep.rng_backend.incdir) + daaldep.math_backend_oneapi.incdir += $(daaldep.rng_backend.incdir) + daaldep.math_backend.seq += $(daaldep.rng_backend.lib) + daaldep.math_backend.thr += $(daaldep.rng_backend.lib) endif daaldep.math_backend.ext := $(daaldep.math_backend.thr) diff --git a/examples/daal/cpp/CMakeLists.txt b/examples/daal/cpp/CMakeLists.txt index ed41306e810..184c80bc14d 100644 --- a/examples/daal/cpp/CMakeLists.txt +++ b/examples/daal/cpp/CMakeLists.txt @@ -34,6 +34,7 @@ set_common_compiler_options() include_directories(source/utils) option(REF_BACKEND "Exclude not supported files for non-MKL backend" OFF) +option(OPENRNG_BACKEND "Exclude not supported files for ref+OpenRNG backend" OFF) set(EXCLUDE_LIST "source/utils/*" @@ -45,6 +46,15 @@ if(REF_BACKEND) ${EXCLUDE_LIST} "source/boosting/brownboost_dense_batch.cpp" ) + if(OPENRNG_BACKEND) + set(EXCLUDE_LIST + ${EXCLUDE_LIST} + "source/decision_forest/df_cls_default_dense_extratrees_batch.cpp" + "source/decision_forest/df_cls_hist_dense_extratrees_batch.cpp" + "source/decision_forest/df_reg_default_dense_batch.cpp" + "source/decision_forest/df_reg_hist_dense_batch.cpp" + ) + endif() endif() include("target_excludes.cmake") diff --git a/examples/oneapi/cpp/CMakeLists.txt b/examples/oneapi/cpp/CMakeLists.txt index 351d5313715..21a293c6493 100644 --- a/examples/oneapi/cpp/CMakeLists.txt +++ b/examples/oneapi/cpp/CMakeLists.txt @@ -33,6 +33,7 @@ set_common_compiler_options() include_directories(source) option(REF_BACKEND "Exclude not supported files for non-MKL backend" OFF) +option(OPENRNG_BACKEND "Exclude not supported files for ref+OpenRNG backend" OFF) # Initialize the EXCLUDE_LIST variable set(EXCLUDE_LIST @@ -45,7 +46,15 @@ if(REF_BACKEND) set(EXCLUDE_LIST ${EXCLUDE_LIST} "source/pca/*" -) + ) + if (OPENRNG_BACKEND) + set (EXCLUDE_LIST + ${EXCLUDE_LIST} + "source/decision_forest/df_reg_dense_batch.cpp" + "source/louvain/louvain_batch.cpp" + "source/connected_components/connected_components_batch.cpp" + ) + endif() endif() include("target_excludes.cmake")