Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
38 changes: 26 additions & 12 deletions bin/run_rocm_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ if [ ! -e $AOMP/bin ]; then
unset AOMP
fi
# Set AOMP to point to rocm symlink or newest version.
newestrocm=$(ls --sort=time /opt | grep -m 1 rocm)
echo "newestrocm: $newestrocm"
if [ -e /opt/rocm/lib/llvm/bin ]; then
AOMP=${AOMP:-"/opt/rocm/lib/llvm"}
ROCMINF="$AOMP/../../"
Expand All @@ -111,19 +113,31 @@ elif [ -e /opt/rocm/llvm/bin ]; then
ROCMINF="$AOMP/../"
ROCMDIR="$AOMP/../"
echo setting 2 $AOMP
elif [ -e "/opt/$newestrocm/lib/llvm/bin" ]; then
AOMP=${AOMP:-"/opt/$newestrocm/lib/llvm"}
ROCMINF=/opt/$newestrocm
ROCMDIR=$ROCMINF
echo setting 3 $AOMP
elif [ -e "/opt/$newestrocm/llvm/bin" ]; then
AOMP=${AOMP:-"/opt/$newestrocm/llvm"}
ROCMINF=/opt/$newestrocm/
ROCMDIR=$ROCMINF/lib
echo setting 4 $AOMP
elif [ -e "$ROCM_PATH/lib/llvm/bin" ]; then
AOMP=${AOMP:-"$ROCM_PATH/lib/llvm"}
ROCMINF="$AOMP/../../"
ROCMDIR="$AOMP/../../"
echo setting 5 $AOMP
elif [ -e "$ROCM_PATH/llvm/bin" ]; then
AOMP=${AOMP:-"$ROCM_PATH/llvm"}
ROCMINF="$AOMP/../"
ROCMDIR="$AOMP/../"
echo setting 6 $AOMP
else
newestrocm=$(ls --sort=time /opt | grep -m 1 rocm)
if [ -e /opt/$newestrocm/lib/llvm/bin ]; then
AOMP=${AOMP:-"/opt/$newestrocm/lib/llvm"}
ROCMINF=/opt/$newestrocm
ROCMDIR=$ROCMINF
echo setting 3 $AOMP
else
AOMP=${AOMP:-"/opt/$newestrocm/llvm"}
ROCMINF=/opt/$newestrocm/
ROCMDIR=$ROCMINF/lib
echo setting 4 $AOMP
fi
echo "Error: A valid ROCm install was not found. Please point ROCM_PATH or AOMP to a valid ROCm install."
echo " Examples: ROCM_PATH=/opt/rocm; ROCM_PATH=/opt/rocm-7.10; AOMP=/opt/rocm/llvm; AOMP=/opt/rocm-7.10/lib/llvm"
echo " Note that AOMP needs the llvm or lib/llvm path suffix."
exit 1
fi
export AOMP
echo "AOMP = $AOMP"
Expand Down
7 changes: 4 additions & 3 deletions srock-bin/build_hipfort.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ if [ ! -f "$SROCK_INSTALL_DIR/lib/llvm/bin/clang" ] ; then
fi

if [ -d "$BUILD_DIR" ] ; then
# shellcheck disable=SC2154 # $_build_srock_mode is set externally
if [ "$_build_srock_mode" == "restart" ] ; then
echo "===== Skipping $0"
return
Expand All @@ -58,7 +59,7 @@ if [ -d "$BUILD_DIR" ] ; then
echo " rm -rf $BUILD_DIR"
rm -rf "$BUILD_DIR"
fi
mkdir -p $BUILD_DIR
mkdir -p "$BUILD_DIR"

declare -a MYCMAKEOPTS
MYCMAKEOPTS=(-DCMAKE_INSTALL_PREFIX="$SROCK_INSTALL_DIR/lib/llvm"
Expand All @@ -72,13 +73,13 @@ MYCMAKEOPTS=(-DCMAKE_INSTALL_PREFIX="$SROCK_INSTALL_DIR/lib/llvm"
cd "$REPO_DIR" || exit
echo
echo "===== Running $SROCK_CMAKE for hipfort"
$SROCK_CMAKE -S. -Bbuild ${MYCMAKEOPTS[@]} -DCMAKE_Fortran_FLAGS='-ffree-form -fPIC' $REPO_DIRi
$SROCK_CMAKE -S. -Bbuild "${MYCMAKEOPTS[@]}" -DCMAKE_Fortran_FLAGS='-ffree-form -fPIC' "$REPO_DIR"
_cmakerc=$?
echo "===== DONE Running hipfort cmake"
if [ $_cmakerc != 0 ] ; then
echo
echo "ERROR hipfort cmake failed with $SROCK_CMAKE. Cmake flags:"
echo " ${MYCMAKEOPTS[@]} -DCMAKE_Fortran_FLAGS='-ffree-form -fPIC'"
echo " ${MYCMAKEOPTS[*]} -DCMAKE_Fortran_FLAGS='-ffree-form -fPIC'"
exit 1
fi

Expand Down
17 changes: 15 additions & 2 deletions srock-bin/build_srock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ echo " TheRock Dir: $SROCK_THEROCK_DIR"
echo " TheRock branch: $SROCK_THEROCK_BRANCH"
echo " Compiler branch: $SROCK_COMPILER_BRANCH"
echo " SROCK config name: $SROCK_CONFIG"
echo " cmake command: $SROCK_CMAKE"
echo " cmake args: ${_cmake_args[*]}"
echo " ninja command: $(which ninja)"
echo " PATH: $PATH"

# Run srock prebuild which includes finding suitable cmake
# also performed in setup_srock.sh, but repeat here to verify binaries exist
echo
echo "===== Sourcing prebuild_srock.sh"
. "$thisdir/prebuild_srock.sh"
echo "===== DONE Sourcing prebuild_srock.sh"

(
cd "$SROCK_THEROCK_DIR" || exit
Expand All @@ -50,7 +60,7 @@ echo "${smsha}${LLVM_SHA_EXTRA}" >> "$smrev"
)

cd "$SROCK_THEROCK_DIR" || exit
_cmd="cmake --build build"
_cmd="$SROCK_CMAKE --build build"
echo
echo "===== build CMD: $_cmd"
$_cmd
Expand Down Expand Up @@ -108,16 +118,19 @@ ln -sf "$SROCK_INSTALL_DIR" "$SROCK_LINK"
echo
echo "===== DONE $0 on $_end_date"
echo " THEROCK targets: $_gfxsemicolons"
echo " THEROCK families: $_gfamsemicolons"
echo " ROCm install dir: $SROCK_INSTALL_DIR"
echo " TheRock Dir: $SROCK_THEROCK_DIR"
echo " TheRock branch: $SROCK_THEROCK_BRANCH"
echo " Compiler branch: $SROCK_COMPILER_BRANCH"
echo " SROCK config name: $SROCK_CONFIG"
echo " cmake command: $SROCK_CMAKE"
echo " cmake args: ${_cmake_args[*]}"
echo " ninja command: $(which ninja)"
echo " PATH: $PATH"
echo " Build time: $_secs_to_build (seconds)"
echo " Files: $_filecount"
echo " Size: $_size"
echo " cmake args: ${_cmake_args[*]}"
echo
echo " For aomp testing, set AOMP=$SROCK_LINK"
echo " or AOMP=$SROCK_INSTALL_DIR"
Expand Down
20 changes: 10 additions & 10 deletions srock-bin/create_patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ thisdir=$(dirname "$realpath")
# --- end standard header ----
_patch_dir=$thisdir/patches/$SROCK_COMPILER_BRANCH
echo " mkdir -p $_patch_dir"
mkdir -p $_patch_dir
cd $SROCK_THEROCK_DIR
mkdir -p "$_patch_dir"
cd "$SROCK_THEROCK_DIR" || exit 1
_patch_file=$_patch_dir/_TheRock.patch
git diff --ignore-submodules . > $_patch_file
[ ! -s "$_patch_file" ] && rm $_patch_file
git diff --ignore-submodules . > "$_patch_file"
[ ! -s "$_patch_file" ] && rm "$_patch_file"

_tmpfile=/tmp/submod$$
git submodule > $_tmpfile
while read _line ; do
_subdir=`echo $_line | cut -d" " -f2`
cd $SROCK_THEROCK_DIR/$_subdir
_subdirname=`echo $_subdir | tr "/" "_"`
while read -r _line ; do
_subdir=$(echo "$_line" | cut -d" " -f2)
cd "$SROCK_THEROCK_DIR/$_subdir" || exit 1
_subdirname=$(echo "$_subdir" | tr "/" "_")
_patch_file=$_patch_dir/$_subdirname.patch
git diff . > $_patch_file
[ ! -s "$_patch_file" ] && rm $_patch_file
git diff . > "$_patch_file"
[ ! -s "$_patch_file" ] && rm "$_patch_file"
done < $_tmpfile
rm $_tmpfile
echo "DONE $0"
23 changes: 12 additions & 11 deletions srock-bin/prebuild_srock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,42 @@ thisdir=$(dirname "$realpath")

echo "= 1 = Checking if cmake needs to be built"
echo " building $_cmake_local"
$thisdir/build_cmake.sh # check is performed within build_cmake.sh
"$thisdir/build_cmake.sh" # check is performed within build_cmake.sh
echo " The cmake for srock is $SROCK_CMAKE"

# Skip these updates if this is a restart
# shellcheck disable=SC2154 # $__build_srock_mode assigned before call
if [ "$_build_srock_mode" == "restart" ] ; then
return
fi

cd $SROCK_REPOS
cd "$SROCK_REPOS" || exit 1
echo "= 2 = Updating aomp repo"
if [ -d $SROCK_REPOS/aomp ] ; then
if [ -d "$SROCK_REPOS/aomp" ] ; then
echo " Skipping aomp clone, $SROCK_REPOS/srock already exists"
else
echo " git clone -b $SROCK_DEV_BRANCH https://github.com/ROCm/aomp"
git clone -b $SROCK_DEV_BRANCH https://github.com/ROCm/aomp 2>/dev/null >/dev/null
git clone -b "$SROCK_DEV_BRANCH" https://github.com/ROCm/aomp 2>/dev/null >/dev/null
fi
echo " cd $SROCK_REPOS/aomp"
cd $SROCK_REPOS/aomp
cd "$SROCK_REPOS/aomp" || exit 1
echo " git checkout $SROCK_DEV_BRANCH"
git checkout $SROCK_DEV_BRANCH
git checkout "$SROCK_DEV_BRANCH"
echo " git pull"
git pull

cd $SROCK_REPOS
cd "$SROCK_REPOS" || exit 1
echo "= 3 = Updating hipfort repo"
if [ -d $SROCK_REPOS/hipfort ] ; then
if [ -d "$SROCK_REPOS/hipfort" ] ; then
echo " Skipping hipfort clone, $SROCK_REPOS/hipfort already exists"
else
echo " git clone -b $SROCK_HIPFORT_BRANCH https://github.com/ROCm/hipfort"
git clone -b $SROCK_HIPFORT_BRANCH https://github.com/ROCm/hipfort 2>/dev/null >/dev/null
git clone -b "$SROCK_HIPFORT_BRANCH" https://github.com/ROCm/hipfort 2>/dev/null >/dev/null
fi
echo " cd $SROCK_REPOS/hipfort"
cd $SROCK_REPOS/hipfort
cd "$SROCK_REPOS/hipfort" || exit 1
echo " git checkout $SROCK_HIPFORT_BRANCH"
git checkout $SROCK_HIPFORT_BRANCH
git checkout "$SROCK_HIPFORT_BRANCH"
echo " git pull"
git pull

2 changes: 2 additions & 0 deletions srock-bin/setup_srock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ thisdir=$(dirname "$realpath")

# Accept a single command as an argument. Only "restart" is accepted so far.
ARG=$1
export _build_srock_mode="$ARG"

if [ -d "$SROCK_THEROCK_DIR" ] && [ "$ARG" != "restart" ]; then
echo " ERROR: $0 requires that $SROCK_THEROCK_DIR NOT exist"
Expand All @@ -39,6 +40,7 @@ echo " TheRock Dir: $SROCK_THEROCK_DIR"
echo " TheRock branch: $SROCK_THEROCK_BRANCH"
echo " Compiler branch: $SROCK_COMPILER_BRANCH"
echo " SROCK config name: $SROCK_CONFIG"
echo " cmake: $SROCK_CMAKE"
echo " cmake args: ${_cmake_args[*]}"

# Run srock prebuild which includes finding suitable cmake
Expand Down
83 changes: 46 additions & 37 deletions srock-bin/srock_common_vars
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# large capacity (100GB+) directory 100GB+

function test_apply_patch() {
# shellcheck disable=SC2154 # $_patch_file &_curdir are set externally
if ! patch -p1 -t -N --merge --dry-run < "$_patch_file" >/dev/null; then
echo "ERROR: patch --dry-run failed. Could not apply $_patch_file "
cd "$_curdir" || exit 1
Expand All @@ -26,33 +27,54 @@ function test_apply_patch() {
}

function srock_venv_activate() {
if [ -d "$SROCK_THEROCK_DIR/.venv/bin" ] ; then
if [ -d "$SROCK_THEROCK_DIR/$SROCK_VENV/bin" ] ; then
echo
echo "===== Activating virtual environment ====="
cd "$SROCK_THEROCK_DIR" || exit
echo "source .venv/bin/activate"
# shellcheck disable=1091 # don't analyze activate
source ".venv/bin/activate"
echo "source $SROCK_VENV/bin/activate"
# shellcheck disable=SC1091 # don't analyze activate
source "$SROCK_VENV/bin/activate"
else
echo
echo "===== Building virtual environment in .venv and updating PATH ====="
echo "===== Building virtual environment in $SROCK_VENV and updating PATH ====="
cd "$SROCK_THEROCK_DIR" || exit
echo "python3 -m venv .venv && source .venv/bin/activate"
# shellcheck disable=1091 # don't analyze activate
python3 -m venv .venv && source ".venv/bin/activate"
echo "python3 -m venv $SROCK_VENV && source $SROCK_VENV/bin/activate"
# shellcheck disable=SC1091 # don't analyze activate
python3 -m venv "$SROCK_VENV" && source "$SROCK_VENV/bin/activate"
fi
echo "pip install -r requirements.txt"
pip install -r requirements.txt
export PATH=$SROCK_THEROCK_DIR/.venv/bin:$PATH
export PATH=$SROCK_THEROCK_DIR/$SROCK_VENV/bin:$PATH
}

function chk_cmake() {
if [ "$_build_cmake" == 1 ] && [ -f "$_cmake_local" ] ; then
_cmake_ver=$($_cmake_local --version 2>/dev/null | grep version | cut -d" " -f3)
if [ "$_cmake_ver" != "" ] ; then
_cmake_major=${_cmake_ver%%.*}
_cmake_rel=$(echo "$_cmake_ver" | cut -d"." -f2)
_cmake_dir=$(dirname "$_cmake_local")
if (( ( _cmake_major >= 4 ) ||
(( _cmake_major == 3 ) && ( _cmake_rel >= 25 )) )); then
_build_cmake=0
export PATH="$_cmake_dir:$PATH"
# echo " $_cmake_local cmake is ok"
SROCK_CMAKE=$_cmake_local
fi
fi
fi
}

# shellcheck disable=SC2034 # currently unused
SROCK="NEVER_USE_'\$SROCK'_ENV_VARIABLE" # Use SROCK_LINK

# SROCK_REPOS is the parent directory for TheRock and srock repos.
SROCK_REPOS=${SROCK_REPOS:-${HOME}/git/srock-repos}
if [ ! -d $SROCK_REPOS ] ; then
mkdir -p $SROCK_REPOS
[ $? != 0 ] && echo "ERROR: Could not create $SROCK_REPOS" && exit 1
if [ ! -d "$SROCK_REPOS" ] ; then
if ! mkdir -p "$SROCK_REPOS"; then
echo "ERROR: Could not create $SROCK_REPOS"
exit 1
fi
fi

SROCK_VERSION=${SROCK_VERSION:-"7.13"}
Expand All @@ -74,13 +96,16 @@ SROCK_LINK=${SROCK_LINK:-$HOME/rocm/srock}
SROCK_INSTALL_DIR=${SROCK_LINK}_${SROCK_VERSION_STRING}

SROCK_THEROCK_DIR=$SROCK_REPOS/TheRock
SROCK_VENV=${SROCK_VENV:-.venv}

export SROCK_REPOS SROCK_VERSION_STRING SROCK_VERSION SROCK_VERSION_MOD SROCK_MAJOR_VERSION SROCK_LINK SROCK_INSTALL_DIR SROCK_THEROCK_DIR

SROCK_REPO_NAME=${SROCK_REPO_NAME:-aomp}
# These local variables are only used during build to log important information.
SROCK_VERSION_INFO_DIR=$SROCK_REPOS/$SROCK_REPO_NAME/srock-bin/srock_$SROCK_VERSION_STRING
# shellcheck disable=SC2034 # currently unused
SROCK_INFO_FILE=$SROCK_VERSION_INFO_DIR/srock_$SROCK_VERSION_STRING.info
# shellcheck disable=SC2034 # currently unused
SROCK_SUBMOD_FILE=$SROCK_VERSION_INFO_DIR/srock_$SROCK_VERSION_STRING.submodules

# SROCK_SUPP is for SUPPlemental software components needed for testing.
Expand All @@ -92,7 +117,7 @@ SROCK_SUPP_BUILD=${SROCK_SUPP_BUILD:-$SROCK_SUPP/build}
# SROCK_SUPP_INSTALL must be permanent directory.
SROCK_SUPP_INSTALL=${SROCK_SUPP_INSTALL:-$SROCK_SUPP/install}
export SROCK_SUPP SROCK_SUPP_BUILD SROCK_SUPP_INSTALL
export PATH=$SROCK_SUPP/cmake/bin:$SROCK_SUPP/ninja/bin:$PATH
export PATH=$SROCK_SUPP/ninja/bin:$PATH

# Specify target GFXLIST/GFXFAM
# gfx not currently supported by TheRock:
Expand All @@ -118,33 +143,17 @@ SROCK_HIPFORT_BRANCH=${SROCK_HIPFORT_BRANCH:-release/rocm-rel-7.2}
SROCK_ROCGDB_BRANCH=${SROCK_ROCGDB_BRANCH:-release/rocm-rel-7.2}
SROCK_ROCDBGAPI_BRANCH=${SROCK_ROCDBGAPI_BRANCH:-release/rocm-rel-7.2}

SROCK_CMAKE=`which cmake`
_build_cmake=1
_cmake_ver=`cmake --version 2>/dev/null | grep version | cut -d" " -f3`
if [ "$_cmake_ver" != "" ] ; then
_cmake_major=${_cmake_ver%%.*}
_cmake_rel=`echo $_cmake_ver | cut -d"." -f2`
if [ $_cmake_major -ge 3 ] && [ $_cmake_rel -ge 25 ] ; then
# Default cmake is ok
# echo " Default PATH $SROCK_CMAKE is ok"
_build_cmake=0
fi
fi
SROCK_CMAKE=$(which cmake)
_cmake_local=$SROCK_CMAKE
chk_cmake

# Check the local build of cmake
_cmake_local=$HOME/local/cmake/bin/cmake
if [ $_build_cmake == 1 ] && [ -f $_cmake_local ] ; then
_cmake_ver=`$_cmake_local --version 2>/dev/null | grep version | cut -d" " -f3`
_cmake_major=${_cmake_ver%%.*}
_cmake_rel=`echo $_cmake_ver | cut -d"." -f2`
if [ $_cmake_major -ge 3 ] && [ $_cmake_rel -ge 25 ] ; then
_build_cmake=0
export PATH=$HOME/local/cmake/bin:$PATH
# echo " $_cmake_local cmake is ok"
SROCK_CMAKE=$_cmake_local
fi
fi
_cmake_local=$SROCK_SUPP/cmake/bin/cmake
chk_cmake

if [ $_build_cmake == 1 ] ; then
export PATH=$HOME/local/cmake/bin:$PATH
export PATH=$SROCK_SUPP/cmake/bin:$PATH
SROCK_CMAKE=$_cmake_local
fi
export SROCK_CMAKE
Expand Down
Loading