diff --git a/bin/CBL_run_sollve.sh b/bin/CBL_run_sollve.sh index e1b578cd1..ca6b8ba1a 100755 --- a/bin/CBL_run_sollve.sh +++ b/bin/CBL_run_sollve.sh @@ -21,6 +21,7 @@ export EFFLAGS="-ffree-form -ffree-line-length-none" # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/aomp_common_vars b/bin/aomp_common_vars index a59bcab09..5ec312dbc 100644 --- a/bin/aomp_common_vars +++ b/bin/aomp_common_vars @@ -233,33 +233,6 @@ else fi fi -# Quote argument list suitable for passing as a single (string) argument to -# cmake. Result can be used within a double-quoted string, i.e. using -# "$(cmquot ...)". -function cmquot() { - local escaped_flags - local escaped_flag - local flag - escaped_flags=() - for flag in "$@"; do - escaped_flag=$(printf "%s" "$flag" | sed 's/\\/\\\\/g; s/\$/\\$/g; s/ /\\ /g; s/"/\\"/g') - escaped_flags+=("$escaped_flag") - done - echo "${escaped_flags[*]}" -} - -# Quote argument list suitable for passing back to the shell as a string. -# Useful for e.g. dumping argument lists in such a way that they can be safely -# copy & pasted into the user's terminal. Output should not be further quoted. -function shquot() { - local -a output - output=() - for arg in "$@"; do - output+=(\'${arg//\'/\'\\\'\'}\') - done - printf '%s' "${output[*]}" -} - # AOMP uses RPATH (not) RUNPATH because LD_LIBRARY_PATH is a user feature for # user lib development. We do not want the compiler runtime to search user paths # first because we want assurance to recreate reported compiler runtime fails. @@ -559,277 +532,3 @@ if [ "$AOMP_BUILD_SANITIZER" == 1 ]; then fi fi -function check_writable_installdir() { - local action=$1 - local installdir=$2 - - # Make sure we can update the install directory - if [ "$action" == "install" ] ; then - $SUDO mkdir -p "$installdir" - - if ! $SUDO touch "$installdir/testfile"; then - echo "ERROR: No update access to $installdir" - exit 1 - fi - $SUDO rm "$installdir/testfile" - fi -} - -# TO use this function set variables patchdir and patchfile -function patchrepo(){ -patchdir=$1 -if [ "$AOMP_APPLY_ROCM_PATCHES" == 1 ] && [ -d "$patchdir" ] ; then - patches="" - cd "$patchdir" || exit - if [[ "$2" =~ "postinstall" ]]; then - getpatchlist "$2" - else - getpatchlist - fi - - #loop through list of patches to apply - if [ "$patches" != "" ] ; then - patchloc=${AOMP_PATCH_CONTROL_FILE%/*} - echo "patchloc=$patchloc" - for patch in $patches; do - patchfile=$patchloc/$patch - if [ ! -f "$patchfile" ] ; then - echo - echo "ERROR: Patch $patchfile does not exist" - echo " It is referenced in ${AOMP_PATCH_CONTROL_FILE}" - exit 1 - fi - - echo "Testing patch $patchfile to $patchdir" - - applypatch="yes" - if ! patch -p1 -t -N --dry-run <"$patchfile" >/dev/null; then - applypatch="no" - # Check to see if reverse patch applies cleanly - if patch -p1 -R --dry-run -t <"$patchfile" >/dev/null; then - echo "patch $patchfile was already applied to $patchdir" - else - echo - echo "ERROR: Patch $patchfile will not apply" - echo " cleanly to directory $patchdir" - echo " Check if it was already applied." - echo - exit 1 - fi - fi - if [ "$applypatch" == "yes" ] ; then - echo "Applying patch $patchfile to $patchdir" - patch -p1 --no-backup-if-mismatch <"$patchfile" - fi - done - fi -fi - -} - -function removepatch(){ -patchdir=$1 -if [ "$AOMP_APPLY_ROCM_PATCHES" == 1 ] && [ -d "$patchdir" ] ; then - patches="" - cd "$patchdir" || exit - getpatchlist - if [ "$patches" != "" ] ; then - echo "Patchdir $patchdir" - echo "PATCHES TO REMOVE: $patches" - fi - patchloc=${AOMP_PATCH_CONTROL_FILE%/*} - if [ "$patches" != "" ] ; then - for patch in $patches; do - patchfile=$patchloc/$patch - echo "Testing reverse patch $patchfile to $patchdir" - reversepatch="yes" - # Check to see if reverse patch applies cleanly - - if ! patch -p1 -R --dry-run -f <"$patchfile" >/dev/null; then - echo "patch $patchfile was NOT applied $patchdir, no patch to reverse" - reversepatch="no" - fi - if [ "$reversepatch" == "yes" ] ; then - echo "Reversing patch $patchfile to $patchdir" - patch -p1 -R -f --no-backup-if-mismatch <"$patchfile" - fi - done - fi -fi -} - -function getpatchlist(){ - currdir=$(pwd) - basedir=$(basename "$currdir") - if [[ "$1" =~ "postinstall" ]]; then - reporegex="(^$1:\s)" - else - reporegex="(^$basedir:\s)" - fi - echo "FILE: $AOMP_PATCH_CONTROL_FILE" - echo "regex $reporegex" - #read patch control file and look for correct patches - while read -r line; do - if [[ "$line" =~ $reporegex ]]; then - #remove basename from list of patches - patches=${line/"${BASH_REMATCH[1]}"} - echo "patches: $patches" - break - fi - done < "$AOMP_PATCH_CONTROL_FILE" -} - -function setaompgpu (){ - if [[ -e "$AOMP/../../bin/rocm_agent_enumerator" ]]; then - echo Set AOMP_GPU with ../.. rocm_agent_enumerator. - detected_gpu=$("$AOMP"/../../bin/rocm_agent_enumerator | grep -m 1 -E 'gfx[^0]{1}.{2}') - elif [[ -e "$AOMP/../bin/rocm_agent_enumerator" ]]; then - echo Set AOMP_GPU with .. rocm_agent_enumerator. - detected_gpu=$("$AOMP"/../bin/rocm_agent_enumerator | grep -m 1 -E 'gfx[^0]{1}.{2}') - elif [[ "$AOMP" =~ "opt" ]]; then - echo Set AOMP_GPU with rocm_agent_enumerator. - detected_gpu=$("$AOMP"/../bin/rocm_agent_enumerator | grep -m 1 -E 'gfx[^0]{1}.{2}') - else - echo Set AOMP_GPU with rocm_agent_enumerator. - if [ -a "$AOMP"/bin/rocm_agent_enumerator ]; then - detected_gpu=$("$AOMP"/bin/rocm_agent_enumerator | grep -m 1 -E 'gfx[^0]{1}.{2}') - elif [ -a "$AOMP"/bin/amdgpu-arch ]; then - detected_gpu=$("$AOMP"/bin/amdgpu-arch) - detected_gpu=$(echo "$detected_gpu" | awk '{print $1,$5}') - detected_gpu=$(echo "$detected_gpu" | cut -d" " -f1) # pick first found - elif [ -e "$AOMP"/../bin/mygpu ]; then - detected_gpu=$("$AOMP"/../bin/mygpu) - else - echo "Error: in setaompgpu, could not find rocm_agent_enumerator" - echo " Set AOMP_GPU, AOMP, or install ROCm" - exit 1 - fi - fi - - AOMP_GPU=${AOMP_GPU:-$detected_gpu} - export AOMP_GPU - echo "AOMP_GPU = $AOMP_GPU" - echo "AOMP = $AOMP" - - if [ "$AOMP_GPU" == "" ] || [ "$AOMP_GPU" == "unknown" ]; then - echo Error: AOMP_GPU not properly set...exiting. - exit 1 - fi -} - -# GPUs which need HSA_XNACK=1 to be set for USM to work. The canonical place -# this info is stored in these scripts is in test/Makefile.defs (SUPPORTS_USM). -# We use a tiny custom makefile to extract the info. -# Usage: -# if gpu_needs_xnack_for_usm "$GPU"; then ...; fi - -function gpu_needs_xnack_for_usm(){ - local needs_usm - needs_usm=$(make -s -C "$thisdir"/../test -f USM_check.make GPU="$1") - case "$needs_usm" in - true) - return 0 - ;; - false) - return 1 - ;; - *) - return 2 - ;; - esac -} - -# Return success (0) if ROCR_VISIBLE_DEVICES (or the first GPU if it is unset) -# refers to an APU, as indicated by rocminfo returning -# "Coherent Host Access: TRUE" for the device, else return failure (1). - -function is_apu(){ - local device_num=${ROCR_VISIBLE_DEVICES:-0} - local cha - cha=$(ROCR_VISIBLE_DEVICES="$device_num" rocminfo | grep -m 1 -F "Coherent Host Access:") - if [[ "$cha" =~ Coherent\ Host\ Access:[[:blank:]]+(TRUE|FALSE) ]]; then - case "${BASH_REMATCH[1]}" in - TRUE) - return 0 - ;; - FALSE) - return 1 - ;; - esac - else - # If we don't see the above pattern in rocminfo output, it's probably not - # an APU. - return 1 - fi -} - -function help_build_aomp(){ - /bin/cat 2>&1 <<"EOF" - - The build scripts in this directory are used to build AOMP. - - Repositories: - Many repositories are used to build AOMP. The script clone_aomp.sh will - clone all the necessary repositories as subdirectories of the directory - $HOME/git/aomp11. The web repository locations and the required branches - are set with the file aomp_common_vars - - Build all components: - To build all components, run these commands: - - ./clone_aomp.sh - unset LD_LIBRARY_PATH - ./build_aomp.sh - - Component builds: - Developers can rebuild individual components by running the build script for - that component. Make sure dependent components are built first. You can run - build_aomp.sh to build call components in the correct order orsee the README.md - file in this directory for the required order. - - Each build script can run with no arguments or with a single argument - "install" or "nocmake". Running with no options starts fresh with an empty - component build directory. It then runs cmake with the correct cmake options - then it runs make with a proper -j option. - - Optional Arguments 'nocmake' and 'install' : - The 'nocmake' or 'install' options can only be used after your initial build - with no options. The 'nocmake' option is intended to restart make after - you fix code following a failed build. The 'install' option will run 'make' - and 'make install' causing installation into the directory $AOMP_INSTALL_DIR. - The 'install' option will also create a symbolic link to directory $AOMP. - - Environment Variables: - You can set environment variables to override behavior of the build scripts - NAME DEFAULT DESCRIPTION - ---- ------- ----------- - AOMP $HOME/rocm/aomp Where the compiler will be installed - AOMP_REPOS $HOME/git/aomp11 Location of all aomp repos - BUILD_TYPE Release The CMAKE build type - BUILD_AOMP same as AOMP_REPOS Set a different build location than AOMP_REPOS - AOMP_USE_NINJA 0 Use ninja if possible - - To build a debug version of the compiler, run this command before the build: - export BUILD_TYPE=debug - - The BUILD_AOMP Envronment Variable: - The build scripts will always build with cmake and make outside your source git trees. - By default (without BUILD_AOMP) the build will occur in the "build" subdirectory of - AOMP_REPOS. For example build_llvm will build in $AOMP_REPOS/build/llvm - - The BUILD_AOMP environment variable enables source development outside your git - repositories. By default, this feature is OFF. The BUILD_AOMP environment variable - can be used if access to your git repositories is very slow or you want to test - changes outside of your local git repositories (specified by AOMP_REPOS env var). - If BUILD_AOMP is set, your git repositories (specifed by AOMP_REPOS) will be - replicated to subdirectories of BUILD_AOMP using rsync. The subsequent build - (cmake and make) will occur in subdirectory BUILD_AOMP/build/llvm. - This replication only happens on your initial build, that is, if you specify no arguments. - The option 'nocmake' skips replication and then restarts make in the build directory. - The install option skips replication, skips cmake, runs 'make' and 'make install'. - Be careful to always use options nocmake or install if you made local changes in - BUILD_AOMP or your changes will be lost by a new replica of your git repositories. - -EOF - exit 0 -} diff --git a/bin/aomp_utils b/bin/aomp_utils new file mode 100644 index 000000000..a60a45b4b --- /dev/null +++ b/bin/aomp_utils @@ -0,0 +1,469 @@ +#!/bin/bash + +# Quote argument list suitable for passing as a single (string) argument to +# cmake. Result can be used within a double-quoted string, i.e. using +# "$(cmquot ...)". +function cmquot() { + local escaped_flags + local escaped_flag + local flag + escaped_flags=() + for flag in "$@"; do + escaped_flag=$(printf "%s" "$flag" | sed 's/\\/\\\\/g; s/\$/\\$/g; s/ /\\ /g; s/"/\\"/g') + escaped_flags+=("$escaped_flag") + done + echo "${escaped_flags[*]}" +} + +# Quote argument list suitable for passing back to the shell as a string. +# Useful for e.g. dumping argument lists in such a way that they can be safely +# copy & pasted into the user's terminal. Output should not be further quoted. +function shquot() { + local -a output + output=() + for arg in "$@"; do + output+=(\'"${arg//\'/\'\\\'\'}"\') + done + printf '%s' "${output[*]}" +} + +function check_writable_installdir() { + local action=$1 + local installdir=$2 + + # Make sure we can update the install directory + if [ "$action" == "install" ] ; then + $SUDO mkdir -p "$installdir" + + if ! $SUDO touch "$installdir/testfile"; then + echo "ERROR: No update access to $installdir" + exit 1 + fi + $SUDO rm "$installdir/testfile" + fi +} + +# TO use this function set variables patchdir and patchfile +function patchrepo(){ +patchdir=$1 +if [ "$AOMP_APPLY_ROCM_PATCHES" == 1 ] && [ -d "$patchdir" ] ; then + patches="" + cd "$patchdir" || exit + if [[ "$2" =~ "postinstall" ]]; then + getpatchlist "$2" + else + getpatchlist + fi + + #loop through list of patches to apply + if [ "$patches" != "" ] ; then + patchloc=${AOMP_PATCH_CONTROL_FILE%/*} + echo "patchloc=$patchloc" + for patch in $patches; do + patchfile=$patchloc/$patch + if [ ! -f "$patchfile" ] ; then + echo + echo "ERROR: Patch $patchfile does not exist" + echo " It is referenced in ${AOMP_PATCH_CONTROL_FILE}" + exit 1 + fi + + echo "Testing patch $patchfile to $patchdir" + + applypatch="yes" + if ! patch -p1 -t -N --dry-run <"$patchfile" >/dev/null; then + applypatch="no" + # Check to see if reverse patch applies cleanly + if patch -p1 -R --dry-run -t <"$patchfile" >/dev/null; then + echo "patch $patchfile was already applied to $patchdir" + else + echo + echo "ERROR: Patch $patchfile will not apply" + echo " cleanly to directory $patchdir" + echo " Check if it was already applied." + echo + exit 1 + fi + fi + if [ "$applypatch" == "yes" ] ; then + echo "Applying patch $patchfile to $patchdir" + patch -p1 --no-backup-if-mismatch <"$patchfile" + fi + done + fi +fi + +} + +function removepatch(){ +patchdir=$1 +if [ "$AOMP_APPLY_ROCM_PATCHES" == 1 ] && [ -d "$patchdir" ] ; then + patches="" + cd "$patchdir" || exit + getpatchlist + if [ "$patches" != "" ] ; then + echo "Patchdir $patchdir" + echo "PATCHES TO REMOVE: $patches" + fi + patchloc=${AOMP_PATCH_CONTROL_FILE%/*} + if [ "$patches" != "" ] ; then + for patch in $patches; do + patchfile=$patchloc/$patch + echo "Testing reverse patch $patchfile to $patchdir" + reversepatch="yes" + # Check to see if reverse patch applies cleanly + + if ! patch -p1 -R --dry-run -f <"$patchfile" >/dev/null; then + echo "patch $patchfile was NOT applied $patchdir, no patch to reverse" + reversepatch="no" + fi + if [ "$reversepatch" == "yes" ] ; then + echo "Reversing patch $patchfile to $patchdir" + patch -p1 -R -f --no-backup-if-mismatch <"$patchfile" + fi + done + fi +fi +} + +function getpatchlist(){ + currdir=$(pwd) + basedir=$(basename "$currdir") + if [[ "$1" =~ "postinstall" ]]; then + reporegex="(^$1:\s)" + else + reporegex="(^$basedir:\s)" + fi + echo "FILE: $AOMP_PATCH_CONTROL_FILE" + echo "regex $reporegex" + #read patch control file and look for correct patches + while read -r line; do + if [[ "$line" =~ $reporegex ]]; then + #remove basename from list of patches + patches=${line/"${BASH_REMATCH[1]}"} + echo "patches: $patches" + break + fi + done < "$AOMP_PATCH_CONTROL_FILE" +} + +function setaompgpu (){ + if [[ -e "$AOMP/../../bin/rocm_agent_enumerator" ]]; then + echo Set AOMP_GPU with ../.. rocm_agent_enumerator. + detected_gpu=$("$AOMP"/../../bin/rocm_agent_enumerator | grep -m 1 -E 'gfx[^0]{1}.{2}') + elif [[ -e "$AOMP/../bin/rocm_agent_enumerator" ]]; then + echo Set AOMP_GPU with .. rocm_agent_enumerator. + detected_gpu=$("$AOMP"/../bin/rocm_agent_enumerator | grep -m 1 -E 'gfx[^0]{1}.{2}') + elif [[ "$AOMP" =~ "opt" ]]; then + echo Set AOMP_GPU with rocm_agent_enumerator. + detected_gpu=$("$AOMP"/../bin/rocm_agent_enumerator | grep -m 1 -E 'gfx[^0]{1}.{2}') + else + echo Set AOMP_GPU with rocm_agent_enumerator. + if [ -a "$AOMP"/bin/rocm_agent_enumerator ]; then + detected_gpu=$("$AOMP"/bin/rocm_agent_enumerator | grep -m 1 -E 'gfx[^0]{1}.{2}') + elif [ -a "$AOMP"/bin/amdgpu-arch ]; then + detected_gpu=$("$AOMP"/bin/amdgpu-arch) + detected_gpu=$(echo "$detected_gpu" | awk '{print $1,$5}') + detected_gpu=$(echo "$detected_gpu" | cut -d" " -f1) # pick first found + elif [ -e "$AOMP"/../bin/mygpu ]; then + detected_gpu=$("$AOMP"/../bin/mygpu) + else + echo "Error: in setaompgpu, could not find rocm_agent_enumerator" + echo " Set AOMP_GPU, AOMP, or install ROCm" + exit 1 + fi + fi + + AOMP_GPU=${AOMP_GPU:-$detected_gpu} + export AOMP_GPU + echo "AOMP_GPU = $AOMP_GPU" + echo "AOMP = $AOMP" + + if [ "$AOMP_GPU" == "" ] || [ "$AOMP_GPU" == "unknown" ]; then + echo Error: AOMP_GPU not properly set...exiting. + exit 1 + fi +} + +# GPUs which need HSA_XNACK=1 to be set for USM to work. The canonical place +# this info is stored in these scripts is in test/Makefile.defs (SUPPORTS_USM). +# We use a tiny custom makefile to extract the info. +# Usage: +# if gpu_needs_xnack_for_usm "$GPU"; then ...; fi + +function gpu_needs_xnack_for_usm(){ + local needs_usm + # $thisdir is always set by aomp_common_vars. + # shellcheck disable=SC2154 + needs_usm=$(make -s -C "$thisdir"/../test -f USM_check.make GPU="$1") + case "$needs_usm" in + true) + return 0 + ;; + false) + return 1 + ;; + *) + return 2 + ;; + esac +} + +# Return success (0) if ROCR_VISIBLE_DEVICES (or the first GPU if it is unset) +# refers to an APU, as indicated by rocminfo returning +# "Coherent Host Access: TRUE" for the device, else return failure (1). + +function is_apu(){ + local device_num=${ROCR_VISIBLE_DEVICES:-0} + local cha + cha=$(ROCR_VISIBLE_DEVICES="$device_num" rocminfo | grep -m 1 -F "Coherent Host Access:") + if [[ "$cha" =~ Coherent\ Host\ Access:[[:blank:]]+(TRUE|FALSE) ]]; then + case "${BASH_REMATCH[1]}" in + TRUE) + return 0 + ;; + FALSE) + return 1 + ;; + esac + else + # If we don't see the above pattern in rocminfo output, it's probably not + # an APU. + return 1 + fi +} + +valid_config() { + local thiscfg=$1 + local -a configs + local oldlastpipe + local cfg + oldlastpipe="$(shopt -p lastpipe)" + shopt -s lastpipe + do_list_configs | mapfile -t configs + for cfg in "${configs[@]}"; do + if [ "$cfg" = "$thiscfg" ]; then + eval "$oldlastpipe" + return 0 + fi + done + eval "$oldlastpipe" + return 1 +} + +runcmd() { + "$@" +} + +aomp_tasks_filtered() { + local filter + local cfg + local task + local cmd + if [ "$1" = "--dryrun" ]; then + cmd="echo" + shift + else + cmd="runcmd" + fi + filter=$1 + do_list_init | while read -r initfn; do + $cmd "task_${initfn}" + done + do_list_configs | while read -r cfg; do + do_list_tasks "$cfg" | while read -r task; do + if [[ "$task" =~ $filter ]]; then + $cmd "task_${task}" "$cfg" + fi + done + done + do_list_fini | while read -r finifn; do + $cmd "task_${finifn}" + done +} + +get_config_var_string() { + #local component=$1 + local -n _varname=$2 + case "$2" in + BUILD_DIR) + printf "%s/build" "$_varname" + return + ;; + LLVM_INSTALL_LOC|AOMP_PROC|CUDABIN|CUDAT|CUDAINCLUDE|REPO_DIR|\ + AOMP_NINJA_BIN|AOMP_JOB_THREADS|LLVM_PROJECT_ROOT) + ;; + *) + >&2 echo "Unknown string configuration variable '$2'" + exit 1 + ;; + esac + printf "%s" "$_varname" +} + +get_config_var_bool() { + #local component=$1 + local -n _varname=$2 + case "$2" in + AOMP_BUILD_CUDA|AOMP_APPLY_ATD_AMD_STAGING_PATCH|AOMP_USE_NINJA|\ + AOMP_STANDALONE_BUILD|SANITIZER|AOMP_LEGACY_OPENMP|AOMP_BUILD_SANITIZER|\ + AOMP_BUILD_PERF|AOMP_BUILD_DEBUG) + ;; + *) + >&2 echo "Unknown bool configuration variable '$2'" + exit 1 + ;; + esac + if [[ $_varname = 1 ]]; then + echo "true" + else + echo "false" + fi +} + +do_aomp_all() { + aomp_tasks_filtered '.*' +} + +do_cmake() { + aomp_tasks_filtered '^(clean|cmake)' +} + +do_nocmake() { + aomp_tasks_filtered 'build' +} + +do_install() { + aomp_tasks_filtered '^(install|postinstall)' +} + +do_show_src_dir() { + if [ $# -eq 0 ]; then + printf "%s\n" "$(get_src_dir)" + else + local WhichComp=$1 + "$thisdir/build_${WhichComp}.sh" show_src_dir + fi +} + +do_show_build_dir() { + local WhichComp + local Cfg + if [ $# -eq 1 ]; then + Cfg=$1 + printf "%s\n" "$(get_build_dir "$Cfg")" + elif [ $# -eq 2 ]; then + WhichComp=$1 + Cfg=$2 + "$thisdir/build_${WhichComp}.sh" show_build_dir "$Cfg" + else + >&2 echo "Usage: show_build_dir [] " + exit 1 + fi +} + +do_show_install_dir() { + local WhichComp + local Cfg + if [ $# -eq 1 ]; then + Cfg=$1 + printf "%s\n" "$(get_install_dir "$Cfg")" + elif [ $# -eq 2 ]; then + WhichComp=$1 + Cfg=$2 + "$thisdir/build_${WhichComp}.sh" show_install_dir "$Cfg" + else + >&2 echo "Usage: show_install_dir [] " + exit 1 + fi +} + +do_list() { + aomp_tasks_filtered --dryrun '.*' +} + +command_dispatcher() { + local _proc + _proc=$1 + if [ "$_proc" ]; then + shift + if [[ $_proc =~ ^task_ ]]; then + "$_proc" "$@" + else + "do_${_proc}" "$@" + fi + else + do_aomp_all + fi +} + +function help_build_aomp(){ + /bin/cat 2>&1 <<"EOF" + + The build scripts in this directory are used to build AOMP. + + Repositories: + Many repositories are used to build AOMP. The script clone_aomp.sh will + clone all the necessary repositories as subdirectories of the directory + $HOME/git/aomp11. The web repository locations and the required branches + are set with the file aomp_common_vars + + Build all components: + To build all components, run these commands: + + ./clone_aomp.sh + unset LD_LIBRARY_PATH + ./build_aomp.sh + + Component builds: + Developers can rebuild individual components by running the build script for + that component. Make sure dependent components are built first. You can run + build_aomp.sh to build call components in the correct order orsee the README.md + file in this directory for the required order. + + Each build script can run with no arguments or with a single argument + "install" or "nocmake". Running with no options starts fresh with an empty + component build directory. It then runs cmake with the correct cmake options + then it runs make with a proper -j option. + + Optional Arguments 'nocmake' and 'install' : + The 'nocmake' or 'install' options can only be used after your initial build + with no options. The 'nocmake' option is intended to restart make after + you fix code following a failed build. The 'install' option will run 'make' + and 'make install' causing installation into the directory $AOMP_INSTALL_DIR. + The 'install' option will also create a symbolic link to directory $AOMP. + + Environment Variables: + You can set environment variables to override behavior of the build scripts + NAME DEFAULT DESCRIPTION + ---- ------- ----------- + AOMP $HOME/rocm/aomp Where the compiler will be installed + AOMP_REPOS $HOME/git/aomp11 Location of all aomp repos + BUILD_TYPE Release The CMAKE build type + BUILD_AOMP same as AOMP_REPOS Set a different build location than AOMP_REPOS + AOMP_USE_NINJA 0 Use ninja if possible + + To build a debug version of the compiler, run this command before the build: + export BUILD_TYPE=debug + + The BUILD_AOMP Envronment Variable: + The build scripts will always build with cmake and make outside your source git trees. + By default (without BUILD_AOMP) the build will occur in the "build" subdirectory of + AOMP_REPOS. For example build_llvm will build in $AOMP_REPOS/build/llvm + + The BUILD_AOMP environment variable enables source development outside your git + repositories. By default, this feature is OFF. The BUILD_AOMP environment variable + can be used if access to your git repositories is very slow or you want to test + changes outside of your local git repositories (specified by AOMP_REPOS env var). + If BUILD_AOMP is set, your git repositories (specifed by AOMP_REPOS) will be + replicated to subdirectories of BUILD_AOMP using rsync. The subsequent build + (cmake and make) will occur in subdirectory BUILD_AOMP/build/llvm. + This replication only happens on your initial build, that is, if you specify no arguments. + The option 'nocmake' skips replication and then restarts make in the build directory. + The install option skips replication, skips cmake, runs 'make' and 'make install'. + Be careful to always use options nocmake or install if you made local changes in + BUILD_AOMP or your changes will be lost by a new replica of your git repositories. + +EOF + exit 0 +} diff --git a/bin/build-deb-aomp.sh b/bin/build-deb-aomp.sh index 3643d2bc1..3a24f9181 100755 --- a/bin/build-deb-aomp.sh +++ b/bin/build-deb-aomp.sh @@ -12,6 +12,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build-rpm.sh b/bin/build-rpm.sh index 64f5870ea..0723e7c34 100755 --- a/bin/build-rpm.sh +++ b/bin/build-rpm.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_amdsmi.sh b/bin/build_amdsmi.sh index ffa078e5e..9a515b969 100755 --- a/bin/build_amdsmi.sh +++ b/bin/build_amdsmi.sh @@ -31,6 +31,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_aomp.sh b/bin/build_aomp.sh index a4e1e6ec2..7a7dab486 100755 --- a/bin/build_aomp.sh +++ b/bin/build_aomp.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_bolt.sh b/bin/build_bolt.sh index cd95b11f3..511791d0a 100755 --- a/bin/build_bolt.sh +++ b/bin/build_bolt.sh @@ -30,6 +30,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_comgr.sh b/bin/build_comgr.sh index 109bebf24..8b8643b5a 100755 --- a/bin/build_comgr.sh +++ b/bin/build_comgr.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_extras.sh b/bin/build_extras.sh index 78df1e164..31c712307 100755 --- a/bin/build_extras.sh +++ b/bin/build_extras.sh @@ -32,6 +32,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_fixups.sh b/bin/build_fixups.sh index 1b464462b..b8295b23d 100755 --- a/bin/build_fixups.sh +++ b/bin/build_fixups.sh @@ -7,6 +7,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_flang-classic.sh b/bin/build_flang-classic.sh index 4ad0a1d2f..19d174655 100755 --- a/bin/build_flang-classic.sh +++ b/bin/build_flang-classic.sh @@ -14,6 +14,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_flang.sh b/bin/build_flang.sh index 74f9162b2..23219d4f5 100755 --- a/bin/build_flang.sh +++ b/bin/build_flang.sh @@ -8,6 +8,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_flang_runtime.sh b/bin/build_flang_runtime.sh index 1bddf1538..ab2b2dab9 100755 --- a/bin/build_flang_runtime.sh +++ b/bin/build_flang_runtime.sh @@ -8,6 +8,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_hipamd.sh b/bin/build_hipamd.sh index 0a0ae14d1..ad79fb56d 100755 --- a/bin/build_hipamd.sh +++ b/bin/build_hipamd.sh @@ -30,6 +30,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_hipcc.sh b/bin/build_hipcc.sh index 7ad2314c4..eb23af4b8 100755 --- a/bin/build_hipcc.sh +++ b/bin/build_hipcc.sh @@ -26,6 +26,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_hipfort.sh b/bin/build_hipfort.sh index 83e584bbf..58522ae75 100755 --- a/bin/build_hipfort.sh +++ b/bin/build_hipfort.sh @@ -30,6 +30,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_hipify.sh b/bin/build_hipify.sh index e2b835f68..a925bcab1 100755 --- a/bin/build_hipify.sh +++ b/bin/build_hipify.sh @@ -26,6 +26,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_libdevice.sh b/bin/build_libdevice.sh index 511bfe416..a1693e67b 100755 --- a/bin/build_libdevice.sh +++ b/bin/build_libdevice.sh @@ -7,6 +7,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_llvm-classic.sh b/bin/build_llvm-classic.sh index b4fa8a6dc..3bba23c9c 100755 --- a/bin/build_llvm-classic.sh +++ b/bin/build_llvm-classic.sh @@ -14,6 +14,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_llvm-flang-rt-host-dev.sh b/bin/build_llvm-flang-rt-host-dev.sh index 739234a6f..303611083 100755 --- a/bin/build_llvm-flang-rt-host-dev.sh +++ b/bin/build_llvm-flang-rt-host-dev.sh @@ -15,6 +15,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_offload.sh b/bin/build_offload.sh index bedc4a6c1..2a935614c 100755 --- a/bin/build_offload.sh +++ b/bin/build_offload.sh @@ -4,12 +4,27 @@ # This script will install in location defined by AOMP env variable # +# Without these options, we can lose error status from command subtitutions, +# etc. +set -e +shopt -s inherit_errexit + # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- +# Get a configuration (environment) variable for this config +cfgvar() { + get_config_var_string offload "$1" +} + +cfgbool() { + get_config_var_bool offload "$1" +} + if [ "$1" == "-h" ] || [ "$1" == "help" ] || [ "$1" == "-help" ] ; then help_build_aomp fi @@ -17,491 +32,487 @@ fi REPO_DIR=$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME _ompd_src_dir="$LLVM_INSTALL_LOC/share/gdb/python/ompd/src" -if [ "$AOMP_BUILD_CUDA" == 1 ] ; then - CUDAH=$(find "$CUDAT" -type f -name "cuda.h" 2>/dev/null) - if [ "$CUDAH" == "" ] ; then - CUDAH=$(find "$CUDAINCLUDE" -type f -name "cuda.h" 2>/dev/null) - fi - if [ "$CUDAH" == "" ] ; then - echo - echo "ERROR: THE cuda.h FILE WAS NOT FOUND WITH ARCH $AOMP_PROC" - echo " A CUDA installation is necessary to build libomptarget deviceRTLs" - echo " Please install CUDA to build offload" - echo +get_src_dir() { + echo "$REPO_DIR/offload" +} + +# Print the build dir for a given config, passed as $1. +get_build_dir() { + local Cfg=$1 + local BuildDir + BuildDir="$(cfgvar BUILD_DIR)" + + case "$Cfg" in + "default") + echo -n "$BuildDir/offload" + ;; + "asan") + echo -n "$BuildDir/offload/asan" + ;; + "perf") + echo -n "$BuildDir/offload_perf" + ;; + "perf+asan") + echo -n "$BuildDir/offload_perf/asan" + ;; + "debug") + echo -n "$BuildDir/offload_debug" + ;; + "debug+asan") + echo -n "$BuildDir/offload_debug/asan" + ;; + *) + >&2 echo "Unknown config '$Cfg'" + exit 1 + ;; + esac +} + +# Print the install dir for a given config, passed as $1. +get_install_dir() { + cfgvar LLVM_INSTALL_LOC +} + +task_precheck() { + local CUDAVER + local SrcDir + local CUDAH + local CUDAVER + local BuildCUDA + local CUDATop + local CUDAInclude + local CUDABin + local AOMPProc + + SrcDir="$(get_src_dir)" + + if [ ! -d "$SrcDir" ] ; then + echo "ERROR: Missing repository $SrcDir " + echo " Consider setting env variables AOMP_REPOS and/or AOMP_PROJECT_REPO_NAME " exit 1 fi - # I don't see now nvcc is called, but this eliminates the deprecated warnings - export CUDAFE_FLAGS="-w" -fi - -if [ ! -d "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME" ] ; then - echo "ERROR: Missing repository $AOMP_REPOS/$AOMP_PROJECT_REPO_NAME " - echo " Consider setting env variables AOMP_REPOS and/or AOMP_PROJECT_REPO_NAME " - exit 1 -fi -check_writable_installdir "$1" "$LLVM_INSTALL_LOC" + check_writable_installdir "$1" "$(cfgvar LLVM_INSTALL_LOC)" -if [ "$AOMP_BUILD_CUDA" == 1 ] ; then - if [ -f "$CUDABIN/nvcc" ] ; then - CUDAVER=$("$CUDABIN"/nvcc --version | grep compilation | cut -d" " -f5 | cut -d"." -f1) - echo "CUDA VERSION IS $CUDAVER" - fi -fi - -if [ "$AOMP_USE_NINJA" == 0 ] ; then - AOMP_SET_NINJA_GEN=() -else - AOMP_SET_NINJA_GEN=(-G Ninja) -fi + BuildCUDA="$(cfgbool AOMP_BUILD_CUDA)" -export LLVM_DIR=$AOMP_INSTALL_DIR -GFXSEMICOLONS=$(echo "$GFXLIST" | tr ' ' ';') -ALTAOMP=${ALTAOMP:-$LLVM_INSTALL_LOC} - -declare -a COMMON_CMAKE_OPTS - -COMMON_CMAKE_OPTS=("${AOMP_SET_NINJA_GEN[@]}" -DOPENMP_ENABLE_LIBOMPTARGET=1 - -DCMAKE_INSTALL_PREFIX="$LLVM_INSTALL_LOC" - -DOPENMP_TEST_C_COMPILER="$LLVM_INSTALL_LOC/bin/clang" - -DOPENMP_TEST_CXX_COMPILER="$LLVM_INSTALL_LOC/bin/clang++" - -DCMAKE_C_COMPILER="$ALTAOMP/bin/clang" - -DCMAKE_CXX_COMPILER="$ALTAOMP/bin/clang++" - -DLIBOMPTARGET_AMDGCN_GFXLIST="$GFXSEMICOLONS" - -DLIBOMPTARGET_ENABLE_DEBUG=ON - -DLLVM_DIR="$LLVM_DIR") - -if [ "$AOMP_STANDALONE_BUILD" == 0 ]; then - COMMON_CMAKE_OPTS=("${COMMON_CMAKE_OPTS[@]}" - -DLLVM_MAIN_INCLUDE_DIR="$LLVM_PROJECT_ROOT/llvm/include" - -DLIBOMPTARGET_LLVM_INCLUDE_DIRS="$LLVM_PROJECT_ROOT/llvm/include") -else - COMMON_CMAKE_OPTS=("${COMMON_CMAKE_OPTS[@]}" - -DLLVM_MAIN_INCLUDE_DIR="$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/llvm/include" - -DLIBOMPTARGET_LLVM_INCLUDE_DIRS="$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/llvm/include") -fi + if "$BuildCUDA"; then + CUDATop=$(cfgvar CUDAT) + CUDAH=$(find "$CUDATop" -type f -name "cuda.h" 2>/dev/null) + if [ "$CUDAH" == "" ] ; then + CUDAInclude=$(cfgvar CUDAINCLUDE) + CUDAH=$(find "$CUDAInclude" -type f -name "cuda.h" 2>/dev/null) + fi + if [ "$CUDAH" == "" ] ; then + AOMPProc=$(cfgvar AOMP_PROC) + echo + echo "ERROR: THE cuda.h FILE WAS NOT FOUND WITH ARCH $AOMPProc" + echo " A CUDA installation is necessary to build libomptarget deviceRTLs" + echo " Please install CUDA to build offload" + echo + exit 1 + fi + # I don't see now nvcc is called, but this eliminates the deprecated warnings + export CUDAFE_FLAGS="-w" -if [ "$AOMP_BUILD_CUDA" == 1 ] ; then - COMMON_CMAKE_OPTS=("${COMMON_CMAKE_OPTS[@]}" - -DLIBOMPTARGET_NVPTX_ENABLE_BCLIB=ON - -DLIBOMPTARGET_NVPTX_CUDA_COMPILER="$AOMP/bin/clang++" - -DLIBOMPTARGET_NVPTX_BC_LINKER="$AOMP/bin/llvm-link" - -DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES="$NVPTXGPUS") -else -# Need to force CUDA off this way in case cuda is installed in this system - COMMON_CMAKE_OPTS=("${COMMON_CMAKE_OPTS[@]}" - -DCUDA_TOOLKIT_ROOT_DIR=OFF) -fi + CUDABin=$(cfgvar CUDABIN) + if [ -f "$CUDABin/nvcc" ] ; then + CUDAVER=$("$CUDABin"/nvcc --version | grep compilation | cut -d" " -f5 | cut -d"." -f1) + echo "CUDA VERSION IS $CUDAVER" + fi + fi +} + +task_clean() { + local Cfg=$1 + local BuildDir + BuildDir=$(get_build_dir "$1") + echo "rm -rf $(shquot "$BuildDir")" + rm -rf "$BuildDir" +} + +task_patch() { + local ApplyPatch + local RepoDir + ApplyPatch=$(cfgbool AOMP_APPLY_ATD_AMD_STAGING_PATCH) + RepoDir=$(cfgvar REPO_DIR) + # Patch llvm-project with ATD patch customized for amd-staging. + # WARNING: This patch (ATD_ASO_full.patch) rarely applies cleanly + # because of its size and constant trunk merges to amd-staging. + # This is why default is 0 (OFF). + if "$ApplyPatch" ; then + patchrepo "$RepoDir" + fi +} + +task_unpatch() { + local ApplyPatch + local RepoDir + ApplyPatch=$(cfgbool AOMP_APPLY_ATD_AMD_STAGING_PATCH) + RepoDir=$(cfgvar REPO_DIR) + if "$ApplyPatch" ; then + removepatch "$RepoDir" + fi +} + +asan_config() { + local Cfg=$1 + case "$Cfg" in + asan|*+asan) + return 0 + ;; + *) + ;; + esac + return 1 +} + +debug_config() { + local Cfg=$1 + case "$Cfg" in + debug|debug+*) + return 0 + ;; + *) + ;; + esac + return 1 +} + +perf_config() { + local Cfg=$1 + case "$Cfg" in + perf|perf+*) + return 0 + ;; + *) + ;; + esac + return 1 +} + +libdir_suffix() { + local Cfg=$1 + case "$Cfg" in + default) + ;; + asan) + echo "/asan" + ;; + perf) + printf "%s" "-perf" + ;; + perf+asan) + printf "%s" "-perf/asan" + ;; + debug) + printf "%s" "-debug" + ;; + debug+asan) + printf "%s" "-debug/asan" + ;; + *) + >&2 echo "Unknown config '$Cfg'" + exit 1 + esac +} + +task_cmake() { + local Cfg=$1 + local UseNinja + local -a AOMP_SET_NINJA_GEN + local GFXSEMICOLONS + local ALTAOMP + local Standalone + local -a MYCMAKEOPTS + local HSA_RUNTIME_PATH + local BuildDir + local _prefix_map + local LibdirSuffix + + UseNinja=$(cfgbool AOMP_USE_NINJA) + + if "$UseNinja"; then + AOMP_SET_NINJA_GEN=(-G Ninja) + fi -#if [ "$AOMP_BUILD_SANITIZER" == 1 ]; then - #LDFLAGS=$(shquot '-fuse-ld=lld' "${ASAN_FLAGS[@]}") - #export LDFLAGS -#fi + BuildDir=$(get_build_dir "$Cfg") -# This is how we tell the hsa plugin where to find hsa -export HSA_RUNTIME_PATH=$ROCM_DIR + export LLVM_DIR=$AOMP_INSTALL_DIR + GFXSEMICOLONS=$(echo "$GFXLIST" | tr ' ' ';') + ALTAOMP=${ALTAOMP:-$LLVM_INSTALL_LOC} -#breaks build as it cant find rocm-path -#export HIP_DEVICE_LIB_PATH=$ROCM_DIR/lib + Standalone=$(cfgbool AOMP_STANDALONE_BUILD) -# Patch llvm-project with ATD patch customized for amd-staging. -# WARNING: This patch (ATD_ASO_full.patch) rarely applies cleanly -# because of its size and constant trunk merges to amd-staging. -# This is why default is 0 (OFF). -if [ "$AOMP_APPLY_ATD_AMD_STAGING_PATCH" == 1 ] ; then - patchrepo "$REPO_DIR" -fi + MYCMAKEOPTS=("${AOMP_SET_NINJA_GEN[@]}" + -DOPENMP_ENABLE_LIBOMPTARGET=1 + -DCMAKE_INSTALL_PREFIX="$LLVM_INSTALL_LOC" + -DOPENMP_TEST_C_COMPILER="$LLVM_INSTALL_LOC/bin/clang" + -DOPENMP_TEST_CXX_COMPILER="$LLVM_INSTALL_LOC/bin/clang++" + -DCMAKE_C_COMPILER="$ALTAOMP/bin/clang" + -DCMAKE_CXX_COMPILER="$ALTAOMP/bin/clang++" + -DLIBOMPTARGET_AMDGCN_GFXLIST="$GFXSEMICOLONS" + -DLLVM_DIR="$LLVM_DIR") -declare -a ASAN_CMAKE_OPTS - -if [ "$1" != "nocmake" ] && [ "$1" != "install" ] ; then - echo " " - echo "This is a FRESH START. ERASING any previous builds in $BUILD_DIR/offload." - echo "Use ""$0 nocmake"" or ""$0 install"" to avoid FRESH START." - echo "rm -rf $BUILD_DIR/build/offload" - rm -rf "$BUILD_DIR/build/offload" - declare -a MYCMAKEOPTS - if [ "$AOMP_STANDALONE_BUILD" == 1 ]; then - MYCMAKEOPTS=("${COMMON_CMAKE_OPTS[@]}" - -DCMAKE_PREFIX_PATH="$AOMP_INSTALL_DIR/lib/cmake;$AOMP_INSTALL_DIR/lib64/cmake" - -DCMAKE_BUILD_TYPE=Release "${AOMP_ORIGIN_RPATH[@]}") + if ! "$Standalone" ; then + MYCMAKEOPTS+=(-DLLVM_MAIN_INCLUDE_DIR="$LLVM_PROJECT_ROOT/llvm/include" + -DLIBOMPTARGET_LLVM_INCLUDE_DIRS="$LLVM_PROJECT_ROOT/llvm/include") else - MYCMAKEOPTS=("${COMMON_CMAKE_OPTS[@]}" - -DCMAKE_PREFIX_PATH="$INSTALL_PREFIX/lib/cmake" - -DCMAKE_BUILD_TYPE=Release "${OPENMP_EXTRAS_ORIGIN_RPATH[@]}") + MYCMAKEOPTS+=(-DLLVM_MAIN_INCLUDE_DIR="$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/llvm/include" + -DLIBOMPTARGET_LLVM_INCLUDE_DIRS="$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/llvm/include") fi - if [ "$AOMP_LEGACY_OPENMP" == "1" ] && [ "$SANITIZER" != 1 ]; then - echo " -----Running offload cmake ---- " - mkdir -p "$BUILD_DIR/build/offload" - cd "$BUILD_DIR/build/offload" || exit - echo "${AOMP_CMAKE}" "$(shquot "${MYCMAKEOPTS[@]}")" \ - "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload" - - if ! ${AOMP_CMAKE} "${MYCMAKEOPTS[@]}" \ - "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload"; then - echo "ERROR offload cmake failed. Cmake flags" - echo " $(shquot "${MYCMAKEOPTS[@]}")" - exit 1 - fi + + if "$(cfgbool AOMP_BUILD_CUDA)"; then + MYCMAKEOPTS+=(-DLIBOMPTARGET_NVPTX_ENABLE_BCLIB=ON + -DLIBOMPTARGET_NVPTX_CUDA_COMPILER="$AOMP/bin/clang++" + -DLIBOMPTARGET_NVPTX_BC_LINKER="$AOMP/bin/llvm-link" + -DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES="$NVPTXGPUS") + else + # Need to force CUDA off this way in case cuda is installed in this system + MYCMAKEOPTS+=(-DCUDA_TOOLKIT_ROOT_DIR=OFF) fi - if [ "$AOMP_BUILD_SANITIZER" == 1 ]; then - if [ "$AOMP_STANDALONE_BUILD" == 1 ]; then - ASAN_CMAKE_OPTS=("${COMMON_CMAKE_OPTS[@]}" - -DCMAKE_PREFIX_PATH="$AOMP_INSTALL_DIR/lib/asan/cmake;$AOMP_INSTALL_DIR/lib/cmake;$AOMP_INSTALL_DIR/lib64/cmake" - -DSANITIZER_AMDGPU=1 -DCMAKE_BUILD_TYPE=Release - -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF - "${AOMP_ASAN_ORIGIN_RPATH[@]}") - else - ASAN_CMAKE_OPTS=("${COMMON_CMAKE_OPTS[@]}" - -DCMAKE_PREFIX_PATH="$ROCM_CMAKECONFIG_PATH;$INSTALL_PREFIX/lib/llvm/lib/asan" - -DSANITIZER_AMDGPU=1 -DCMAKE_BUILD_TYPE=Release - -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF - "${OPENMP_EXTRAS_ORIGIN_RPATH[@]}") - fi - echo " -----Running offload cmake for asan ---- " - mkdir -p "$BUILD_DIR/build/offload/asan" - cd "$BUILD_DIR/build/offload/asan" || exit - echo "${AOMP_CMAKE}" "$(shquot "${ASAN_CMAKE_OPTS[@]}")" \ - -DCMAKE_C_FLAGS="\"$(cmquot "${ASAN_FLAGS[@]}")\"" \ - -DCMAKE_CXX_FLAGS="\"$(cmquot "${ASAN_FLAGS[@]}")\"" \ - -DOFFLOAD_LIBDIR_SUFFIX="/asan" \ - -DLLVM_LIBDIR_SUFFIX="/asan" \ - "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload" - if ! ${AOMP_CMAKE} "${ASAN_CMAKE_OPTS[@]}" \ - -DCMAKE_C_FLAGS="$(cmquot "${ASAN_FLAGS[@]}")" \ - -DCMAKE_CXX_FLAGS="$(cmquot "${ASAN_FLAGS[@]}")" \ - -DOFFLOAD_LIBDIR_SUFFIX="/asan" \ - -DLLVM_LIBDIR_SUFFIX="/asan" \ - "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload"; then - echo "ERROR offload cmake failed. Cmake flags" - echo " $(shquot "${ASAN_CMAKE_OPTS[@]}")" - exit 1 - fi - fi - # Build a dedicatd "performance" version of libomptarget - if [ "$AOMP_BUILD_PERF" == "1" ]; then - echo "rm -rf $BUILD_DIR/build/offload_perf" - rm -rf "$BUILD_DIR/build/offload_perf" - MYCMAKEOPTS=("${COMMON_CMAKE_OPTS[@]}" - -DCMAKE_PREFIX_PATH="$AOMP_INSTALL_DIR/lib/cmake;$AOMP_INSTALL_DIR/lib64/cmake" - -DLIBOMPTARGET_ENABLE_DEBUG=OFF -DCMAKE_BUILD_TYPE=Release - -DLIBOMPTARGET_PERF=ON -DOFFLOAD_LIBDIR_SUFFIX=-perf - -DLLVM_LIBDIR_SUFFIX="-perf") - mkdir -p "$BUILD_DIR/build/offload_perf" - cd "$BUILD_DIR/build/offload_perf" || exit - echo " -----Running offload cmake for perf ---- " - echo "${AOMP_CMAKE}" "$(shquot "${MYCMAKEOPTS[@]}")" \ - "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload" \ - "$(shquot "${AOMP_ORIGIN_RPATH[@]}")" - - if ! ${AOMP_CMAKE} "${MYCMAKEOPTS[@]}" \ - "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload" \ - "${AOMP_ORIGIN_RPATH[@]}"; then - echo "error offload cmake failed. cmake flags" - echo " $(shquot "${MYCMAKEOPTS[@]}")" - exit 1 - fi - if [ "$AOMP_BUILD_SANITIZER" == 1 ]; then - ASAN_CMAKE_OPTS=("${COMMON_CMAKE_OPTS[@]}" - -DCMAKE_PREFIX_PATH="$AOMP_INSTALL_DIR/lib/asan/cmake;$AOMP_INSTALL_DIR/lib/cmake;$AOMP_INSTALL_DIR/lib64/cmake" - -DLIBOMPTARGET_ENABLE_DEBUG=OFF - -DCMAKE_BUILD_TYPE=Release - -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF - -DLIBOMPTARGET_PERF=ON -DSANITIZER_AMDGPU=1 - "${AOMP_ASAN_ORIGIN_RPATH[@]}") - echo " -----Running offload cmake for perf-asan ---- " - mkdir -p "$BUILD_DIR/build/offload_perf/asan" - cd "$BUILD_DIR/build/offload_perf/asan" || exit - echo "${AOMP_CMAKE}" "$(shquot "${ASAN_CMAKE_OPTS[@]}")" \ - -DCMAKE_C_FLAGS="\"$(cmquot "${ASAN_FLAGS[@]}")\"" \ - -DCMAKE_CXX_FLAGS="\"$(cmquot "${ASAN_FLAGS[@]}")\"" \ - -DOFFLOAD_LIBDIR_SUFFIX="-perf/asan" \ - -DLLVM_LIBDIR_SUFFIX="-perf/asan" \ - "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload" - - if ! ${AOMP_CMAKE} "${ASAN_CMAKE_OPTS[@]}" \ - -DCMAKE_C_FLAGS="$(cmquot "${ASAN_FLAGS[@]}")" \ - -DCMAKE_CXX_FLAGS="$(cmquot "${ASAN_FLAGS[@]}")" \ - -DOFFLOAD_LIBDIR_SUFFIX="-perf/asan" \ - -DLLVM_LIBDIR_SUFFIX="-perf/asan" \ - "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload"; then - echo "error offload cmake failed. cmake flags" - echo " $(shquot "${ASAN_CMAKE_OPTS[@]}")" - exit 1 - fi - fi - fi + #if [ "$AOMP_BUILD_SANITIZER" == 1 ]; then + #LDFLAGS=$(shquot '-fuse-ld=lld' "${ASAN_FLAGS[@]}") + #export LDFLAGS + #fi - if [ "$AOMP_BUILD_DEBUG" == "1" ] ; then - _prefix_map=(-fdebug-prefix-map="$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload=$_ompd_src_dir/offload") + # This is how we tell the hsa plugin where to find hsa + export HSA_RUNTIME_PATH=$ROCM_DIR - declare -a DEBUGCMAKEOPTS + #breaks build as it cant find rocm-path + #export HIP_DEVICE_LIB_PATH=$ROCM_DIR/lib - DEBUGCMAKEOPTS=(-DLIBOMPTARGET_NVPTX_DEBUG=ON - -DLLVM_ENABLE_ASSERTIONS=ON - -DCMAKE_BUILD_TYPE=Debug - -DROCM_DIR="$ROCM_DIR" - -DLIBOMP_ARCH=x86_64 - -DLIBOMP_OMPT_SUPPORT=ON - -DLIBOMP_USE_DEBUGGER=ON - -DLIBOMP_CPPFLAGS='-O0' - -DLIBOMP_OMPD_SUPPORT=ON - -DLIBOMP_OMPT_DEBUG=ON) + mkdir -p "$BuildDir" + pushd "$BuildDir" >& /dev/null || exit + + if perf_config "$Cfg"; then + MYCMAKEOPTS+=(-DLIBOMPTARGET_PERF=ON + -DLIBOMPTARGET_ENABLE_DEBUG=OFF) + else + MYCMAKEOPTS+=(-DLIBOMPTARGET_ENABLE_DEBUG=ON) + fi + + if debug_config "$Cfg"; then + MYCMAKEOPTS+=(-DLIBOMPTARGET_NVPTX_DEBUG=ON + -DLLVM_ENABLE_ASSERTIONS=ON + -DROCM_DIR="$ROCM_DIR" + -DCMAKE_BUILD_TYPE=Debug + -DLIBOMP_ARCH=x86_64 + -DLIBOMP_OMPT_SUPPORT=ON + -DLIBOMP_USE_DEBUGGER=ON + -DLIBOMP_CPPFLAGS='-O0' + -DLIBOMP_OMPD_SUPPORT=ON + -DLIBOMP_OMPT_DEBUG=ON) # The 'pip install --system' command is not supported on non-debian systems. This will disable # the system option if the debian_version file is not present. if [ ! -f /etc/debian_version ]; then echo "==> Non-Debian OS, disabling use of pip install --system" - DEBUGCMAKEOPTS=("${DEBUGCMAKEOPTS[@]}" -DDISABLE_SYSTEM_NON_DEBIAN=1) + MYCMAKEOPTS+=(-DDISABLE_SYSTEM_NON_DEBIAN=1) fi # Redhat 7.6 does not have python36-devel package, which is needed for ompd compilation. # This is acquired through RH Software Collections. if [ -f /opt/rh/rh-python36/enable ]; then echo "==> Using python3.6 out of rh tools." - DEBUGCMAKEOPTS=("${DEBUGCMAKEOPTS[@]}" - -DPython3_ROOT_DIR=/opt/rh/rh-python36/root/bin - -DPYTHON_HEADERS=/opt/rh/rh-python36/root/usr/include/python3.6m) + MYCMAKEOPTS+=(-DPython3_ROOT_DIR=/opt/rh/rh-python36/root/bin + -DPYTHON_HEADERS=/opt/rh/rh-python36/root/usr/include/python3.6m) fi + else + MYCMAKEOPTS+=(-DCMAKE_BUILD_TYPE=Release) + fi - echo - if [ "$SANITIZER" != 1 ] ; then - echo "rm -rf $BUILD_DIR/build/offload_debug" - rm -rf "$BUILD_DIR/build/offload_debug" - echo " -----Running offload cmake for debug ---- " - mkdir -p "$BUILD_DIR/build/offload_debug" - cd "$BUILD_DIR/build/offload_debug" || exit - if [ "$AOMP_STANDALONE_BUILD" == 1 ]; then - PREFIX_PATH="-DCMAKE_PREFIX_PATH=$AOMP_INSTALL_DIR/lib/cmake;$AOMP_INSTALL_DIR/lib64/cmake" - MYCMAKEOPTS=("${COMMON_CMAKE_OPTS[@]}" "${DEBUGCMAKEOPTS[@]}" - "${AOMP_DEBUG_ORIGIN_RPATH[@]}") - else - PREFIX_PATH="-DCMAKE_PREFIX_PATH=$INSTALL_PREFIX/lib/cmake" - MYCMAKEOPTS=("${COMMON_CMAKE_OPTS[@]}" "${DEBUGCMAKEOPTS[@]}" - "${OPENMP_EXTRAS_ORIGIN_RPATH[@]}") - fi + if asan_config "$Cfg"; then + MYCMAKEOPTS+=(-DSANITIZER_AMDGPU=1 + -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF) + fi - if ! ${AOMP_CMAKE} "${MYCMAKEOPTS[@]}" "$PREFIX_PATH" \ - -DCMAKE_C_FLAGS="$CFLAGS -g" \ - -DCMAKE_CXX_FLAGS="$CXXFLAGS -g $(cmquot "${_prefix_map[@]}")" \ - -DOFFLOAD_LIBDIR_SUFFIX="-debug" \ - -DLLVM_LIBDIR_SUFFIX="-debug" \ - "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload"; then - echo "ERROR offload debug cmake failed. Cmake flags" - echo " $(shquot "${MYCMAKEOPTS[@]}")" - exit 1 - fi - fi - if [ "$AOMP_BUILD_SANITIZER" == 1 ]; then - ASAN_CMAKE_OPTS=("${COMMON_CMAKE_OPTS[@]}" "${DEBUGCMAKEOPTS[@]}" - -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF - -DSANITIZER_AMDGPU=1) - if [ "$AOMP_STANDALONE_BUILD" == 1 ]; then - ASAN_CMAKE_OPTS=("${ASAN_CMAKE_OPTS[@]}" - -DCMAKE_PREFIX_PATH="$AOMP_INSTALL_DIR/lib/asan/cmake;$AOMP_INSTALL_DIR/lib/cmake;$AOMP_INSTALL_DIR/lib64/cmake" - "${AOMP_ASAN_ORIGIN_RPATH[@]}") + # rpath options + if "$Standalone"; then + if asan_config "$Cfg"; then + MYCMAKEOPTS+=("${AOMP_ASAN_ORIGIN_RPATH[@]}" + -DCMAKE_PREFIX_PATH="$AOMP_INSTALL_DIR/lib/asan/cmake;$AOMP_INSTALL_DIR/lib/cmake;$AOMP_INSTALL_DIR/lib64/cmake") + else + if debug_config "$Cfg"; then + MYCMAKEOPTS+=("${AOMP_DEBUG_ORIGIN_RPATH[@]}") else - ASAN_CMAKE_OPTS=("${ASAN_CMAKE_OPTS[@]}" - -DCMAKE_PREFIX_PATH="$ROCM_CMAKECONFIG_PATH;$INSTALL_PREFIX/lib/llvm/lib/asan" - "${OPENMP_EXTRAS_ORIGIN_RPATH[@]}") - fi - echo " -----Running offload cmake for debug-asan ---- " - mkdir -p "$BUILD_DIR/build/offload_debug/asan" - cd "$BUILD_DIR/build/offload_debug/asan" || exit - echo "${AOMP_CMAKE}" "${ASAN_CMAKE_OPTS[@]}" \ - -DCMAKE_C_FLAGS="\"$(cmquot "${ASAN_FLAGS[@]}")\"" \ - -DCMAKE_CXX_FLAGS="\"$(cmquot "${ASAN_FLAGS[@]}")\"" \ - -DOFFLOAD_LIBDIR_SUFFIX="-debug/asan" \ - -DLLVM_LIBDIR_SUFFIX="-debug/asan" \ - "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload" - - if ! ${AOMP_CMAKE} "${ASAN_CMAKE_OPTS[@]}" \ - -DCMAKE_C_FLAGS="$(cmquot "${ASAN_FLAGS[@]}")" \ - -DCMAKE_CXX_FLAGS="$(cmquot "${ASAN_FLAGS[@]}")" \ - -DOFFLOAD_LIBDIR_SUFFIX="-debug/asan" \ - -DLLVM_LIBDIR_SUFFIX="-debug/asan" \ - "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload"; then - echo "ERROR offload debug cmake failed. Cmake flags" - echo " $(shquot "${ASAN_CMAKE_OPTS[@]}")" - exit 1 + MYCMAKEOPTS+=("${AOMP_ORIGIN_RPATH[@]}") fi + MYCMAKEOPTS+=(-DCMAKE_PREFIX_PATH="$AOMP_INSTALL_DIR/lib/cmake;$AOMP_INSTALL_DIR/lib64/cmake") + fi + else + if asan_config "$Cfg"; then + MYCMAKEOPTS+=(-DCMAKE_PREFIX_PATH="$ROCM_CMAKECONFIG_PATH;$INSTALL_PREFIX/lib/llvm/lib/asan") + else + MYCMAKEOPTS+=(-DCMAKE_PREFIX_PATH="$INSTALL_PREFIX/lib/cmake") fi + MYCMAKEOPTS+=("${OPENMP_EXTRAS_ORIGIN_RPATH[@]}") fi -fi - -if [ "$1" = "cmake" ]; then - exit 0 -fi -if [ "$1" != "install" ] ; then -if [ "$AOMP_LEGACY_OPENMP" == "1" ] && [ "$SANITIZER" != 1 ] ; then - cd "$BUILD_DIR/build/offload" || exit - echo " -----Running $AOMP_NINJA_BIN for $BUILD_DIR/build/offload ---- " - if ! $AOMP_NINJA_BIN -j "$AOMP_JOB_THREADS"; then - echo " " - echo "ERROR: $AOMP_NINJA_BIN -j $AOMP_JOB_THREADS FAILED" - echo "To restart:" - echo " cd $BUILD_DIR/build/offload" - echo " $AOMP_NINJA_BIN" - exit 1 - fi -fi + # libdir suffix options + LibdirSuffix=$(libdir_suffix "$Cfg") -if [ "$AOMP_BUILD_SANITIZER" == 1 ] ; then - cd "$BUILD_DIR/build/offload/asan" || exit - echo " -----Running $AOMP_NINJA_BIN for $BUILD_DIR/build/offload/asan ---- " - - if ! $AOMP_NINJA_BIN -j "$AOMP_JOB_THREADS"; then - echo " " - echo "ERROR: $AOMP_NINJA_BIN -j $AOMP_JOB_THREADS FAILED" - echo "To restart:" - echo " cd $BUILD_DIR/build/offload/asan" - echo " $AOMP_NINJA_BIN" - exit 1 + if [ -n "$LibdirSuffix" ]; then + MYCMAKEOPTS+=(-DOFFLOAD_LIBDIR_SUFFIX="$LibdirSuffix" + -DLLVM_LIBDIR_SUFFIX="$LibdirSuffix") fi -fi -if [ "$AOMP_BUILD_PERF" == "1" ] ; then - cd "$BUILD_DIR/build/offload_perf" || exit - echo - echo - echo " -----Running $AOMP_NINJA_BIN for $BUILD_DIR/build/offload_perf ---- " - - if ! $AOMP_NINJA_BIN -j "$AOMP_JOB_THREADS"; then - echo "ERROR $AOMP_NINJA_BIN -j $AOMP_JOB_THREADS failed" - exit 1 - fi - if [ "$AOMP_BUILD_SANITIZER" == 1 ] ; then - cd "$BUILD_DIR/build/offload_perf/asan" || exit - echo - echo - echo " ----- Running $AOMP_NINJA_BIN for $BUILD_DIR/build/offload_perf/asan ----- " - - if ! $AOMP_NINJA_BIN -j "$AOMP_JOB_THREADS"; then - echo "ERROR $AOMP_NINJA_BIN -j $AOMP_JOB_THREADS failed" - exit 1 - fi + # C/C++ flags + if asan_config "$Cfg"; then + MYCMAKEOPTS+=(-DCMAKE_C_FLAGS="$(cmquot "${ASAN_FLAGS[@]}")" + -DCMAKE_CXX_FLAGS="$(cmquot "${ASAN_FLAGS[@]}")") + elif debug_config "$Cfg"; then + _prefix_map=(-fdebug-prefix-map="$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload=$_ompd_src_dir/offload") + MYCMAKEOPTS+=(-DCMAKE_C_FLAGS="$CFLAGS -g" + -DCMAKE_CXX_FLAGS="$CXXFLAGS -g $(cmquot "${_prefix_map[@]}")") fi -fi -if [ "$AOMP_BUILD_DEBUG" == "1" ] ; then - if [ "$SANITIZER" != 1 ] ; then - cd "$BUILD_DIR/build/offload_debug" || exit - echo - echo - echo " -----Running $AOMP_NINJA_BIN for $BUILD_DIR/build/offload_debug ---- " - - if ! $AOMP_NINJA_BIN -j "$AOMP_JOB_THREADS"; then - echo "ERROR $AOMP_NINJA_BIN -j $AOMP_JOB_THREADS failed" - exit 1 - fi - fi - if [ "$AOMP_BUILD_SANITIZER" == 1 ] ; then - cd "$BUILD_DIR/build/offload_debug/asan" || exit - echo - echo - echo " -----Running $AOMP_NINJA_BIN for $BUILD_DIR/build/offload_debug/asan ---- " - - if ! $AOMP_NINJA_BIN -j "$AOMP_JOB_THREADS"; then - echo "ERROR $AOMP_NINJA_BIN -j $AOMP_JOB_THREADS failed" - exit 1 - fi + echo "${AOMP_CMAKE}" "$(shquot "${MYCMAKEOPTS[@]}")" \ + "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload" + + if ! ${AOMP_CMAKE} "${MYCMAKEOPTS[@]}" \ + "$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload"; then + echo "ERROR offload cmake failed. Cmake flags" + echo " $(shquot "${MYCMAKEOPTS[@]}")" + exit 1 fi -fi - - echo - echo "Successful build of ./build_offload.sh . Please run:" - echo " ./build_offload.sh install " - echo -fi -# ----------- Install only if asked ---------------------------- -if [ "$1" == "install" ] ; then - if [ "$AOMP_LEGACY_OPENMP" == "1" ] && [ "$SANITIZER" != 1 ] ; then - cd "$BUILD_DIR/build/offload" || exit - echo - echo " -----Installing to $LLVM_INSTALL_LOC/lib ----- " - - if ! $SUDO "$AOMP_NINJA_BIN" -j "$AOMP_JOB_THREADS" install; then - echo "ERROR $AOMP_NINJA_BIN install failed " - exit 1 + popd >& /dev/null || exit +} + +task_build() { + local Cfg=$1 + local BuildDir + local NinjaBin + local Jobs + BuildDir=$(get_build_dir "$Cfg") + NinjaBin="$(cfgvar AOMP_NINJA_BIN)" + Jobs="$(cfgvar AOMP_JOB_THREADS)" + + pushd "$BuildDir" >& /dev/null || exit + echo " -----Running $NinjaBin for $BuildDir ---- " + if ! $NinjaBin -j "$Jobs"; then + echo " " + echo "ERROR: $NinjaBin -j $Jobs FAILED" + echo "To restart:" + echo " cd $BuildDir" + echo " $NinjaBin" + exit 1 fi - fi + popd >& /dev/null || exit +} - if [ "$AOMP_BUILD_SANITIZER" == 1 ] ; then - cd "$BUILD_DIR/build/offload/asan" || exit - echo - echo " -----Installing to $LLVM_INSTALL_LOC/lib/asan ----- " +task_install() { + local Cfg=$1 + local BuildDir + local NinjaBin + local Jobs + BuildDir=$(get_build_dir "$Cfg") + NinjaBin="$(cfgvar AOMP_NINJA_BIN)" + Jobs="$(cfgvar AOMP_JOB_THREADS)" - if ! $SUDO "$AOMP_NINJA_BIN" -j "$AOMP_JOB_THREADS" install; then - echo "ERROR $AOMP_NINJA_BIN install failed " - exit 1 - fi - fi + pushd "$BuildDir" >& /dev/null || exit - if [ "$AOMP_BUILD_PERF" == "1" ]; then - cd "$BUILD_DIR/build/offload_perf" || exit - echo - echo " -----Installing to $LLVM_INSTALL_LOC/lib-perf ----- " + echo " -----Installing to $LLVM_INSTALL_LOC/lib ----- " - if ! $SUDO "$AOMP_NINJA_BIN" -j "$AOMP_JOB_THREADS" install; then - echo "ERROR $AOMP_NINJA_BIN install failed " - exit 1 - fi - - if [ "$AOMP_BUILD_SANITIZER" == 1 ] ; then - cd "$BUILD_DIR/build/offload_perf/asan" || exit - echo - echo " ----- Installing to $LLVM_INSTALL_LOC/lib-perf/asan ----- " - - if ! $SUDO "$AOMP_NINJA_BIN" -j "$AOMP_JOB_THREADS" install; then - echo "ERROR $AOMP_NINJA_BIN install failed " - exit 1 - fi - fi + if ! $SUDO "$NinjaBin" -j "$Jobs" install; then + echo "ERROR $NinjaBin install failed " + exit 1 fi - if [ "$AOMP_BUILD_DEBUG" == "1" ] ; then - if [ "$SANITIZER" != 1 ] ; then - cd "$BUILD_DIR/build/offload_debug" || exit - echo - echo " -----Installing to $LLVM_INSTALL_LOC/lib-debug ---- " - - if ! $SUDO "$AOMP_NINJA_BIN" -j "$AOMP_JOB_THREADS" install; then - echo "ERROR $AOMP_NINJA_BIN install failed " - exit 1 - fi - fi - if [ "$AOMP_BUILD_SANITIZER" == 1 ] ; then - cd "$BUILD_DIR/build/offload_debug/asan" || exit - echo " -----Installing to $LLVM_INSTALL_LOC/lib-debug/asan ---- " - - if ! $SUDO "$AOMP_NINJA_BIN" -j "$AOMP_JOB_THREADS" install; then - echo "ERROR $AOMP_NINJA_BIN install failed " - exit 1 - fi - fi - - # Copy selected debugable runtime sources into the installation directory - # $_ompd_src_dir directory to satisfy the above CXXOPT -fdebug-prefix-map. - $SUDO mkdir -p "$_ompd_src_dir/offload" - $SUDO mkdir -p "$_ompd_src_dir/offload/plugins-nextgen" - if [ "$AOMP_STANDALONE_BUILD" == 1 ]; then - _from_dir_src="$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload/libomptarget" - _from_dir_plugins="$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload/plugins-nextgen" - else - _from_dir_src="$LLVM_PROJECT_ROOT/offload/libomptarget" - _from_dir_plugins="$LLVM_PROJECT_ROOT/offload/plugins-nextgen" - fi - echo cp -rp "$_from_dir_src" "$_ompd_src_dir/offload" - $SUDO cp -rp "$_from_dir_src" "$_ompd_src_dir/offload" - echo cp -rp "$_from_dir_plugins" "$_ompd_src_dir/offload" - $SUDO cp -rp "$_from_dir_plugins" "$_ompd_src_dir/offload" - fi # end of AOMP_BUILD_DEBUG install block - - if [ "$AOMP_APPLY_ATD_AMD_STAGING_PATCH" == 1 ] ; then - removepatch "$REPO_DIR" + popd >& /dev/null || exit +} + +task_postinstall() { + local Cfg=$1 + local Standalone + local LLVMRoot + local _from_dir_src + local _from_dir_plugins + + Standalone="$(cfgbool AOMP_STANDALONE_BUILD)" + LLVMRoot="$(cfgvar LLVM_PROJECT_ROOT)" + + # Copy selected debugable runtime sources into the installation directory + # $_ompd_src_dir directory to satisfy the above CXXOPT -fdebug-prefix-map. + $SUDO mkdir -p "$_ompd_src_dir/offload" + $SUDO mkdir -p "$_ompd_src_dir/offload/plugins-nextgen" + if "$Standalone"; then + _from_dir_src="$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload/libomptarget" + _from_dir_plugins="$AOMP_REPOS/$AOMP_PROJECT_REPO_NAME/offload/plugins-nextgen" + else + _from_dir_src="$LLVMRoot/offload/libomptarget" + _from_dir_plugins="$LLVMRoot/offload/plugins-nextgen" fi + echo cp -rp "$_from_dir_src" "$_ompd_src_dir/offload" + $SUDO cp -rp "$_from_dir_src" "$_ompd_src_dir/offload" + echo cp -rp "$_from_dir_plugins" "$_ompd_src_dir/offload" + $SUDO cp -rp "$_from_dir_plugins" "$_ompd_src_dir/offload" +} + +do_list_configs() { + local Sanitizer + local LegacyOpenMP + local BuildSanitizer + local BuildPerf + local BuildDebug + + Sanitizer="$(cfgbool SANITIZER)" + LegacyOpenMP="$(cfgbool AOMP_LEGACY_OPENMP)" + BuildSanitizer="$(cfgbool AOMP_BUILD_SANITIZER)" + BuildPerf="$(cfgbool AOMP_BUILD_PERF)" + BuildDebug="$(cfgbool AOMP_BUILD_DEBUG)" + + if ! "$Sanitizer" && "$LegacyOpenMP" ; then + echo "default" + fi + if "$BuildSanitizer"; then + echo "asan" + fi + if "$BuildPerf"; then + echo "perf" + if "$BuildSanitizer"; then + echo "perf+asan" + fi + fi + if "$BuildDebug" ; then + if ! "$Sanitizer"; then + echo "debug" + fi + if "$BuildSanitizer"; then + echo "debug+asan" + fi + fi +} + +do_list_init() { + echo "precheck" + echo "patch" +} + +do_list_fini() { + echo "unpatch" +} + +# List of tasks per config. +do_list_tasks() { + local Cfg=$1 + if valid_config "$Cfg"; then + echo "clean" + echo "cmake" + echo "build" + echo "install" + case "$Cfg" in + debug) + echo "postinstall" + ;; + *) + ;; + esac + else + echo "Unknown config '$Cfg'" + fi +} -fi # end of install block +command_dispatcher "$@" diff --git a/bin/build_openmp.sh b/bin/build_openmp.sh index fb4800d05..8655a8fe8 100755 --- a/bin/build_openmp.sh +++ b/bin/build_openmp.sh @@ -7,6 +7,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_pgmath.sh b/bin/build_pgmath.sh index cdd1045cf..ec03dc469 100755 --- a/bin/build_pgmath.sh +++ b/bin/build_pgmath.sh @@ -8,6 +8,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_project.sh b/bin/build_project.sh index 52c9d6e1b..c59776bb3 100755 --- a/bin/build_project.sh +++ b/bin/build_project.sh @@ -13,6 +13,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_qmcpack.sh b/bin/build_qmcpack.sh index 188913bde..ddd137bac 100755 --- a/bin/build_qmcpack.sh +++ b/bin/build_qmcpack.sh @@ -25,6 +25,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_rocdbgapi.sh b/bin/build_rocdbgapi.sh index 08ade0f1f..ca9fdeeab 100755 --- a/bin/build_rocdbgapi.sh +++ b/bin/build_rocdbgapi.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_rocgdb.sh b/bin/build_rocgdb.sh index 3cebec3c3..ff0fd140d 100755 --- a/bin/build_rocgdb.sh +++ b/bin/build_rocgdb.sh @@ -9,6 +9,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_rocm-cmake.sh b/bin/build_rocm-cmake.sh index 98f405935..cd67067f5 100755 --- a/bin/build_rocm-cmake.sh +++ b/bin/build_rocm-cmake.sh @@ -31,6 +31,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_rocm_smi_lib.sh b/bin/build_rocm_smi_lib.sh index b074713b7..7927ade7d 100755 --- a/bin/build_rocm_smi_lib.sh +++ b/bin/build_rocm_smi_lib.sh @@ -31,6 +31,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_rocminfo.sh b/bin/build_rocminfo.sh index 0af84d537..606aef31d 100755 --- a/bin/build_rocminfo.sh +++ b/bin/build_rocminfo.sh @@ -31,6 +31,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_rocprofiler-register.sh b/bin/build_rocprofiler-register.sh index 489a9136e..2094caa2d 100755 --- a/bin/build_rocprofiler-register.sh +++ b/bin/build_rocprofiler-register.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_rocprofiler-sdk.sh b/bin/build_rocprofiler-sdk.sh index b95222505..520c968d5 100755 --- a/bin/build_rocprofiler-sdk.sh +++ b/bin/build_rocprofiler-sdk.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_rocprofiler.sh b/bin/build_rocprofiler.sh index 8cf77057d..2b37b638f 100755 --- a/bin/build_rocprofiler.sh +++ b/bin/build_rocprofiler.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_rocr.sh b/bin/build_rocr.sh index b78bcb937..1d5958d5c 100755 --- a/bin/build_rocr.sh +++ b/bin/build_rocr.sh @@ -8,6 +8,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_roct.sh b/bin/build_roct.sh index e928aa3fa..aa8379b99 100755 --- a/bin/build_roct.sh +++ b/bin/build_roct.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_roctracer.sh b/bin/build_roctracer.sh index ec9dc3d66..58707b1e2 100755 --- a/bin/build_roctracer.sh +++ b/bin/build_roctracer.sh @@ -7,6 +7,7 @@ realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/build_supp.sh b/bin/build_supp.sh index 7ebc91249..2dda1bf32 100755 --- a/bin/build_supp.sh +++ b/bin/build_supp.sh @@ -58,6 +58,7 @@ PREREQUISITE_COMPONENTS=${PREREQUISITE_COMPONENTS:-cmake rocmsmilib hwloc aqlpro # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- FLANG=${FLANG:-flang} diff --git a/bin/build_supp_llvm-flang.sh b/bin/build_supp_llvm-flang.sh index d7c70accc..0766c1c3a 100755 --- a/bin/build_supp_llvm-flang.sh +++ b/bin/build_supp_llvm-flang.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/check_amdgpu_modversion.sh b/bin/check_amdgpu_modversion.sh index 4af2e7231..b4587847a 100755 --- a/bin/check_amdgpu_modversion.sh +++ b/bin/check_amdgpu_modversion.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" [ -f "$thisdir/aomp_common_vars" ] && . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/check_omptests.sh b/bin/check_omptests.sh index 453f5671b..a32e8de44 100755 --- a/bin/check_omptests.sh +++ b/bin/check_omptests.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/check_openmpvv.sh b/bin/check_openmpvv.sh index e28d1d124..9b7e82bc5 100755 --- a/bin/check_openmpvv.sh +++ b/bin/check_openmpvv.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/check_sollve.sh b/bin/check_sollve.sh index ecdbd7815..236f618c7 100755 --- a/bin/check_sollve.sh +++ b/bin/check_sollve.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/clone_aomp.sh b/bin/clone_aomp.sh index cd53cd162..f0f40f88d 100755 --- a/bin/clone_aomp.sh +++ b/bin/clone_aomp.sh @@ -8,6 +8,7 @@ realpath=$(realpath "$0") thisdir=$(dirname "$realpath") export AOMP_USE_CCACHE=${AOMP_USE_CCACHE:-0} +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/clone_epsdb_test.sh b/bin/clone_epsdb_test.sh index f949401b2..c385f9eb5 100755 --- a/bin/clone_epsdb_test.sh +++ b/bin/clone_epsdb_test.sh @@ -7,6 +7,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=$(realpath "$0") thisdir=$(dirname "$realpath") +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/clone_test.sh b/bin/clone_test.sh index 85d8686d5..77fd1fb42 100755 --- a/bin/clone_test.sh +++ b/bin/clone_test.sh @@ -9,6 +9,7 @@ realpath=$(realpath "$0") thisdir=$(dirname "$realpath") export AOMP_USE_CCACHE=${AOMP_USE_CCACHE:-0} +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/rocmlibs/build_half.sh b/bin/rocmlibs/build_half.sh index 418f56723..5349d93f7 100755 --- a/bin/rocmlibs/build_half.sh +++ b/bin/rocmlibs/build_half.sh @@ -5,6 +5,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_hipBLAS-common.sh b/bin/rocmlibs/build_hipBLAS-common.sh index ed16b6859..525ee5c03 100755 --- a/bin/rocmlibs/build_hipBLAS-common.sh +++ b/bin/rocmlibs/build_hipBLAS-common.sh @@ -8,6 +8,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_hipBLAS.sh b/bin/rocmlibs/build_hipBLAS.sh index 6483123e4..be34fcdaf 100755 --- a/bin/rocmlibs/build_hipBLAS.sh +++ b/bin/rocmlibs/build_hipBLAS.sh @@ -8,6 +8,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_hipRAND.sh b/bin/rocmlibs/build_hipRAND.sh index c35fab740..090967c1b 100755 --- a/bin/rocmlibs/build_hipRAND.sh +++ b/bin/rocmlibs/build_hipRAND.sh @@ -7,6 +7,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_hipSOLVER.sh b/bin/rocmlibs/build_hipSOLVER.sh index 05137d502..99c29fc3e 100755 --- a/bin/rocmlibs/build_hipSOLVER.sh +++ b/bin/rocmlibs/build_hipSOLVER.sh @@ -8,6 +8,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_powerinfer.sh b/bin/rocmlibs/build_powerinfer.sh index c23ce6bd0..354293419 100755 --- a/bin/rocmlibs/build_powerinfer.sh +++ b/bin/rocmlibs/build_powerinfer.sh @@ -8,6 +8,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_rccl.sh b/bin/rocmlibs/build_rccl.sh index 60534a535..6f543a3d6 100755 --- a/bin/rocmlibs/build_rccl.sh +++ b/bin/rocmlibs/build_rccl.sh @@ -10,6 +10,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_rocBLAS.sh b/bin/rocmlibs/build_rocBLAS.sh index 5eef6f8cc..489621b09 100755 --- a/bin/rocmlibs/build_rocBLAS.sh +++ b/bin/rocmlibs/build_rocBLAS.sh @@ -8,6 +8,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_rocPRIM.sh b/bin/rocmlibs/build_rocPRIM.sh index 32ff54e35..543268e6f 100755 --- a/bin/rocmlibs/build_rocPRIM.sh +++ b/bin/rocmlibs/build_rocPRIM.sh @@ -7,6 +7,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_rocRAND.sh b/bin/rocmlibs/build_rocRAND.sh index 3f7c16b14..c39a7d6e2 100755 --- a/bin/rocmlibs/build_rocRAND.sh +++ b/bin/rocmlibs/build_rocRAND.sh @@ -7,6 +7,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_rocSOLVER.sh b/bin/rocmlibs/build_rocSOLVER.sh index dd95c90a4..c72e7f218 100755 --- a/bin/rocmlibs/build_rocSOLVER.sh +++ b/bin/rocmlibs/build_rocSOLVER.sh @@ -8,6 +8,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_rocSPARSE.sh b/bin/rocmlibs/build_rocSPARSE.sh index e16c20fcd..ad971b02a 100755 --- a/bin/rocmlibs/build_rocSPARSE.sh +++ b/bin/rocmlibs/build_rocSPARSE.sh @@ -8,6 +8,7 @@ BUILD_TYPE=${BUILD_TYPE:-Release} # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/build_rocmlibs.sh b/bin/rocmlibs/build_rocmlibs.sh index 064c1fa71..6edde3f34 100755 --- a/bin/rocmlibs/build_rocmlibs.sh +++ b/bin/rocmlibs/build_rocmlibs.sh @@ -5,6 +5,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/clone_rocmlibs.sh b/bin/rocmlibs/clone_rocmlibs.sh index dac87fb08..ca71485c0 100755 --- a/bin/rocmlibs/clone_rocmlibs.sh +++ b/bin/rocmlibs/clone_rocmlibs.sh @@ -7,6 +7,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/rocmlibs/test_powerinfer.sh b/bin/rocmlibs/test_powerinfer.sh index 6cd011fd4..f2a2bc895 100755 --- a/bin/rocmlibs/test_powerinfer.sh +++ b/bin/rocmlibs/test_powerinfer.sh @@ -6,6 +6,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/../aomp_utils" . $thisdir/../aomp_common_vars # --- end standard header ---- diff --git a/bin/run_Fnekbone.sh b/bin/run_Fnekbone.sh index 9b7911301..961284b09 100755 --- a/bin/run_Fnekbone.sh +++ b/bin/run_Fnekbone.sh @@ -8,6 +8,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_OpenMP_VV.sh b/bin/run_OpenMP_VV.sh index 91d7ac485..348d383eb 100755 --- a/bin/run_OpenMP_VV.sh +++ b/bin/run_OpenMP_VV.sh @@ -19,7 +19,8 @@ realpath=$(realpath "$0") thisdir=$(dirname "${realpath}") export AOMP_USE_CCACHE=0 -. ${thisdir}/aomp_common_vars +. "$thisdir/aomp_utils" +. "${thisdir}"/aomp_common_vars # --- end standard header ---- # Setup AOMP variables diff --git a/bin/run_RSBench.sh b/bin/run_RSBench.sh index 1d176e23a..cddef37fd 100755 --- a/bin/run_RSBench.sh +++ b/bin/run_RSBench.sh @@ -8,6 +8,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_XSBench.sh b/bin/run_XSBench.sh index bc2b99487..91eba8c2f 100755 --- a/bin/run_XSBench.sh +++ b/bin/run_XSBench.sh @@ -8,6 +8,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_accel2023.sh b/bin/run_accel2023.sh index 567f88aed..894780239 100755 --- a/bin/run_accel2023.sh +++ b/bin/run_accel2023.sh @@ -9,6 +9,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars : ${ACCEL2023_SOURCE_DIR:=$AOMP_REPOS_TEST/accel2023-2.0.18} diff --git a/bin/run_babelstream.sh b/bin/run_babelstream.sh index 30426dd23..47538a629 100755 --- a/bin/run_babelstream.sh +++ b/bin/run_babelstream.sh @@ -30,6 +30,7 @@ export AOMP_USE_CCACHE=0 export ROCR_VISIBLE_DEVICES=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_composable-kernels.sh b/bin/run_composable-kernels.sh index 98c5cf50c..122d3dc84 100755 --- a/bin/run_composable-kernels.sh +++ b/bin/run_composable-kernels.sh @@ -11,6 +11,7 @@ CKBuildParallelism=$(free -g | grep Mem | awk '{print int($2/10)}') realpath=$(realpath $0) thisdir=$(dirname $realpath) +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars export PATH=$AOMP/bin:$PATH diff --git a/bin/run_fBabel.sh b/bin/run_fBabel.sh index fa1fca096..bd869d12c 100755 --- a/bin/run_fBabel.sh +++ b/bin/run_fBabel.sh @@ -18,6 +18,7 @@ export AOMP_USE_CCACHE=0 export ROCR_VISIBLE_DEVICES=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_genasis.sh b/bin/run_genasis.sh index 806572636..728496ae4 100755 --- a/bin/run_genasis.sh +++ b/bin/run_genasis.sh @@ -8,6 +8,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_genasis_flang_new.sh b/bin/run_genasis_flang_new.sh index 3a862878d..7e8d9a4f1 100755 --- a/bin/run_genasis_flang_new.sh +++ b/bin/run_genasis_flang_new.sh @@ -27,6 +27,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_gests.sh b/bin/run_gests.sh index 62cd6bb2a..b646f443c 100755 --- a/bin/run_gests.sh +++ b/bin/run_gests.sh @@ -8,6 +8,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_hpc2021.sh b/bin/run_hpc2021.sh index 4c070ee31..025be4cde 100755 --- a/bin/run_hpc2021.sh +++ b/bin/run_hpc2021.sh @@ -9,6 +9,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars : ${HPC2021_SOURCE_DIR:=$AOMP_REPOS_TEST/hpc2021-1.1.9} diff --git a/bin/run_hpcg.sh b/bin/run_hpcg.sh index b27a08266..678ea921d 100755 --- a/bin/run_hpcg.sh +++ b/bin/run_hpcg.sh @@ -7,6 +7,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars : ${HPCG_SOURCE_DIR:=$AOMP_REPOS_TEST/hpcg} diff --git a/bin/run_miniQMC.sh b/bin/run_miniQMC.sh index fef7f6244..a3669a8a9 100755 --- a/bin/run_miniQMC.sh +++ b/bin/run_miniQMC.sh @@ -13,6 +13,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_nekbone.sh b/bin/run_nekbone.sh index a43f95672..32a479a74 100755 --- a/bin/run_nekbone.sh +++ b/bin/run_nekbone.sh @@ -8,6 +8,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_nio.sh b/bin/run_nio.sh index 7a36d6c8e..cbd945ff9 100755 --- a/bin/run_nio.sh +++ b/bin/run_nio.sh @@ -5,6 +5,7 @@ # --- Start standard header to set AOMP environment variables ---- realpath=`realpath $0` thisdir=`dirname $realpath` +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_omptests.sh b/bin/run_omptests.sh index 21de8e4d8..a15744ef3 100755 --- a/bin/run_omptests.sh +++ b/bin/run_omptests.sh @@ -5,6 +5,7 @@ realpath=$(realpath "$0") thisdir=$(dirname "$realpath") export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . "$thisdir/aomp_common_vars" # --- end standard header ---- diff --git a/bin/run_openlibm_test.sh b/bin/run_openlibm_test.sh index b2a300631..90b94755d 100755 --- a/bin/run_openlibm_test.sh +++ b/bin/run_openlibm_test.sh @@ -5,6 +5,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_openmpapps.sh b/bin/run_openmpapps.sh index 3c664debf..9d61b35c9 100755 --- a/bin/run_openmpapps.sh +++ b/bin/run_openmpapps.sh @@ -8,6 +8,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_ovo.sh b/bin/run_ovo.sh index 8245a06ad..222ae6ed3 100755 --- a/bin/run_ovo.sh +++ b/bin/run_ovo.sh @@ -5,6 +5,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_rajaperf.sh b/bin/run_rajaperf.sh index 727b888c9..22d222515 100755 --- a/bin/run_rajaperf.sh +++ b/bin/run_rajaperf.sh @@ -5,6 +5,7 @@ realpath=$(realpath "$0") thisdir=$(dirname "$realpath") export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . "${thisdir}/aomp_common_vars" # --- end standard header ---- diff --git a/bin/run_rushlarsen.sh b/bin/run_rushlarsen.sh index f74cbd5c1..dc85a21f5 100755 --- a/bin/run_rushlarsen.sh +++ b/bin/run_rushlarsen.sh @@ -8,6 +8,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_sollve.sh b/bin/run_sollve.sh index 26991ece6..cb0436922 100755 --- a/bin/run_sollve.sh +++ b/bin/run_sollve.sh @@ -10,6 +10,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_su3bench.sh b/bin/run_su3bench.sh index a98a79d74..0c6937fce 100755 --- a/bin/run_su3bench.sh +++ b/bin/run_su3bench.sh @@ -8,6 +8,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ---- diff --git a/bin/run_umt.sh b/bin/run_umt.sh index 75cb3da27..eefab2c27 100755 --- a/bin/run_umt.sh +++ b/bin/run_umt.sh @@ -9,6 +9,7 @@ realpath=`realpath $0` thisdir=`dirname $realpath` export AOMP_USE_CCACHE=0 +. "$thisdir/aomp_utils" . $thisdir/aomp_common_vars # --- end standard header ----