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 Cross Compilation of Arm SVE on x86 Cl (Binary only) #2691

Merged
merged 26 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ea9fba9
adding options in apt for cross compilers
rakshithgb-fujitsu Feb 12, 2024
131f3db
modifying build.sh
rakshithgb-fujitsu Feb 12, 2024
3111999
adding help option
rakshithgb-fujitsu Feb 12, 2024
e245c4b
support openblas cross compile for arm
rakshithgb-fujitsu Feb 13, 2024
7e59bd7
adding cross compile support for tbb
rakshithgb-fujitsu Feb 13, 2024
9067913
minor changes
rakshithgb-fujitsu Feb 13, 2024
854f5e7
arm cross compile ci working
rakshithgb-fujitsu Feb 15, 2024
d6d4b66
Update ci.yml temp
rakshithgb-fujitsu Feb 15, 2024
8b0b697
fix identation
rakshithgb-fujitsu Feb 15, 2024
47e2b0f
fix identation
rakshithgb-fujitsu Feb 15, 2024
c6eb05e
added cla, comments and build cmd fix
rakshithgb-fujitsu Mar 6, 2024
9550371
making openblas build cmd uniform
rakshithgb-fujitsu Mar 6, 2024
736aba2
comment fix
rakshithgb-fujitsu Mar 6, 2024
914fddb
cla
rakshithgb-fujitsu Mar 8, 2024
e14ea0e
fix - examples cross compile build
ajay-fuji Mar 8, 2024
08ea467
Update env scripts
ajay-fuji Mar 11, 2024
ca493dc
Update ci.yml and build.sh
ajay-fuji Mar 13, 2024
56522d1
Remove examples build task from ARM_OPENBLAS build Job
ajay-fuji Mar 14, 2024
c329f85
Update .ci/env/arm-toolchain.cmake
ajay-fuji Mar 15, 2024
000296c
review comment updates
rakshithgb-fujitsu Mar 20, 2024
af8409b
changed task name
rakshithgb-fujitsu Mar 20, 2024
35bbf7b
rename toolchain
rakshithgb-fujitsu Mar 20, 2024
f1d6353
Merge branch 'oneapi-src:main' into arm-sve-ci
rakshithgb-fujitsu Mar 21, 2024
c7ba868
Merge branch 'oneapi-src:main' into arm-sve-ci
rakshithgb-fujitsu Mar 22, 2024
90bfb08
Update tbb.sh
ajay-fuji Mar 22, 2024
24326ee
bug fix in cpu_infor_arm_impl
rakshithgb-fujitsu Mar 22, 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
10 changes: 9 additions & 1 deletion .ci/env/apt.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#===============================================================================
# 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 Down Expand Up @@ -54,12 +55,19 @@ function install_dev-base-conda {
conda env create -f .ci/env/environment.yml
}

function install_arm-cross-compilers {
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gfortran-aarch64-linux-gnu
}

if [ "${component}" == "dpcpp" ]; then
add_repo
install_dpcpp
elif [ "${component}" == "mkl" ]; then
add_repo
install_mkl
elif [ "${component}" == "arm-compiler" ]; then
update
install_arm-cross-compilers
elif [ "${component}" == "clang-format" ]; then
update
install_clang-format
Expand All @@ -69,6 +77,6 @@ elif [ "${component}" == "dev-base" ]; then
install_dev-base-conda
else
echo "Usage:"
echo " $0 [dpcpp|mkl|clang-format|dev-base]"
echo " $0 [dpcpp|mkl|arm-compiler|clang-format|dev-base]"
exit 1
fi
38 changes: 38 additions & 0 deletions .ci/env/arm-gcc-crosscompile-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#===============================================================================
# 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.
#===============================================================================


# Set the CMake system name to inform CMake that we are cross-compiling
set(CMAKE_SYSTEM_NAME Linux)

# Set the cross-compilation prefix for the toolchain
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)

# Set the target architecture
set(CMAKE_SYSTEM_PROCESSOR aarch64)

# Set compiler flags and options for ARMv8-A architecture with SVE
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a+sve")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8-a+sve")

# Specify the root directory of the cross-compiler toolchain
set(CMAKE_FIND_ROOT_PATH / /usr/bin)

# Specify the search paths for libraries and headers
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
40 changes: 39 additions & 1 deletion .ci/env/openblas.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#===============================================================================
# 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 @@ -15,12 +16,49 @@
# limitations under the License.
#===============================================================================

while [[ $# -gt 0 ]]; do
key="$1"

case $key in
--target)
target="$2"
shift;;
--compiler)
compiler="$2"
shift;;
--host_compiler)
host_compiler="$2"
shift;;
--cflags)
cflags="$2"
shift;;
--cross_compile)
cross_compile="yes"
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
shift
done

target=${target:-ARMV8}
host_compiler=${host_compiler:-gcc}
compiler=${compiler:-aarch64-linux-gnu-gcc}
cflags=${cflags:--march=armv8-a+sve}

sudo apt-get update
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
make clean
make -j${CoreCount} NO_FORTRAN=1
if [ "${cross_compile}" == "yes" ]; then
echo make -j${CoreCount} TARGET=${target} HOSTCC=${host_compiler} CC=${compiler} NO_FORTRAN=1 USE_OPENMP=0 USE_THREAD=0 USE_LOCKING=1 CFLAGS=\"${cflags}\"
make -j${CoreCount} TARGET=${target} HOSTCC=${host_compiler} CC=${compiler} NO_FORTRAN=1 USE_OPENMP=0 USE_THREAD=0 USE_LOCKING=1 CFLAGS=\"${cflags}\"
else
make -j${CoreCount} NO_FORTRAN=1 USE_OPENMP=0 USE_THREAD=0 USE_LOCKING=1
fi
make install PREFIX=../__deps/open_blas
popd
106 changes: 75 additions & 31 deletions .ci/env/tbb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,73 @@

# 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."
echo "Usage: $0 [--help]"
echo -e " --help \t\t\tDisplay this information"
echo -e " --CC <bin path> \t\tPass full path to c compiler. Default is GNU gcc."
echo -e " --CXX <bin path> \t\tPass full path to c++ compiler. Default is GNU g++."
echo -e " --cross-compile <flag> \tPass this flag if cross-compiling."
echo -e " --toolchain_file <file> \tPass path to cmake toolchain file. Default is './.ci/env/arm-toolchain.cmake'. Use only with '--cross_compile'"
echo -e " --target_arch <name> \t\tTarget architecture name (i.e aarch64, x86_64, etc.) for cross-compilation. Use only with '--cross_compile'"
}

# 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
;;
while [[ $# -gt 0 ]]; do
key="$1"

case $key in
--CXX)
CXX="$2"
shift;;
--CC)
CC="$2"
shift;;
--toolchain_file)
toolchain_file="$2"
shift;;
--target_arch)
target_arch="$2"
shift;;
--help)
show_help
exit 0
;;
--cross_compile)
cross_compile="yes"
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
shift
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"
set_arch_dir() {
local arch="$1"
local arch_dir=""
if [ "$arch" == "x86_64" ]; then
arch_dir="intel64"
elif [ "$arch" == "aarch64" ]; then
arch_dir="arm"
else
echo "Unsupported arch, quitting tbb build script."
exit 1
fi
echo "${arch_dir}"
}

arch=$(uname -m)
if [ "${arch}" == "x86_64" ]; then
arch_dir="intel64"
elif [ "${arch}" == "aarch64" ]; then
arch_dir="arm"
if [ "${cross_compile}" == "yes" ]; then
toolchain_file=${toolchain_file:-$(pwd)/.ci/env/arm-toolchain.cmake}
if [ ! -f ${toolchain_file} ]; then
echo "'${toolchain_file}' file does not exists. Please specify using '--toolchain_file=<path>' argument."
exit 1
fi
target_arch=${target_arch:-aarch64}
else
arch_dir=${arch}
target_arch=${target_arch:-$(uname -m)}
fi
arch_dir=${arch_dir:-$(set_arch_dir "${target_arch}")}

TBB_VERSION="v2021.10.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't feel like the TBB version should be hard-coded. This should be picked up from the pkgconfig file in the installation


sudo apt-get update
sudo apt-get install build-essential gcc gfortran cmake -y
Expand All @@ -63,10 +93,24 @@ CoreCount=$(lscpu -p | grep -Ev '^#' | wc -l)

rm -rf __deps/tbb
pushd onetbb-src
rm -rf build
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}
if [ "${cross_compile}" == "yes" ]; then
unset CXX
rakshithgb-fujitsu marked this conversation as resolved.
Show resolved Hide resolved
unset CC
echo cmake -DCMAKE_TOOLCHAIN_FILE=${toolchain_file} -DCMAKE_BUILD_TYPE=Release -DTBB_TEST=OFF -DTBB_STRICT_PROTOTYPES=OFF -DCMAKE_INSTALL_PREFIX=../../__deps/tbb ..
cmake -DCMAKE_TOOLCHAIN_FILE=${toolchain_file} -DCMAKE_BUILD_TYPE=Release -DTBB_TEST=OFF -DTBB_STRICT_PROTOTYPES=OFF -DCMAKE_INSTALL_PREFIX=../../__deps/tbb ..
else
# 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"
cmake -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_CC_COMPILER=${CC} -DCMAKE_BUILD_TYPE=Release -DTBB_TEST=OFF -DTBB_STRICT_PROTOTYPES=OFF -DCMAKE_INSTALL_PREFIX=../../__deps/tbb ..
fi
make -j${CoreCount}
make install
popd
popd
Expand Down
40 changes: 39 additions & 1 deletion .ci/pipeline/ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright contributors to the oneDAL project
# C/C++ with GCC
# Build your C/C++ project with GCC using make.
# Add steps that publish test results, save build artifacts, deploy, and more:
Expand Down Expand Up @@ -83,7 +84,44 @@ jobs:
condition: failed()
continueOnError: true

- job: 'LinuxMakeGNU_OpenBLAS'
- job: 'LinuxMakeGNU_OpenBLAS_ARM'
rakshithgb-fujitsu marked this conversation as resolved.
Show resolved Hide resolved
timeoutInMinutes: 0
variables:
release.dir: '__release_lnx_gnu'
platform.type : 'lnxarm'
pool:
vmImage: 'ubuntu-22.04'
steps:
- script: |
.ci/env/apt.sh dev-base
displayName: 'apt-get and conda install'
- script: |
.ci/env/apt.sh arm-compiler
displayName: 'arm-compiler installation'
- script: |
.ci/scripts/describe_system.sh
displayName: 'System info'
- script: |
.ci/scripts/build.sh --compiler gnu --optimizations sve --target daal --backend_config ref --conda-env ci-env --cross_compile --arch arm --plat lnxarm
displayName: 'make daal'
- script: |
.ci/scripts/build.sh --compiler gnu --optimizations sve --target onedal_c --backend_config ref --cross_compile --arch arm --plat lnxarm
displayName: 'make onedal_c'
- task: PublishPipelineArtifact@1
inputs:
artifactName: '$(platform.type) ARM OpenBLAS build'
targetPath: '$(Build.Repository.LocalPath)/$(release.dir)'
displayName: 'Upload build artifacts'
continueOnError: true
- task: PublishPipelineArtifact@1
inputs:
artifactName: '$(platform.type) fail'
targetPath: '$(Build.Repository.LocalPath)/$(release.dir)'
displayName: 'Uploading on fail'
condition: failed()
continueOnError: true

- job: 'LinuxMakeGNU_OpenBLAS_x86'
timeoutInMinutes: 0
variables:
release.dir: '__release_lnx_gnu'
Expand Down
Loading