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

Adding OpenRNG Backend #2871

Merged
merged 6 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
69 changes: 69 additions & 0 deletions .ci/env/openrng.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/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.
#===============================================================================

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"

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
'
}

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

case $key in
--rng-src)
rng_src_dir="$2"
shift;;
--prefix)
PREFIX="$2"
shift;;
--help)
show_help
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
shift
done

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}"
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}" ./../
make install
popd
popd
16 changes: 16 additions & 0 deletions .ci/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ show_help() {
--plat:The platform to build for. This is passed to the oneDAL top level Makefile
--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 with the `ref` backend.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
--use-openrng:Set this to yes if openrng is to be used as RNG backend. Use this with the `ref` backend.
--use-openrng:Set this to yes if openrng is to be used as RNG backend. Use this only with the `ref` backend.

--sysroot:The sysroot to use, in the case that clang is used as the cross-compiler
'
}
Expand Down Expand Up @@ -72,6 +73,9 @@ while [[ $# -gt 0 ]]; do
--sysroot)
sysroot="$2"
shift;;
--use-openrng)
use_openrng="$2"
shift;;
--help)
show_help
exit 0
Expand Down Expand Up @@ -187,6 +191,14 @@ 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
Expand Down Expand Up @@ -232,6 +244,10 @@ if [ "${cross_compile}" == "yes" ] && [ "${compiler}" == "clang" ] ; then
make_options+=(SYSROOT="${sysroot}")
fi

if [ "${use_openrng}" == "yes" ]; then
make_options+=(RNG_BACKEND=openrng)
fi

echo "Calling make"
echo "CXX=$CXX"
echo "CC=$CC"
Expand Down
Loading
Loading