forked from ARM-software/Tool-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ARM-software#289 from aditew01/aditew01/update_ope…
…nblas
- Loading branch information
Showing
4 changed files
with
137 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
|
||
# ******************************************************************************* | ||
# Copyright 2025 Arm Limited and affiliates. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# 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. | ||
# ******************************************************************************* | ||
|
||
function git-shallow-clone { | ||
( | ||
repo_name=$(basename "$1" .git) | ||
if ! cd "$repo_name" ; then | ||
echo "$repo_name doesn't exist, so we are making" | ||
mkdir "$repo_name" | ||
cd "$repo_name" | ||
git init | ||
git remote add origin $1 | ||
fi | ||
git fetch --recurse-submodules=no origin $2 | ||
# We do a force checkout + clean to overwrite previous patches | ||
git checkout -f $2 | ||
git clean -fd | ||
) | ||
} | ||
|
||
function apply-github-patch { | ||
# Apply a specific commit from a specific GitHub PR | ||
# $1 is the repo url, $2 is the PR number, and $3 is commit hash | ||
set -u | ||
|
||
# Look in the PR first | ||
curl --silent -L $1/pull/$2/commits/$3.patch -o $3.patch | ||
|
||
# If the PR has been updated, the commit may no longer be there and the .patch will be empty. | ||
# Look in the full repo instead. | ||
# If it can't be found, this time curl will error | ||
if [[ ! -s $3.patch ]]; then | ||
>&2 echo "Commit $3 not found in $1/pull/$2. Checking the full repository..." | ||
curl --silent --fail -L $1/commit/$3.patch -o $3.patch | ||
fi | ||
|
||
# Apply the patch and tidy up. | ||
patch -p1 < $3.patch | ||
rm $3.patch | ||
return 0 | ||
} | ||
|
||
function apply-gerrit-patch { | ||
# $1 must be the url to a specific patch set | ||
# We get the repo by removing /c and chopping off the change number | ||
# e.g. https://review.mlplatform.org/c/ml/ComputeLibrary/+/12818/1 -> https://review.mlplatform.org/ml/ComputeLibrary/ | ||
repo_url=$(echo "$1" | sed 's#/c/#/#' | cut -d'+' -f1) | ||
# e.g. refs/changes/18/12818/1 Note that where the middle number is the last 2 digits of the patch number | ||
refname=$(echo "$1" | awk -F'/' '{print "refs/changes/" substr($(NF-1),length($(NF-1))-1,2) "/" $(NF-1) "/" $(NF)}') | ||
git fetch $repo_url $refname && git cherry-pick --no-commit FETCH_HEAD | ||
} | ||
|
||
function setup_submodule() { | ||
local original_dir=$(pwd) | ||
rm -rf "$2" | ||
git clone $1 $2 | ||
cd $2 | ||
git checkout $3 | ||
cd $original_dir | ||
} | ||
|
||
function reset_submodule() { | ||
if [ -d "$1" ]; then | ||
rm -rf "$1" | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
# ******************************************************************************* | ||
# Copyright 2025 Arm Limited and affiliates. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# 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. | ||
# ******************************************************************************* | ||
|
||
# This script is based on the upstream PyTorch repository. | ||
# Reference: pytorch/pytorch | ||
# https://github.com/pytorch/pytorch/blob/main/.ci/docker/common/install_openblas.sh | ||
# TODO: discard this and use `pytorch/.ci/docker/common/install_openblas.sh` to build OpenBLAS after version upgrade | ||
|
||
source /utils/helper.sh | ||
|
||
set -ex | ||
OPENBLAS_CHECKOUT_DIR="OpenBLAS" | ||
|
||
cd / | ||
git clone https://github.com/OpenMathLib/OpenBLAS.git -b develop --depth 1 | ||
( | ||
cd $OPENBLAS_CHECKOUT_DIR | ||
apply-github-patch https://github.com/OpenMathLib/OpenBLAS/ 5108 4379a6fbe37038082c657bba5be5c67331a0bd0b | ||
apply-github-patch https://github.com/OpenMathLib/OpenBLAS/ 5108 c748e6a33871f0dfa3bf6569c88a676c9a387411 | ||
cd / | ||
) | ||
|
||
OPENBLAS_BUILD_FLAGS=" | ||
NUM_THREADS=128 | ||
USE_OPENMP=1 | ||
NO_SHARED=0 | ||
DYNAMIC_ARCH=1 | ||
TARGET=ARMV8 | ||
CFLAGS=-O3 | ||
BUILD_BFLOAT16=1 | ||
" | ||
make -j$(nproc) ${OPENBLAS_BUILD_FLAGS} -C ${OPENBLAS_CHECKOUT_DIR} | ||
make -j$(nproc) ${OPENBLAS_BUILD_FLAGS} install -C ${OPENBLAS_CHECKOUT_DIR} |