Skip to content

Commit

Permalink
Adding OpenRNG Backend (#2871)
Browse files Browse the repository at this point in the history
* Added openrng backend

---------

Signed-off-by: Dhanus M Lal <Dhanus.MLal@fujitsu.com>
  • Loading branch information
DhanusML authored Oct 1, 2024
1 parent 8309ae3 commit 7f05e43
Show file tree
Hide file tree
Showing 9 changed files with 551 additions and 33 deletions.
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 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 @@ -186,6 +190,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 @@ -231,6 +243,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

0 comments on commit 7f05e43

Please sign in to comment.