Skip to content

Commit

Permalink
Added ci jobs for openrng openblas arm build
Browse files Browse the repository at this point in the history
* Modified the build script to enable cross compile
* Fixed static link build with openrng backend
* Extended exclude list for openrng build

Signed-off-by: Dhanus M Lal <[email protected]>
  • Loading branch information
DhanusML committed Nov 8, 2024
1 parent 84ec51f commit 3e38f9f
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 15 deletions.
54 changes: 49 additions & 5 deletions .ci/env/openrng.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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>:Path to the C compiler executable to use
--CXX <path>:Path to the CXX compiler executable to use
--target-arch <name>: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 <version string>:The version of OpenRNG to fetch and build. Must be a valid git reference in the upstream OpenRNG repo
'
}

Expand All @@ -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
Expand All @@ -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
85 changes: 85 additions & 0 deletions .ci/pipeline/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down
32 changes: 24 additions & 8 deletions .ci/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
'
}
Expand Down Expand Up @@ -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;;
Expand Down Expand Up @@ -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}"
Expand Down
18 changes: 17 additions & 1 deletion .ci/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
'
Expand Down Expand Up @@ -67,6 +68,10 @@ while [[ $# -gt 0 ]]; do
backend="$2"
shift
;;
--rng-backend)
rng_backend="$2"
shift
;;
--platform)
platform="$2"
shift
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions dev/make/deps.ref.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions examples/daal/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"
Expand All @@ -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")
Expand Down
11 changes: 10 additions & 1 deletion examples/oneapi/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 3e38f9f

Please sign in to comment.