Compare commits

...

4 Commits

Author SHA1 Message Date
Wang, Yanyao
66e8ada46c Test ROCm 6.1.2 build 2024-06-05 14:48:12 -07:00
Wang, Yanyao
673f1eed48 Fix Markdown formate for the linter check 2024-06-05 10:41:25 -07:00
Wang, Yanyao
5642d4f7b0 Update the branch of ROCm repo after testing 2024-06-05 09:50:20 -07:00
Wang, Yanyao
7f93d1635d Build ROCm from source 2024-06-04 21:20:04 -07:00
77 changed files with 10343 additions and 1 deletions

View File

@@ -56,12 +56,103 @@ cd ~/ROCm/
**Note:** Using this sample code will cause the repo tool to download the open source code associated with the specified ROCm release. Ensure that you have ssh-keys configured on your machine for your GitHub ID prior to the download as explained at [Connecting to GitHub with SSH](https://docs.github.com/en/authentication/connecting-to-github-with-ssh).
### Building the ROCm source code
## Building the ROCm source code
Each ROCm component repository contains directions for building that component, such as the rocSPARSE documentation [Installation and Building for Linux](https://rocm.docs.amd.com/projects/rocSPARSE/en/latest/install/Linux_Install_Guide.html). Refer to the specific component documentation for instructions on building the repository.
Each release of the ROCm software supports specific hardware and software configurations. Refer to [System requirements (Linux)](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/reference/system-requirements.html) for the current supported hardware and OS.
## Build ROCm from source
The Build will use as many processors as it can find to build in parallel. Some of the compiles can consume as much as 10GB of RAM, so make sure you have plenty of Swap Space !
By default the ROCm build will compile for all supported GPU architectures and will take approximately 500 CPU hours.
The Build time will reduce significantly if we limit the GPU Architecture/s against which we need to build by using the environment variable GPU_ARCHS as mentioned below.
```bash
# --------------------------------------
# Step1: clone source code
# --------------------------------------
mkdir -p ~/WORKSPACE/ # Or any folder name other than WORKSPACE
cd ~/WORKSPACE/
export ROCM_VERSION=6.1.0 # or 6.1.1
~/bin/repo init -u http://github.com/ROCm/ROCm.git -b roc-6.1.x -m rocm-build/rocm-${ROCM_VERSION}.xml
~/bin/repo sync
# --------------------------------------
# Step 2: Prepare build environment
# --------------------------------------
# Option 1: Start a docker container
# Pulling required base docker images:
# Ubuntu20.04 built from ROCm/rocm-build/docker/ubuntu20/Dockerfile
docker pull rocm/rocm-build-ubuntu-20.04:6.1
# Ubuntu22.04 built from ROCm/rocm-build/docker/ubuntu22/Dockerfile
docker pull rocm/rocm-build-ubuntu-22.04:6.1
# Start docker container and mount the source code folder:
docker run -ti \
-e ROCM_VERSION=${ROCM_VERSION} \
-e CCACHE_DIR=$HOME/.ccache \
-e CCACHE_ENABLED=true \
-e DOCK_WORK_FOLD=/src \
-w /src \
-v $PWD:/src \
-v /etc/passwd:/etc/passwd \
-v /etc/shadow:/etc/shadow \
-v ${HOME}/.ccache:${HOME}/.ccache \
-u $(id -u):$(id -g) \
<replace_with_required_ubuntu_base_docker_image> bash
# Option 2: Install required packages into the host machine
# For ubuntu20.04 system
cd ROCm/rocm-build/docker/ubuntu20
bash install-prerequisites.sh
# For ubuntu22.04 system
cd ROCm/rocm-build/docker/ubuntu22
bash install-prerequisities.sh
# --------------------------------------
# Step 3: Run build command line
# --------------------------------------
# Select GPU targets before building:
# When GPU_ARCHS is not set, default GPU targets supported by ROCm6.1 will be used.
# To build against a subset of GFX architectures you can use the below env variable.
# Support MI300 (gfx940, gfx941, gfx942).
export GPU_ARCHS="gfx942" # Example
export GPU_ARCHS="gfx940;gfx941;gfx942" # Example
# Pick and run build commands in the docker container:
# Build rocm-dev packages
make -f ROCm/rocm-build/ROCm.mk -j ${NPROC:-$(nproc)} rocm-dev
# Build all ROCm packages
make -f ROCm/rocm-build/ROCm.mk -j ${NPROC:-$(nproc)} all
# list all ROCm components to find required components
make -f ROCm/rocm-build/ROCm.mk list_components
# Build a single ROCm packages
make -f ROCm/rocm-build/ROCm.mk T_rocblas
# Find built packages in ubuntu20.04:
out/ubuntu-20.04/20.04/deb/
# Find built packages in ubuntu22.04:
out/ubuntu-22.04/22.04/deb/
# Find built logs in ubuntu20.04:
out/ubuntu-20.04/20.04/logs/
# Find built logs in ubuntu22.04:
out/ubuntu-22.04/22.04/logs/
# All logs pertaining to failed components, end with .errrors extension.
out/ubuntu-22.04/22.04/logs/rocblas.errors # Example
# All logs pertaining to building components, end with .inprogress extension.
out/ubuntu-22.04/22.04/logs/rocblas.inprogress # Example
# All logs pertaining to passed components, use the component names.
out/ubuntu-22.04/22.04/logs/rocblas # Example
```
Note: [Overview for ROCm.mk](rocm-build/README.md)
## ROCm documentation
This repository contains the [manifest file](https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md)

37
rocm-build/README.md Normal file
View File

@@ -0,0 +1,37 @@
# Overview for ROCm.mk
This Makefile builds the various projects that makes up ROCm in the correct order.
It is expected to be run in an environment with the tooling set up. An easy way
to do this is to use Docker.
## Targets
* all (default)
* rocm-dev (a subset of all)
* clean
* list_components
* help
* T_foo
* C_foo
## Makefile Variables
* PEVAL set to 1 to enable some Makefile debugging code.
* RELEASE\_FLAG set to "" to avoid passing "-r" to builds, effect is package defined.
* NOBUILD="foo bar" to avoid adding foo and bar into the dependencies of top level targets. They still may be
built if they are needed as dependencies of other top level targets.
* toplevel
## Makefile assumptions
### Requirements for package "foo"
#### program build\_foo.sh
* Should take option "-c" to clean
* Should take option "-r" to do a normal "RelWithDeb" build
### For package "foo" we define some targets
* T\_foo - The main build target, calls "build\_foo.sh -r"
* C\_foo - Clean target, calls "build_foo.sh -c"

248
rocm-build/ROCm.mk Normal file
View File

@@ -0,0 +1,248 @@
# Traditional first make target
all:
# Use bash as a shell
# On Ubuntu sh is 'dash'
SHELL:=bash
# Allow RELEASE_FLAG to be overwritten
RELEASE_FLAG?=-r
# Set SANITIZER_FLAG for sanitizer
ASAN_DEP:=
ifeq (${ENABLE_ADDRESS_SANITIZER},true)
ASAN_DEP=lightning
SANITIZER_FLAG=-a
endif
export INFRA_REPO:=ROCm/rocm-build
OUT_DIR:=$(shell . ${INFRA_REPO}/envsetup.sh >/dev/null 2>&1 ; echo $${OUT_DIR})
ROCM_INSTALL_PATH:=$(shell . ${INFRA_REPO}/envsetup.sh >/dev/null 2>&1 ; echo $${ROCM_INSTALL_PATH})
$(info OUT_DIR=${OUT_DIR})
$(info ROCM_INSTALL_PATH=${ROCM_INSTALL_PATH})
# -------------------------------------------------------------------------
# Internal stuff. Could be put in a different file to hide it.
# Internal macros, they need to be defined before being used.
# The internal "eval" allows parts of the Makefile to be generated.
# Whilst it is possible to dump the effective Makefile, it can be
# hard to see where parts come from. Set up the "peval" macro which
# optionally prints out the generated makefile snippet and evaluate it.
# Use "make PEVAL=1 all" to see the things being evaluated.
ifeq (,${PEVAL})
define peval =
$(eval $1)
endef
else
define peval =
$(eval $(info $1)$1)
endef
endif
# macro to add dependencies. Saves having to put all the OUT_DIR/logs in
# The outer strip is to work around a gnu make 4.1 and earlier bug
# It should not be needed.
define adddep =
$(strip $(call peval,components+= $(1) $(2))
$(foreach comp,$(strip $2),$(call peval,${OUT_DIR}/logs/${1}: ${OUT_DIR}/logs/${comp}))
)
endef
# End of internal stuff that is needed at the start of the file
# -------------------------------------------------------------------------
# Dependencies. These can be updated. Anything that is mentioned in
# either the args to the adddep macro will be added to components. as
# an example there is no need for the adddep of lightning, as it
# depends on nothing and at least one other component includes it.
# Syntax. Up to the first comma everything is fixed. The "call" is a
# keyword to gnu make. The "adddep" is the name of the variable containing
# the macro.
# The second comma delimited argument is the target.
# The third comma delimited arg is the thing that the target depends on.
# It is a space seperated list with zero or more elements.
$(call adddep,amd_smi_lib,${ASAN_DEP})
$(call adddep,aqlprofile,${ASAN_DEP} hsa)
$(call adddep,clang-ocl,lightning rocm-cmake)
$(call adddep,comgr,lightning devicelibs)
$(call adddep,dbgapi,hsa comgr)
$(call adddep,devicelibs,lightning)
$(call adddep,hip_on_rocclr,${ASAN_DEP} rocclr rocprofiler-register)
$(call adddep,hipcc,)
$(call adddep,hipify_clang,hip_on_rocclr lightning)
$(call adddep,hsa,${ASAN_DEP} thunk lightning devicelibs rocprofiler-register)
$(call adddep,lightning,)
$(call adddep,opencl_on_rocclr,${ASAN_DEP} rocclr)
$(call adddep,openmp_extras,thunk lightning devicelibs hsa)
$(call adddep,rdc,${ASAN_DEP} rocm_smi_lib hsa rocprofiler)
$(call adddep,rocclr,${ASAN_DEP} hsa comgr hipcc rocprofiler-register)
$(call adddep,rocm_bandwidth_test,${ASAN_DEP} hsa)
$(call adddep,rocm_smi_lib,${ASAN_DEP})
$(call adddep,rocm-cmake,${ASAN_DEP})
$(call adddep,rocm-core,${ASAN_DEP})
$(call adddep,rocm-gdb,dbgapi)
$(call adddep,rocminfo,${ASAN_DEP} hsa)
$(call adddep,rocprofiler-register,${ASAN_DEP})
$(call adddep,rocprofiler,${ASAN_DEP} hsa roctracer aqlprofile opencl_on_rocclr hip_on_rocclr comgr dbgapi rocm_smi_lib)
$(call adddep,rocr_debug_agent,${ASAN_DEP} hip_on_rocclr hsa dbgapi)
$(call adddep,roctracer,${ASAN_DEP} hsa hip_on_rocclr)
$(call adddep,thunk,${ASAN_DEP})
# rocm-dev points to all possible last finish components of Stage1 build.
rocm-dev-components :=rdc hipify_clang openmp_extras \
rocm-core amd_smi_lib hipcc clang-ocl \
rocm_bandwidth_test rocr_debug_agent rocm-gdb
$(call adddep,rocm-dev,$(filter-out ${NOBUILD},${rocm-dev-components}))
$(call adddep,amdmigraphx,hip_on_rocclr half rocblas miopen-hip lightning hipcc)
$(call adddep,composable_kernel,lightning hipcc hip_on_rocclr rocm-cmake)
$(call adddep,half,rocm-cmake)
$(call adddep,hipblas,hip_on_rocclr rocblas rocsolver lightning hipcc)
$(call adddep,hipblaslt,hip_on_rocclr openmp_extras hipblas lightning hipcc)
$(call adddep,hipcub,hip_on_rocclr rocprim lightning hipcc)
$(call adddep,hipfft,hip_on_rocclr openmp_extras rocfft rocrand hiprand lightning hipcc)
$(call adddep,hipfort,rocblas hipblas rocsparse hipsparse rocfft hipfft rocrand hiprand rocsolver hipsolver lightning hipcc)
$(call adddep,hiprand,hip_on_rocclr rocrand lightning hipcc)
$(call adddep,hipsolver,hip_on_rocclr rocblas rocsolver rocsparse lightning hipcc hipsparse)
$(call adddep,hipsparse,hip_on_rocclr rocsparse lightning hipcc)
$(call adddep,hipsparselt,hip_on_rocclr hipsparse lightning hipcc openmp_extras)
$(call adddep,hiptensor,hip_on_rocclr composable_kernel lightning hipcc)
$(call adddep,miopen-deps,lightning hipcc)
$(call adddep,miopen-hip,composable_kernel half hip_on_rocclr miopen-deps rocblas roctracer lightning hipcc)
$(call adddep,mivisionx,amdmigraphx miopen-hip rpp lightning hipcc)
$(call adddep,rccl,hip_on_rocclr hsa lightning hipcc rocm_smi_lib hipify_clang)
$(call adddep,rocalution,rocblas rocsparse rocrand lightning hipcc)
$(call adddep,rocblas,hip_on_rocclr openmp_extras lightning hipcc)
$(call adddep,rocdecode,hip_on_rocclr lightning hipcc)
$(call adddep,rocfft,hip_on_rocclr rocrand hiprand lightning hipcc openmp_extras)
$(call adddep,rocmvalidationsuite,hip_on_rocclr hsa rocblas rocm-core lightning hipcc rocm_smi_lib)
$(call adddep,rocprim,hip_on_rocclr lightning hipcc)
$(call adddep,rocrand,hip_on_rocclr lightning hipcc)
$(call adddep,rocsolver,hip_on_rocclr rocblas rocsparse lightning hipcc)
$(call adddep,rocsparse,hip_on_rocclr rocprim lightning hipcc)
$(call adddep,rocthrust,hip_on_rocclr rocprim lightning hipcc)
$(call adddep,rocwmma,hip_on_rocclr rocblas lightning hipcc rocm-cmake rocm_smi_lib)
$(call adddep,rpp,half lightning hipcc openmp_extras)
# -------------------------------------------------------------------------
# The rest of the file is internal
# Do not pass jobserver params if -n build
ifneq (,$(findstring n,${MAKEFLAGS}))
RMAKE:=
else
RMAKE := +
endif
# disable the builtin rules
.SUFFIXES:
# Linear
# include moredeps
# A macro to define a toplevel target, add it to the 'all' target
# Make it depend on the generated log. Generate the log of the build.
# See if the macro is already defined, if so don't touch it.
# As GNU make allows more than one makefile to be specified with "-f"
# one could put an alternative definition of "toplevel" in a different
# file or even the environment, and use the data in this file for other
# purposes. Uses might include generating output in "dot" format for
# showing the dependency graph, or having a wrapper script to run programs
# to generate code quality tools.
ifeq (${toplevel},)
# { Start of test to see if toplevel is defined
define toplevel =
# The "target" make, this builds the package if it is out of date
T_$1: ${OUT_DIR}/logs/$1 FRC
: $1 built
# The "upload" for $1, it uploads the packages for $1 to the central storage
U_$1: T_$1 FRC
source $${INFRA_REPO}/envsetup.sh && $${INFRA_REPO}/upload_packages.sh "$1"
: $1 uploaded
# The "clean" for $1, it just marks the target as not existing so it will be built
# in the future.
C_$1: FRC
rm -f ${OUT_DIR}/logs/$1 ${OUT_DIR}/logs/$1.repackaged
# parallel build {
${OUT_DIR}/logs/$1: | ${OUT_DIR}/logs
ifneq ($(wildcard ${OUT_DIR}/logs/$1.repackaged),)
@echo Skipping build of $1 as it has already been repackaged
cat $$@.repackaged > $$@
rm -f $$@.repackaged
else # } {
@echo $1 started due to $$? | sed "s:${OUT_DIR}/logs/::g"
# Build in a subshell so we get the time output
# Pass in jobserver info using the RMAKE variable
${RMAKE}@( if set -x && source $${INFRA_REPO}/envsetup.sh && \
rm -f $$@.errors $$@ $$@.repackaged && \
$${INFRA_REPO}/build_$1.sh -c && source $${INFRA_REPO}/ccache-env-mathlib.sh && \
time bash -x $${INFRA_REPO}/build_$1.sh $${RELEASE_FLAG} $${SANITIZER_FLAG} && $${INFRA_REPO}/post_inst_pkg.sh "$1" ; \
then mv $$@.inprogress $$@ ; \
else mv $$@.inprogress $$@.errors ; echo Error in $1 >&2 ; exit 1 ;\
fi ) > $$@.inprogress 2>&1
endif # }
# end of toplevel macro
endef
# } End of test to see if toplevel is defined
endif
components:=$(sort $(components))
# Create all the T_xxxx and C_xxxx targets
$(call peval,$(foreach dep,$(strip ${components}),$(call toplevel,${dep})))
# Add all the T_xxxx targets to "all" except those listed in NOBUILD
# Note this does not prohibit them from being built, it just means that
# a build of "all" will not force them to be built directly
# example command
# make -f jenkins-utils/scripts/Stage1.mk -j60
##help all: Build everything
all: $(addprefix T_,$(filter-out ${NOBUILD},${components}))
@echo All ROCm components built
# Do not document this target
upload: $(addprefix U_,${components})
@echo All ROCm components built and uploaded
##help rocm-dev: Build a subset of ROCm
rocm-dev: T_rocm-dev
@echo rocm-dev built
${OUT_DIR}/logs:
sudo mkdir -p -m 775 "${ROCM_INSTALL_PATH}" && \
sudo chown -R "$(shell id -u):$(shell id -g)" "${ROCM_INSTALL_PATH}"
sudo chown -R "$(shell id -u):$(shell id -g)" "/home/$(shell id -un)"
mkdir -p "${@}"
mkdir -p ${HOME}/.ccache
##help clean: remove the output directory and recreate it
clean:
[ -n "${OUT_DIR}" ] && rm -rf "${OUT_DIR}"
mkdir -p ${OUT_DIR}/logs
.SECONDARY: ${components:%=${OUT_DIR}/logs/%}
.PHONY: all clean repack help list_components
##help list_components: output the list of components
##help : Hint make list_components | paste - - - | column -t
list_components:
@echo "${components}" | sed 'y/ /\n/'
##help help: show this text
help:
@sed -n 's/^##help //p' ${MAKEFILE_LIST} | \
if type -t column > /dev/null ; then column -s: -t ; else cat ; fi
FRC:

145
rocm-build/build_amd_smi_lib.sh Executable file
View File

@@ -0,0 +1,145 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [-c|-r|-h] [makeopts]"
echo
echo "Options:"
echo " -c, --clean Removes all amd_smi build artifacts"
echo " -r, --release Build non-debug version amd_smi (default is debug)"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -s, --static Build static lib (.a). build instead of dynamic/shared(.so) "
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of type referred to by pkg_type"
echo " -p, --package <type> Specify packaging format"
echo " -h, --help Prints this help"
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
PACKAGE_ROOT="$(getPackageRoot)"
TARGET="build"
PACKAGE_LIB=$(getLibPath)
PACKAGE_INCLUDE="$(getIncludePath)"
AMDSMI_BUILD_DIR=$(getBuildPath amdsmi)
AMDSMI_PACKAGE_DEB_DIR="$(getPackageRoot)/deb/amdsmi"
AMDSMI_PACKAGE_RPM_DIR="$(getPackageRoot)/rpm/amdsmi"
AMDSMI_BUILD_TYPE="debug"
BUILD_TYPE="Debug"
MAKETARGET="deb"
MAKEARG="$DASH_JAY O=$AMDSMI_BUILD_DIR"
AMDSMI_MAKE_OPTS="$DASH_JAY O=$AMDSMI_BUILD_DIR -C $AMDSMI_BUILD_DIR"
AMDSMI_PKG_NAME="amd-smi-lib"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
PKGTYPE="deb"
VALID_STR=`getopt -o hcraso:p: --long help,clean,release,static,address_sanitizer,outdir:,package: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="RelWithDebInfo" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on
# TODO - support standard option of passing cmake environment vars - CFLAGS,CXXFLAGS etc., to enable address sanitizer
ADDRESS_SANITIZER=true ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-p | --package)
MAKETARGET="$2" ; shift 2;;
--) shift; break;; # end delimiter
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_amdsmi() {
rm -rf "$AMDSMI_BUILD_DIR"
rm -rf "$AMDSMI_PACKAGE_DEB_DIR"
rm -rf "$AMDSMI_PACKAGE_RPM_DIR"
rm -rf "$PACKAGE_ROOT/amd_smi"
rm -rf "$PACKAGE_INCLUDE/amd_smi"
rm -f $PACKAGE_LIB/libamd_smi.*
return 0
}
build_amdsmi() {
echo "Building AMDSMI"
echo "AMDSMI_BUILD_DIR: ${AMDSMI_BUILD_DIR}"
if [ ! -d "$AMDSMI_BUILD_DIR" ]; then
mkdir -p $AMDSMI_BUILD_DIR
pushd $AMDSMI_BUILD_DIR
print_lib_type $SHARED_LIBS
cmake \
-DBUILD_SHARED_LIBS=$SHARED_LIBS \
$(rocm_common_cmake_params) \
$(rocm_cmake_params) \
-DENABLE_LDCONFIG=OFF \
-DAMD_SMI_PACKAGE="${AMDSMI_PKG_NAME}" \
-DCPACK_PACKAGE_VERSION_MAJOR="1" \
-DCPACK_PACKAGE_VERSION_MINOR="$ROCM_LIBPATCH_VERSION" \
-DCPACK_PACKAGE_VERSION_PATCH="0" \
-DADDRESS_SANITIZER="$ADDRESS_SANITIZER" \
-DBUILD_TESTS=ON \
"$AMD_SMI_LIB_ROOT"
popd
fi
echo "Making amd_smi package:"
cmake --build "$AMDSMI_BUILD_DIR" -- $AMDSMI_MAKE_OPTS
cmake --build "$AMDSMI_BUILD_DIR" -- $AMDSMI_MAKE_OPTS install
cmake --build "$AMDSMI_BUILD_DIR" -- $AMDSMI_MAKE_OPTS package
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$AMDSMI_PACKAGE_DEB_DIR" $AMDSMI_BUILD_DIR/*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$AMDSMI_PACKAGE_RPM_DIR" $AMDSMI_BUILD_DIR/*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${AMDSMI_PACKAGE_DEB_DIR};;
("rpm")
echo ${AMDSMI_PACKAGE_RPM_DIR};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
verifyEnvSetup
case $TARGET in
(clean) clean_amdsmi ;;
(build) build_amdsmi ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"
exit 0

54
rocm-build/build_amdmigraphx.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src AMDMIGraphX
build_amdmigraphx() {
echo "Start build"
cd $COMPONENT_SRC
pip3 install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908;gfx90a;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
mkdir -p ${BUILD_DIR} && rm -rf ${BUILD_DIR}/* && mkdir -p ${HOME}/amdmigraphx && rm -rf ${HOME}/amdmigraphx/*
rbuild package -d "${HOME}/amdmigraphx" -B "${BUILD_DIR}" \
--cxx="${ROCM_PATH}/llvm/bin/clang++" \
--cc="${ROCM_PATH}/llvm/bin/clang" \
$(rocm_common_cmake_params) \
-DCMAKE_MODULE_LINKER_FLAGS="-Wl,--enable-new-dtags -Wl,--rpath,$ROCM_LIB_RPATH" \
-DGPU_TARGETS="${GPU_TARGETS}" \
-DCMAKE_INSTALL_RPATH=""
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
cd $BUILD_DIR && cmake --build . -- install -j${PROC}
show_build_cache_stats
}
clean_amdmigraphx() {
echo "Cleaning AMDMIGraphX build directory: ${BUILD_DIR} ${DEPS_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$DEPS_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_amdmigraphx ;;
outdir) print_output_directory ;;
clean) clean_amdmigraphx ;;
*) die "Invalid target $TARGET" ;;
esac

150
rocm-build/build_aqlprofile.sh Executable file
View File

@@ -0,0 +1,150 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: ${BASH_SOURCE##*/} [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -p, --package <type> Specify packaging format"
echo " -r, --release Make a release build instead of a debug build"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
API_NAME="hsa-amd-aqlprofile"
PACKAGE_DEB="$(getPackageRoot)/deb/$API_NAME"
PROJ_NAME="$API_NAME"
TARGET="build"
BUILD_TYPE="Debug"
MAKETARGET="deb"
MAKE_OPTS="$DASH_JAY -C $BUILD_DIR"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0
MAKETARGET="deb"
PKGTYPE="deb"
VALID_STR=$(getopt -o hcro:p: --long help,clean,release,clean,outdir:,package: -- "$@")
eval set -- "$VALID_STR"
while true; do
case "$1" in
-h | --help)
printUsage
exit 0
;;
-c | --clean)
TARGET="clean"
((CLEAN_OR_OUT |= 1))
shift
;;
-r | --release)
BUILD_TYPE="Release"
shift
;;
-o | --outdir)
TARGET="outdir"
PKGTYPE=$2
OUT_DIR_SPECIFIED=1
((CLEAN_OR_OUT |= 2))
shift 2
;;
--)
shift
break
;;
*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] " >&2
exit 20
;;
esac
done
copy_pkg_files_to_rocm() {
local comp_folder=$1
local comp_pkg_name=$2
cd "${OUT_DIR}/${PKGTYPE}/${comp_folder}"|| exit 2
if [ "${PKGTYPE}" = 'deb' ]; then
dpkg-deb -x ${comp_pkg_name}_*.deb pkg/
else
mkdir pkg && pushd pkg/ || exit 2
if [[ "${comp_pkg_name}" != *-dev* ]]; then
rpm2cpio ../${comp_pkg_name}-*.rpm | cpio -idmv
else
rpm2cpio ../${comp_pkg_name}el-*.rpm | cpio -idmv
fi
popd || exit 2
fi
ls ./pkg -alt
sudo cp -r ./pkg/*/rocm*/* "${ROCM_PATH}" || exit 2
rm -rf pkg/
}
clean() {
echo "Cleaning $PROJ_NAME package"
rm -rf "$PACKAGE_DEB"
}
build() {
echo "Downloading $PROJ_NAME" package
if [ "$DISTRO_NAME" = ubuntu ]; then
mkdir -p "$PACKAGE_DEB"
local rocm_ver=${ROCM_VERSION}
if [ ${ROCM_VERSION##*.} = 0 ]; then
rocm_ver=${ROCM_VERSION%.*}
fi
local url="https://repo.radeon.com/rocm/apt/${rocm_ver}/pool/main/h/${API_NAME}/"
local package
package=$(curl -s "$url" | grep -Po 'href="\K[^"]*' | grep "${DISTRO_RELEASE}" | head -n 1)
if [ -z "$package" ]; then
echo "No package found for Ubuntu version $DISTRO_RELEASE"
exit 1
fi
wget -t3 -P "$PACKAGE_DEB" "${url}${package}"
copy_pkg_files_to_rocm ${API_NAME} ${API_NAME}
else
echo "$DISTRO_ID is not supported..."
exit 2
fi
echo "Installing $PROJ_NAME" package
}
print_output_directory() {
case ${PKGTYPE} in
"deb")
echo ${PACKAGE_DEB}
;;
"rpm")
echo ${PACKAGE_RPM}
;;
*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2
exit 1
;;
esac
exit
}
case "$TARGET" in
clean) clean ;;
build) build ;;
outdir) print_output_directory ;;
*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

136
rocm-build/build_clang-ocl.sh Executable file
View File

@@ -0,0 +1,136 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [-c|-r|-h] [makeopts]"
echo
echo "Options:"
echo " -c, --clean Removes all clang-ocl build artifacts"
echo " -r, --release Build non-debug version clang-ocl (default is debug)"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo " -s, --static Supports static CI by accepting this param & not bailing out. No effect of the param though"
echo
return 0
}
TARGET="build"
CLANG_OCL_DEST="$(getBinPath)"
CLANG_OCL_SRC_ROOT="$CLANG_OCL_ROOT"
CLANG_OCL_BUILD_DIR="$(getBuildPath clang-ocl)"
MAKEARG="$DASH_JAY"
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_UTILS="$(getUtilsPath)"
CLANG_OCL_PACKAGE_DEB="$PACKAGE_ROOT/deb/clang-ocl"
CLANG_OCL_PACKAGE_RPM="$PACKAGE_ROOT/rpm/clang-ocl"
BUILD_TYPE="Debug"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
VALID_STR=`getopt -o hcraso:g: --long help,clean,release,clean,static,address_sanitizer,outdir:,gpu_list: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
MAKEARG="$MAKEARG BUILD_TYPE=rel" ; BUILD_TYPE="Release" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-g | --gpu_list )
GPU_LIST=$2; shift 2 ;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_clang-ocl() {
echo "Removing clang-ocl"
rm -rf $CLANG_OCL_DEST/clang-ocl
rm -rf $CLANG_OCL_BUILD_DIR
rm -rf $CLANG_OCL_PACKAGE_DEB
rm -rf $CLANG_OCL_PACKAGE_RPM
}
build_clang-ocl() {
if [ ! -d "$CLANG_OCL_BUILD_DIR" ]; then
mkdir -p $CLANG_OCL_BUILD_DIR
pushd $CLANG_OCL_BUILD_DIR
if [ -e $PACKAGE_ROOT/lib/bitcode/opencl.amdgcn.bc ]; then
BC_DIR="$ROCM_INSTALL_PATH/lib"
else
BC_DIR="$ROCM_INSTALL_PATH/amdgcn/bitcode"
fi
cmake \
$(rocm_cmake_params) \
-DDISABLE_CHECKS="ON" \
-DCLANG_BIN="$ROCM_INSTALL_PATH/llvm/bin" \
-DBITCODE_DIR="$BC_DIR" \
$(rocm_common_cmake_params) \
-DCPACK_SET_DESTDIR="OFF" \
$CLANG_OCL_SRC_ROOT
echo "Making clang-ocl:"
cmake --build . -- $MAKEARG
cmake --build . -- $MAKEARG install
cmake --build . -- $MAKEARG package
popd
fi
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$CLANG_OCL_PACKAGE_DEB" $CLANG_OCL_BUILD_DIR/rocm-clang-ocl*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$CLANG_OCL_PACKAGE_RPM" $CLANG_OCL_BUILD_DIR/rocm-clang-ocl*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${CLANG_OCL_PACKAGE_DEB};;
("rpm")
echo ${CLANG_OCL_PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
case $TARGET in
(clean) clean_clang-ocl ;;
(build) build_clang-ocl ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"
exit 0

151
rocm-build/build_comgr.sh Executable file
View File

@@ -0,0 +1,151 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -p, --package <type> Specify packaging format"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo " -s, --static Build static lib (.a). build instead of dynamic/shared(.so) "
echo " -l, --link_llvm_static Link to LLVM statically. Default is to dynamically link to LLVM; requires that LLVM dylibs are created."
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
API_NAME=amd_comgr
PROJ_NAME=$API_NAME
LIB_NAME=lib${API_NAME}
TARGET=build
MAKETARGET=deb
PACKAGE_ROOT=$(getPackageRoot)
PACKAGE_LIB=$(getLibPath)
PACKAGE_INCLUDE=$(getIncludePath)
BUILD_DIR=$(getBuildPath $API_NAME)
PACKAGE_DEB=$(getPackageRoot)/deb/$API_NAME
PACKAGE_RPM=$(getPackageRoot)/rpm/$API_NAME
PACKAGE_PREFIX=$ROCM_INSTALL_PATH
BUILD_TYPE=Debug
MAKE_OPTS="$DASH_JAY CTEST_OUTPUT_ON_FAILURE=1 -C $BUILD_DIR"
VERBOSE_OPTS="AMD_COMGR_EMIT_VERBOSE_LOGS=1 AMD_COMGR_REDIRECT_LOGS=stdout"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
PKGTYPE="deb"
MAKETARGET="deb"
LINK_LLVM_DYLIB="OFF"
VALID_STR=`getopt -o hcraslo:p: --long help,clean,release,address_sanitizer,static,link_llvm_static,outdir:,package: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="RelWithDebInfo" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-l | --link_llvm_static)
LINK_LLVM_DYLIB="OFF"; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-p | --package)
MAKETARGET="$2" ; shift 2;;
--) shift; break;; # end delimiter
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean() {
echo "Cleaning $PROJ_NAME"
rm -rf $BUILD_DIR
rm -rf $PACKAGE_DEB
rm -rf $PACKAGE_RPM
rm -rf $PACKAGE_ROOT/${PROJ_NAME}
rm -rf $PACKAGE_LIB/${LIB_NAME}*
}
build() {
echo "Building $PROJ_NAME"
mkdir -p "$BUILD_DIR"
pushd "$BUILD_DIR"
if [ "$SHARED_LIBS" == "OFF" ]
then
echo " Building Archive "
else
echo " Building Shared Object "
fi
cmake \
$(rocm_cmake_params) \
-DBUILD_SHARED_LIBS=$SHARED_LIBS \
$(rocm_common_cmake_params) \
-DCMAKE_DISABLE_FIND_PACKAGE_hip=TRUE \
-DCMAKE_CTEST_ARGUMENTS="--exclude-regex;multithread_test" \
-DLLVM_LINK_LLVM_DYLIB=$LINK_LLVM_DYLIB \
-DLLVM_ENABLE_LIBCXX=$LINK_LLVM_DYLIB \
$COMGR_ROOT
popd
cmake --build "$BUILD_DIR" -- $MAKE_OPTS
cmake --build "$BUILD_DIR" -- $MAKE_OPTS $VERBOSE_OPTS test
cmake --build "$BUILD_DIR" -- $MAKE_OPTS install
cmake --build "$BUILD_DIR" -- $MAKE_OPTS package
mkdir -p $PACKAGE_LIB
cp -R $BUILD_DIR/${LIB_NAME}* $PACKAGE_LIB
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_DEB" $BUILD_DIR/comgr*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_RPM" $BUILD_DIR/comgr*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${PACKAGE_DEB};;
("rpm")
echo ${PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
verifyEnvSetup
case $TARGET in
(clean) clean ;;
(build) build ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

View File

@@ -0,0 +1,185 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src composable_kernel
build_miopen_ck() {
echo "Start Building Composable Kernel"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
cd $COMPONENT_SRC
mkdir "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908;gfx90a;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
if [ "${ASAN_CMAKE_PARAMS}" == "true" ] ; then
cmake -DBUILD_DEV=OFF \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE:-'RelWithDebInfo'} \
-DCMAKE_CXX_COMPILER=${ROCM_PATH}/llvm/bin/clang++ \
-DCMAKE_CXX_FLAGS=" -O3 " \
-DCMAKE_PREFIX_PATH="${ROCM_PATH%-*}/lib/cmake;${ROCM_PATH%-*}/$ASAN_LIBDIR;${ROCM_PATH%-*}/llvm;${ROCM_PATH%-*}" \
-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,--enable-new-dtags,--rpath,$ROCM_ASAN_LIB_RPATH" \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-Wl,--enable-new-dtags,--rpath,$ROCM_ASAN_EXE_RPATH" \
-DCMAKE_VERBOSE_MAKEFILE=1 \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE \
-DCMAKE_INSTALL_PREFIX=${ROCM_PATH} \
-DCMAKE_PACKAGING_INSTALL_PREFIX=${ROCM_PATH} \
-DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=OFF \
-DROCM_SYMLINK_LIBS=OFF \
-DCPACK_PACKAGING_INSTALL_PREFIX=${ROCM_PATH} \
-DROCM_DISABLE_LDCONFIG=ON \
-DROCM_PATH=${ROCM_PATH} \
-DCPACK_GENERATOR="${PKGTYPE^^}" \
${LAUNCHER_FLAGS} \
-DINSTANCES_ONLY=ON \
-DENABLE_ASAN_PACKAGING=true \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
"$COMPONENT_SRC"
else
cmake -DBUILD_DEV=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=${ROCM_PATH}/llvm/bin/clang++ \
-DCMAKE_CXX_FLAGS=" -O3 " \
-DCMAKE_PREFIX_PATH=${ROCM_PATH%-*} \
-DCMAKE_SHARED_LINKER_FLAGS_INIT='-Wl,--enable-new-dtags,--rpath,$ORIGIN' \
-DCMAKE_EXE_LINKER_FLAGS_INIT='-Wl,--enable-new-dtags,--rpath,$ORIGIN/../lib' \
-DCMAKE_VERBOSE_MAKEFILE=1 \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE \
-DCMAKE_INSTALL_PREFIX=${ROCM_PATH} \
-DCMAKE_PACKAGING_INSTALL_PREFIX=${ROCM_PATH} \
-DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=OFF \
-DROCM_SYMLINK_LIBS=OFF \
-DCPACK_PACKAGING_INSTALL_PREFIX=${ROCM_PATH} \
-DROCM_DISABLE_LDCONFIG=ON \
-DROCM_PATH=${ROCM_PATH} \
-DCPACK_GENERATOR="${PKGTYPE^^}" \
${LAUNCHER_FLAGS} \
-DINSTANCES_ONLY=ON \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
"$COMPONENT_SRC"
fi
cmake --build . -- -j${PROC} package
cmake --build "$BUILD_DIR" -- install
mkdir -p $PACKAGE_DIR && cp ./*.${PKGTYPE} $PACKAGE_DIR
rm -rf *
}
unset_asan_env_vars() {
ASAN_CMAKE_PARAMS="false"
export ADDRESS_SANITIZER="OFF"
export LD_LIBRARY_PATH=""
export ASAN_OPTIONS=""
}
set_address_sanitizer_off() {
export CFLAGS=""
export CXXFLAGS=""
export LDFLAGS=""
}
build_miopen_ckProf() {
ENABLE_ADDRESS_SANITIZER=false
echo "Start Building Composable Kernel Profiler"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
else
unset_asan_env_vars
set_address_sanitizer_off
fi
cd $COMPONENT_SRC
cd "$BUILD_DIR"
rm -rf *
architectures='gfx10 gfx11 gfx90 gfx94'
if [ -n "$GPU_ARCHS" ]; then
architectures=$(echo ${GPU_ARCHS} | awk -F';' '{for(i=1;i<=NF;i++) a[substr($i,1,5)]} END{for(i in a) printf i" "}')
else
architectures='gfx10 gfx11 gfx90 gfx94'
fi
for arch in ${architectures}
do
if [ "${ASAN_CMAKE_PARAMS}" == "true" ] ; then
cmake -DBUILD_DEV=OFF \
-DCMAKE_PREFIX_PATH="${ROCM_PATH%-*}/lib/cmake;${ROCM_PATH%-*}/$ASAN_LIBDIR;${ROCM_PATH%-*}/llvm;${ROCM_PATH%-*}" \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE:-'RelWithDebInfo'} \
-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,--enable-new-dtags,--rpath,$ROCM_ASAN_LIB_RPATH" \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-Wl,--enable-new-dtags,--rpath,$ROCM_ASAN_EXE_RPATH" \
-DCMAKE_VERBOSE_MAKEFILE=1 \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE \
-DCMAKE_INSTALL_PREFIX="${ROCM_PATH}" \
-DCMAKE_PACKAGING_INSTALL_PREFIX="${ROCM_PATH}" \
-DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=OFF \
-DROCM_SYMLINK_LIBS=OFF \
-DCPACK_PACKAGING_INSTALL_PREFIX="${ROCM_PATH}" \
-DROCM_DISABLE_LDCONFIG=ON \
-DROCM_PATH="${ROCM_PATH}" \
-DCPACK_GENERATOR="${PKGTYPE^^}" \
-DCMAKE_CXX_COMPILER="${ROCM_PATH}/llvm/bin/clang++" \
-DCMAKE_C_COMPILER="${ROCM_PATH}/llvm/bin/clang" \
${LAUNCHER_FLAGS} \
-DPROFILER_ONLY=ON \
-DENABLE_ASAN_PACKAGING=true \
-DGPU_ARCH="${arch}" \
"$COMPONENT_SRC"
else
cmake -DBUILD_DEV=OFF \
-DCMAKE_PREFIX_PATH="${ROCM_PATH%-*}" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SHARED_LINKER_FLAGS_INIT='-Wl,--enable-new-dtags,--rpath,$ORIGIN' \
-DCMAKE_EXE_LINKER_FLAGS_INIT='-Wl,--enable-new-dtags,--rpath,$ORIGIN/../lib' \
-DCMAKE_VERBOSE_MAKEFILE=1 \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE \
-DCMAKE_INSTALL_PREFIX="${ROCM_PATH}" \
-DCMAKE_PACKAGING_INSTALL_PREFIX="${ROCM_PATH}" \
-DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=OFF \
-DROCM_SYMLINK_LIBS=OFF \
-DCPACK_PACKAGING_INSTALL_PREFIX="${ROCM_PATH}" \
-DROCM_DISABLE_LDCONFIG=ON \
-DROCM_PATH="${ROCM_PATH}" \
-DCPACK_GENERATOR="${PKGTYPE^^}" \
-DCMAKE_CXX_COMPILER="${ROCM_PATH}/llvm/bin/clang++" \
-DCMAKE_C_COMPILER="${ROCM_PATH}/llvm/bin/clang" \
${LAUNCHER_FLAGS} \
-DPROFILER_ONLY=ON \
-DGPU_ARCH="${arch}" \
"$COMPONENT_SRC"
fi
cmake --build . -- -j${PROC} package
cp ./*ckprofiler*.${PKGTYPE} $PACKAGE_DIR
rm -rf *
done
rm -rf _CPack_Packages/ && find -name '*.o' -delete
echo "Finished building Composable Kernel"
show_build_cache_stats
}
clean_miopen_ck() {
echo "Cleaning MIOpen-CK build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_miopen_ck; build_miopen_ckProf;;
outdir) print_output_directory ;;
clean) clean_miopen_ck ;;
*) die "Invalid target $TARGET" ;;
esac

159
rocm-build/build_dbgapi.sh Executable file
View File

@@ -0,0 +1,159 @@
#!/bin/bash
source "${BASH_SOURCE%/*}/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE[0]}") [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -p, --package <type> Specify packaging format"
echo " -r, --release Make a release build instead of a debug build"
echo " --enable-assertions Enable assertions"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo " -M, --skip_man_pages Do not build the 'docs' target"
echo " -s, --static Supports static CI by accepting this param & not bailing out. No effect of the param though"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
API_NAME=rocm-dbgapi
AMD_DBGAPI_NAME=amd-dbgapi
MAKEINSTALL_MANIFEST=makeinstall_manifest.txt
PROJ_NAME=$API_NAME
LIB_NAME=lib${API_NAME}.so
TARGET=build
MAKETARGET=deb
PACKAGE_ROOT=$(getPackageRoot)
PACKAGE_LIB=$(getLibPath)
PACKAGE_INCLUDE=$(getIncludePath)
BUILD_DIR=$(getBuildPath $API_NAME)
PACKAGE_DEB=$(getPackageRoot)/deb/$API_NAME
PACKAGE_RPM=$(getPackageRoot)/rpm/$API_NAME
BUILD_TYPE=Debug
MAKE_OPTS=($DASH_JAY -C "$BUILD_DIR")
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
DODOCSBUILD=true
VALID_STR=$(getopt -o hcraso:p:M --long help,clean,release,enable-assertions,static,address_sanitizer,outdir:,package:skip_man_pages -- "$@")
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ;;
(-r | --release)
ENABLE_ASSERTIONS=${ENABLE_ASSERTIONS:-"Off"} ;
BUILD_TYPE="RelWithDebInfo" ;;
( --enable-assertions)
ENABLE_ASSERTIONS="On" ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ;;
(-s | --static)
SHARED_LIBS="OFF" ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; ((CLEAN_OR_OUT|=2)) ; shift 1 ;;
(-M | --skip_man_pages) DODOCSBUILD=false;;
(-p | --package)
MAKETARGET="$2" ; shift 1;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
shift
done
check_conflicting_options $CLEAN_OR_OUT "$PKGTYPE" "$MAKETARGET"
if [ "$RET_CONFLICT" -ge 30 ]; then
print_vars "$API_NAME" "$TARGET" "$BUILD_TYPE" "$SHARED_LIBS" "$CLEAN_OR_OUT" "$PKGTYPE" "$MAKETARGET"
exit "$RET_CONFLICT"
fi
clean() {
echo "Cleaning $PROJ_NAME"
if [ -e "$BUILD_DIR/$MAKEINSTALL_MANIFEST" ] ; then
xargs rm -f < "$BUILD_DIR/$MAKEINSTALL_MANIFEST"
fi
rm -rf "$BUILD_DIR"
rm -rf "$PACKAGE_DEB"
rm -rf "$PACKAGE_RPM"
rm -rf "${PACKAGE_ROOT:?}/${PROJ_NAME}"
rm -rf "${PACKAGE_LIB:?}/${LIB_NAME}"*
rm -rf "${PACKAGE_LIB:?}/cmake/${AMD_DBGAPI_NAME}"
rm -rf "${PACKAGE_INCLUDE:?}/${AMD_DBGAPI_NAME}"
}
build() {
if [ ! -e "$ROCM_DBGAPI_ROOT/CMakeLists.txt" ]
then
echo " No $ROCM_DBGAPI_ROOT/CMakeLists.txt file, skipping rocm-dbgapi" >&2
echo " No $ROCM_DBGAPI_ROOT/CMakeLists.txt file, skipping rocm-dbgapi"
exit 0
fi
echo "Building $PROJ_NAME"
mkdir -p "$BUILD_DIR"
pushd "$BUILD_DIR" || exit 99
cmake \
$(rocm_cmake_params) \
$(rocm_common_cmake_params) \
-DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS:-"On"} \
"$ROCM_DBGAPI_ROOT"
popd || exit 99
cmake --build "$BUILD_DIR" -- "${MAKE_OPTS[@]}"
"$DODOCSBUILD" && cmake --build "$BUILD_DIR" -- "${MAKE_OPTS[@]}" doc
cmake --build "$BUILD_DIR" -- "${MAKE_OPTS[@]}" install
mv "$BUILD_DIR/install_manifest.txt" "$BUILD_DIR/$MAKEINSTALL_MANIFEST"
cmake --build "$BUILD_DIR" -- "${MAKE_OPTS[@]}" package
mkdir -p "$PACKAGE_LIB"
(
shopt -s nullglob
cp -R "$BUILD_DIR/lib/${LIB_NAME}"* "$BUILD_DIR/${LIB_NAME}"* "$PACKAGE_LIB"
)
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_DEB" "$BUILD_DIR/${API_NAME}"*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_RPM" "$BUILD_DIR/${API_NAME}"*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${PACKAGE_DEB};;
("rpm")
echo ${PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
verifyEnvSetup
case $TARGET in
(clean) clean ;;
(build) build ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

140
rocm-build/build_devicelibs.sh Executable file
View File

@@ -0,0 +1,140 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -r, --release Build a release version of the package"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -s, --static Supports static CI by accepting this param & not bailing out. No effect of the param though"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo
echo
return 0
}
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_BIN="$(getBinPath)"
PACKAGE_LIB="$(getLibPath)"
BUILD_PATH="$(getBuildPath devicelibs)"
INSTALL_PATH="$(getPackageRoot)"
LIGHTNING_BUILD_PATH="$(getBuildPath lightning)"
DEB_PATH="$(getDebPath devicelibs)"
RPM_PATH="$(getRpmPath devicelibs)"
AMDGCN_LIB_PATH="$PACKAGE_ROOT/amdgcn/bitcode/"
TARGET="build"
MAKEOPTS="$DASH_JAY"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
PKGTYPE="deb"
MAKETARGET="deb"
VALID_STR=`getopt -o hcraso: --long help,clean,release,static,address_sanitizer,outdir: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="Release" ; shift ;;
(-a | --address_sanitizer)
ASAN_CMAKE_PARAMS="true"
ack_and_ignore_asan ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
--) shift; break;; # end delimiter
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_devicelibs() {
rm -rf "$BUILD_PATH"
rm -f $PACKAGE_LIB/hc*.bc
rm -f $PACKAGE_LIB/irif*.bc
rm -f $PACKAGE_LIB/ockl*.bc
rm -f $PACKAGE_LIB/oclc*.bc
rm -f $PACKAGE_LIB/ocml*.bc
rm -f $PACKAGE_LIB/opencl*.bc
rm -f $PACKAGE_LIB/openmp*.bc
rm -rf $PACKAGE_ROOT/amdgcn
rm -rf "$DEB_PATH"
rm -rf "$RPM_PATH"
}
build_devicelibs() {
mkdir -p "$BUILD_PATH"
pushd "$BUILD_PATH"
local clangResourceDir="$($LIGHTNING_BUILD_PATH/bin/clang -print-resource-dir)"
local clangResourceVer=${clangResourceDir#*lib/clang/}
local bitcodeInstallLoc="lib/llvm/lib/clang/${clangResourceVer}/lib"
export LLVM_BUILD="$LIGHTNING_BUILD_PATH"
if [ ! -e Makefile ]; then
cmake $(rocm_cmake_params) \
$(rocm_common_cmake_params) \
-DROCM_DEVICE_LIBS_BITCODE_INSTALL_LOC_NEW="$bitcodeInstallLoc/amdgcn" \
-DROCM_DEVICE_LIBS_BITCODE_INSTALL_LOC_OLD="amdgcn" \
"$DEVICELIBS_ROOT"
echo "CMake complete"
fi
echo "Building device-libs"
cmake --build . -- $MAKEOPTS
cmake --build . -- $MAKEOPTS install
popd
}
package_devicelibs() {
mkdir -p "$DEB_PATH"
mkdir -p "$RPM_PATH"
pushd "$BUILD_PATH"
cpack
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$DEB_PATH" *.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$RPM_PATH" *.rpm
popd
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${DEB_PATH};;
("rpm")
echo ${RPM_PATH};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
case $TARGET in
(clean) clean_devicelibs ;;
(build) build_devicelibs; package_devicelibs ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

46
rocm-build/build_half.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src half
build_half() {
echo "Start build"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
ASAN_CMAKE_PARAMS="false"
fi
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
cmake \
-DCMAKE_INSTALL_PREFIX="$ROCM_PATH" \
-DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=OFF \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- package
cmake --build "$BUILD_DIR" -- install
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_half() {
echo "Cleaning half build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_half ;;
outdir) print_output_directory ;;
clean) clean_half ;;
*) die "Invalid target $TARGET" ;;
esac

295
rocm-build/build_hip_on_rocclr.sh Executable file
View File

@@ -0,0 +1,295 @@
#!/bin/bash
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -h, --help Prints this help"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -s, --static Build static lib (.a). build instead of dynamic/shared(.so) "
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of type referred to by pkg_type"
echo " -t, --offload-arch=<arch> Specify arch for catch tests ex: --offload-arch=gfx1030 --offload-arch=gfx1100"
echo " -p, --package <type> Specify packaging format"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
MAKEOPTS="$DASH_JAY"
BUILD_PATH="$(getBuildPath hip-on-rocclr)"
TARGET="build"
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_SRC="$(getSrcPath)"
PACKAGE_DEB="$PACKAGE_ROOT/deb/hip-on-rocclr"
PACKAGE_RPM="$PACKAGE_ROOT/rpm/hip-on-rocclr"
PREFIX_PATH="$PACKAGE_ROOT"
CORE_BUILD_DIR="$(getBuildPath hsa-core)"
ROCclr_BUILD_DIR="$(getBuildPath rocclr)"
HIPCC_BUILD_DIR="$(getBuildPath hipcc)"
CATCH_BUILD_DIR="$(getBuildPath catch)"
CATCH_SRC="$HIP_CATCH_TESTS_ROOT/catch"
SAMPLES_SRC="$HIP_CATCH_TESTS_ROOT/samples"
SAMPLES_BUILD_DIR="$(getBuildPath samples)"
if [ ! -e "$CATCH_SRC/CMakeLists.txt" ]; then
echo "Using catch source from hip project" >&2
CATCH_SRC="$HIP_ON_ROCclr_ROOT/tests/catch"
fi
BUILD_TYPE="Debug"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
OFFLOAD_ARCH=()
DEFAULT_OFFLOAD_ARCH=(gfx900 gfx906 gfx908 gfx90a gfx940 gfx941 gfx942 gfx1030 gfx1031 gfx1033 gfx1034 gfx1035 gfx1100 gfx1101 gfx1102 gfx1103)
VALID_STR=`getopt -o hcrast:o: --long help,clean,release,address_sanitizer,static,offload-arch=:,outdir: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="RelWithDebInfo" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-t | --offload-arch=)
OFFLOAD_ARCH+=( "$2" ); ((CLEAN_OR_OUT|=2)); shift 2 ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
if [ ${#OFFLOAD_ARCH[@]} = 0 ] ; then
OFFLOAD_ARCH=( "${DEFAULT_OFFLOAD_ARCH[@]}" )
else
echo "Using user defined offload archs ${OFFLOAD_ARCH[@]} for catch tests";
fi
printf -v OFFLOAD_ARCH_STR -- '--offload-arch=%q ' "${OFFLOAD_ARCH[@]}"
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_hip_on_rocclr() {
rm -rf "$BUILD_PATH"
rm -rf "$PACKAGE_DEB"
rm -rf "$PACKAGE_RPM"
rm -rf "$OUT_DIR/hip"
}
build_hip_on_rocclr() {
if [ -e "$CLR_ROOT/CMakeLists.txt" ]; then
_HIP_CMAKELIST_DIR="$CLR_ROOT"
_HIP_CMAKELIST_OPT="-DCLR_BUILD_HIP=ON -DCLR_BUILD_OCL=OFF"
if [ -e "$HIPOTHER_ROOT/hipnv" ]; then
_HIP_CMAKELIST_OPT="$_HIP_CMAKELIST_OPT -DHIPNV_DIR=$HIPOTHER_ROOT/hipnv"
fi
elif [ ! -e "$HIPAMD_ROOT/CMakeLists.txt" ]; then
echo "No $HIPAMD_ROOT/CMakeLists.txt file, skipping hip on rocclr" >&2
echo "No $HIPAMD_ROOT/CMakeLists.txt file, skipping hip on rocclr"
exit 0
else
_HIP_CMAKELIST_DIR="$HIPAMD_ROOT"
_HIP_CMAKELIST_OPT=""
fi
echo "$_HIP_CMAKELIST_DIR"
mkdir -p "$BUILD_PATH"
pushd "$BUILD_PATH"
if [ ! -e Makefile ]; then
echo "Building HIP-On-ROCclr CMake environment"
print_lib_type $SHARED_LIBS
cmake $(rocm_cmake_params) \
-DBUILD_SHARED_LIBS=$SHARED_LIBS \
-DHIP_COMPILER=clang \
-DHIP_PLATFORM=amd \
-DHIP_COMMON_DIR="$HIP_ON_ROCclr_ROOT" \
$(rocm_common_cmake_params) \
-DCMAKE_HIP_ARCHITECTURES=OFF \
-DHSA_PATH="$ROCM_INSTALL_PATH" \
-DCMAKE_SKIP_BUILD_RPATH=TRUE \
-DCPACK_INSTALL_PREFIX="$ROCM_INSTALL_PATH" \
-DROCM_PATH="$ROCM_INSTALL_PATH" \
-DHIPCC_BIN_DIR="$HIPCC_BUILD_DIR" \
-DHIP_CATCH_TEST=1 \
$_HIP_CMAKELIST_OPT \
"$_HIP_CMAKELIST_DIR"
echo "CMake complete"
fi
echo "Build and Install HIP"
cmake --build . -- $MAKEOPTS install "VERBOSE=1"
popd
}
build_catch_tests() {
WORKSPACE=`pwd`
echo "Build catch2 tests independently"
if [ ! -e "$CATCH_SRC/CMakeLists.txt" ]; then
echo "catch source not found: $CATCH_SRC" >&2
exit
fi
# build catch
rm -rf "$CATCH_BUILD_DIR"
mkdir -p "$CATCH_BUILD_DIR"
pushd "$CATCH_BUILD_DIR"
export HIP_PATH="$ROCM_INSTALL_PATH"
export ROCM_PATH="$ROCM_INSTALL_PATH"
cmake \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DHIP_PLATFORM=amd \
-DROCM_PATH="$ROCM_INSTALL_PATH" \
-DOFFLOAD_ARCH_STR="$OFFLOAD_ARCH_STR" \
$(rocm_common_cmake_params) \
-DCPACK_RPM_DEBUGINFO_PACKAGE=FALSE \
-DCPACK_DEBIAN_DEBUGINFO_PACKAGE=FALSE \
-DCPACK_INSTALL_PREFIX="$ROCM_INSTALL_PATH" \
"$CATCH_SRC"
make $MAKEOPTS build_tests
echo "Packaging catch tests"
make $MAKEOPTS package_test
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_DEB" *.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_RPM" *.rpm
popd
}
package_samples() {
if [ "$ASAN_CMAKE_PARAMS" == "true" ] ; then
echo "Disable the packaging of HIP samples" >&2
return
fi
WORKSPACE=`pwd`
if [ ! -e "$SAMPLES_SRC/CMakeLists.txt" ]; then
echo "HIP samples source not found at: $SAMPLES_SRC" >&2
echo "Using samples package from hip project: $BUILD_PATH" >&2
return
fi
rm -rf "$SAMPLES_BUILD_DIR"
mkdir -p "$SAMPLES_BUILD_DIR"
pushd "$SAMPLES_BUILD_DIR"
local CMAKE_PATH="$(getCmakePath)"
export HIP_PATH="$ROCM_INSTALL_PATH"
export ROCM_PATH="$ROCM_INSTALL_PATH"
cmake \
-DROCM_PATH="$ROCM_INSTALL_PATH" \
$(rocm_common_cmake_params) \
-DCMAKE_MODULE_PATH="$CMAKE_PATH/hip" \
-DCPACK_INSTALL_PREFIX="$ROCM_INSTALL_PATH" \
"$SAMPLES_SRC"
echo "Packaging hip samples from hip-tests project"
make $MAKEOPTS package_samples
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_DEB" *.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_RPM" *.rpm
popd
}
clean_hip_tests(){
rm -rf "$CATCH_BUILD_DIR"
rm -rf "$PACKAGE_SRC/hip-on-rocclr"
rm -rf "$PACKAGE_SRC/hipamd"
rm -rf "$PACKAGE_SRC/rocclr"
rm -rf "$PACKAGE_SRC/opencl-on-rocclr"
rm -rf "$PACKAGE_SRC/clr"
rm -rf "$PACKAGE_SRC/hip-tests"
rm -rf "$PACKAGE_SRC/hipother"
}
copy_hip_tests() {
clean_hip_tests
echo "Copy HIP & ROCclr Source and tests"
mkdir -p "$PACKAGE_SRC/hip-on-rocclr"
echo "Copying hip-on-rocclr"
progressCopy "$HIP_ON_ROCclr_ROOT" "$PACKAGE_SRC/hip-on-rocclr"
if [ -e "$CLR_ROOT/CMakeLists.txt" ]; then
mkdir -p "$PACKAGE_SRC/clr"
echo "Copying clr"
progressCopy "$CLR_ROOT" "$PACKAGE_SRC/clr"
else
mkdir -p "$PACKAGE_SRC/hipamd"
mkdir -p "$PACKAGE_SRC/rocclr"
mkdir -p "$PACKAGE_SRC/opencl-on-rocclr"
echo "Copying hipamd"
progressCopy "$HIPAMD_ROOT" "$PACKAGE_SRC/hipamd"
echo "Copying rocclr"
progressCopy "$ROCclr_ROOT" "$PACKAGE_SRC/rocclr"
echo "Copying opencl-on-rocclr"
progressCopy "$OPENCL_ON_ROCclr_ROOT" "$PACKAGE_SRC/opencl-on-rocclr"
fi
if [ -e "$HIPOTHER_ROOT/hipnv" ]; then
mkdir -p "$PACKAGE_SRC/hipother"
echo "Copying hipother"
progressCopy "$HIPOTHER_ROOT" "$PACKAGE_SRC/hipother"
fi
mkdir -p "$PACKAGE_SRC/hip-tests"
echo "Copying hip-tests"
progressCopy "$HIP_CATCH_TESTS_ROOT" "$PACKAGE_SRC/hip-tests"
}
package_hip_on_rocclr()
{
echo "Packagin HIP-on-ROCclr"
pushd "$BUILD_PATH"
cmake --build . -- $MAKEOPTS package
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_DEB" *.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_RPM" *.rpm
popd
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${PACKAGE_DEB};;
("rpm")
echo ${PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
case $TARGET in
(clean) clean_hip_on_rocclr; clean_hip_tests ;;
(build) build_hip_on_rocclr; build_catch_tests; package_hip_on_rocclr; package_samples; copy_hip_tests;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

65
rocm-build/build_hipblas.sh Executable file
View File

@@ -0,0 +1,65 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src hipBLAS
build_hipblas() {
echo "Start build"
CXX="g++"
CLIENTS_SAMPLES="ON"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
CLIENTS_SAMPLES="OFF"
fi
echo "C compiler: $CC"
echo "CXX compiler: $CXX"
echo "FC compiler: $FC"
cd $COMPONENT_SRC
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
rebuild_lapack
fi
cmake \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DUSE_CUDA=OFF \
-DBUILD_CLIENTS_TESTS=ON \
-DBUILD_CLIENTS_BENCHMARKS=ON \
-DBUILD_CLIENTS_SAMPLES="${CLIENTS_SAMPLES}" \
-DCPACK_SET_DESTDIR=OFF \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_hipblas() {
echo "Cleaning hipBLAS build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_hipblas ;;
outdir) print_output_directory ;;
clean) clean_hipblas ;;
*) die "Invalid target $TARGET" ;;
esac

69
rocm-build/build_hipblaslt.sh Executable file
View File

@@ -0,0 +1,69 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src hipBLASLt
build_hipblaslt() {
echo "Start build"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
cd $COMPONENT_SRC
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
rebuild_lapack
fi
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
# gfx90a:xnack+;gfx90a:xnack-;gfx940;gfx941;gfx942
GPU_TARGETS=all
fi
CXX=$(set_build_variables CXX)\
cmake \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DTensile_LOGIC= \
-DTensile_CODE_OBJECT_VERSION=default \
-DTensile_CPU_THREADS= \
-DTensile_LIBRARY_FORMAT=msgpack \
-DBUILD_CLIENTS_SAMPLES=ON \
-DBUILD_CLIENTS_TESTS=ON \
-DBUILD_CLIENTS_BENCHMARKS=ON \
-DCPACK_SET_DESTDIR=OFF \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_hipblaslt() {
echo "Cleaning hipBLASLt build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_hipblaslt ;;
outdir) print_output_directory ;;
clean) clean_hipblaslt ;;
*) die "Invalid target $TARGET" ;;
esac

118
rocm-build/build_hipcc.sh Executable file
View File

@@ -0,0 +1,118 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -h, --help Prints this help"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -r, --release Makes a release build"
echo
return 0
}
API_NAME=hipcc
PROJ_NAME=$API_NAME
TARGET="build"
MAKEOPTS="$DASH_JAY"
BUILD_TYPE="Debug"
BUILD_DIR=$(getBuildPath $API_NAME)
PACKAGE_DEB=$(getPackageRoot)/deb/$API_NAME
PACKAGE_RPM=$(getPackageRoot)/rpm/$API_NAME
PACKAGE_SRC="$(getSrcPath)"
while [ "$1" != "" ];
do
case $1 in
(-a | --address_sanitizer)
ack_and_ignore_asan ;;
(-c | --clean)
TARGET="clean" ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 1 ;;
(-r | --release)
BUILD_TYPE="RelWithDebInfo" ;;
(-h | --help)
printUsage ; exit 0 ;;
(*)
echo "Invalid option [$1]" >&2; printUsage; exit 1 ;;
esac
shift 1
done
clean() {
echo "Cleaning hipcc"
rm -rf $BUILD_DIR
echo "Cleaning up hipcc DEB and RPM packages"
rm -rf $PACKAGE_DEB
rm -rf $PACKAGE_RPM
}
copy_hipcc_sources() {
echo "Clean up hipcc build folder"
rm -rf "$PACKAGE_SRC/hipcc"
echo "Copy hipcc sources"
mkdir -p "$PACKAGE_SRC/hipcc"
progressCopy "$HIPCC_ROOT" "$PACKAGE_SRC/hipcc"
}
build() {
echo "Build hipcc binary"
mkdir -p "$BUILD_DIR"
pushd "$BUILD_DIR"
if ! [ -e "$HIPCC_ROOT/CMakeLists.txt" ] ; then
echo "No source for hipcc, exiting. this is not an error" >&2
exit 0
fi
cmake \
$(rocm_cmake_params) \
$(rocm_common_cmake_params) \
-DHIPCC_BACKWARD_COMPATIBILITY=OFF \
-DCMAKE_INSTALL_PREFIX="$OUT_DIR" \
$HIPCC_ROOT
popd
cmake --build "$BUILD_DIR" -- $MAKEOPTS
echo "Installing and Packaging hipcc"
cmake --build "$BUILD_DIR" -- $MAKEOPTS install
cmake --build "$BUILD_DIR" -- $MAKEOPTS package
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_DEB" $BUILD_DIR/hipcc*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_RPM" $BUILD_DIR/hipcc*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${PACKAGE_DEB};;
("rpm")
echo ${PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1 ;;
esac
exit
}
case $TARGET in
(clean) clean ;;
(build) build ; copy_hipcc_sources ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

60
rocm-build/build_hipcub.sh Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src hipCUB
build_hipcub() {
echo "Start build"
cd $COMPONENT_SRC
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
ASAN_CMAKE_PARAMS="false"
fi
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
CXX=$(set_build_variables CXX)\
cmake \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DCMAKE_MODULE_PATH="${ROCM_PATH}/lib/cmake/hip;${ROCM_PATH}/hip/cmake" \
-Drocprim_DIR="${ROCM_PATH}/rocprim" \
-DBUILD_TEST=ON \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_hipcub() {
echo "Cleaning hipCUB build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_hipcub ;;
outdir) print_output_directory ;;
clean) clean_hipcub ;;
*) die "Invalid target $TARGET" ;;
esac

61
rocm-build/build_hipfft.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src hipFFT
build_hipfft() {
echo "Start build"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
cd $COMPONENT_SRC
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908;gfx90a;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
cmake \
-DCMAKE_CXX_COMPILER=$(set_build_variables CXX) \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DCMAKE_MODULE_PATH="${ROCM_PATH}/lib/cmake/hip" \
-DCMAKE_SKIP_BUILD_RPATH=TRUE \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
-DBUILD_CLIENTS_TESTS=ON \
-DBUILD_CLIENTS_SAMPLES=ON \
-L \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_hipfft() {
echo "Cleaning hipFFT build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_hipfft ;;
outdir) print_output_directory ;;
clean) clean_hipfft ;;
*) die "Invalid target $TARGET" ;;
esac

50
rocm-build/build_hipfort.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src hipfort
build_hipfort() {
echo "Start build"
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
cmake --trace \
-DHIPFORT_INSTALL_DIR="${ROCM_PATH}" \
-DCMAKE_PREFIX_PATH="${ROCM_PATH}/llvm;${ROCM_PATH}" \
-DCMAKE_BUILD_TYPE=Release \
-DHIPFORT_COMPILER="${ROCM_PATH}/${ROCM_LLVMDIR}/bin/flang" \
-DCMAKE_Fortran_FLAGS="-Mfree" \
-DHIPFORT_COMPILER_FLAGS="-cpp" \
-DCMAKE_Fortran_FLAGS_DEBUG="" \
${LAUNCHER_FLAGS} \
-DROCM_SYMLINK_LIBS=OFF \
-DCMAKE_INSTALL_PREFIX=${ROCM_PATH} \
-DHIPFORT_AR="${ROCM_PATH}/${ROCM_LLVMDIR}/bin/llvm-ar" \
-DHIPFORT_RANLIB="${ROCM_PATH}/${ROCM_LLVMDIR}/bin/llvm-ranlib" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_hipfort() {
echo "Cleaning hipFORT build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_hipfort ;;
outdir) print_output_directory ;;
clean) clean_hipfort ;;
*) die "Invalid target $TARGET" ;;
esac

142
rocm-build/build_hipify_clang.sh Executable file
View File

@@ -0,0 +1,142 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo " -r, --release Make a release build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -s, --static Supports static CI by accepting this param & not bailing out. No effect of the param though"
echo
return 0
}
TARGET="build"
MAKEOPTS="$DASH_JAY"
HIPIFY_CLANG_BUILD_DIR="$(getBuildPath $HIPIFY_ROOT)"
HIPIFY_CLANG_DIST_DIR="$HIPIFY_CLANG_BUILD_DIR/dist"
BUILD_TYPE="Debug"
PACKAGE_ROOT="$(getPackageRoot)"
HIPIFY_CLANG_HASH=""
LIGHTNING_PATH="$ROCM_INSTALL_PATH/llvm"
ADDRESS_SANITIZER=false
DEB_PATH="$(getDebPath hipify)"
RPM_PATH="$(getRpmPath hipify)"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
VALID_STR=`getopt -o hcraso: --long help,clean,release,static,address_sanitizer,outdir: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="RelWithDebInfo" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on
ADDRESS_SANITIZER=true ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_hipify() {
echo "Cleaning hipify-clang"
rm -rf "$HIPIFY_CLANG_BUILD_DIR"
rm -rf "$HIPIFY_CLANG_DIST_DIR"
rm -rf "$DEB_PATH"
rm -rf "$RPM_PATH"
}
package_hipify() {
if [ "$PACKAGEEXT" = "deb" ]; then
rm -rf "$DEB_PATH"
mkdir -p "$DEB_PATH"
fi
if [ "$PACKAGEEXT" = "rpm" ]; then
rm -rf "$RPM_PATH"
mkdir -p "$RPM_PATH"
fi
pushd "$HIPIFY_CLANG_BUILD_DIR"
make $MAKEOPTS package_hipify-clang
popd
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$DEB_PATH" $HIPIFY_CLANG_BUILD_DIR/hipify*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$RPM_PATH" $HIPIFY_CLANG_BUILD_DIR/hipify*.rpm
}
build_hipify() {
echo "Building hipify-clang binaries"
mkdir -p "$HIPIFY_CLANG_BUILD_DIR"
mkdir -p "$HIPIFY_CLANG_DIST_DIR"
pushd "$HIPIFY_CLANG_BUILD_DIR"
cmake \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
$(rocm_common_cmake_params) \
-DCMAKE_INSTALL_PREFIX="$HIPIFY_CLANG_DIST_DIR" \
-DCPACK_PACKAGING_INSTALL_PREFIX=$ROCM_INSTALL_PATH \
-DCMAKE_PREFIX_PATH="$LIGHTNING_PATH" \
-DADDRESS_SANITIZER="$ADDRESS_SANITIZER" \
$HIPIFY_ROOT
cmake --build . -- $MAKEOPTS install
popd
pushd "$HIPIFY_ROOT"
HIPIFY_CLANG_HASH=`git describe --dirty --long --match [0-9]* --always`
popd
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${DEB_PATH};;
("rpm")
echo ${RPM_PATH};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
case $TARGET in
(clean) clean_hipify ;;
(build) build_hipify; package_hipify ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

90
rocm-build/build_hiprand.sh Executable file
View File

@@ -0,0 +1,90 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src hipRAND
while [ "$1" != "" ];
do
case $1 in
-o | --outdir )
shift 1; PKGTYPE=$1 ; TARGET="outdir" ;;
-c | --clean )
TARGET="clean" ;;
*)
break ;;
esac
shift 1
done
build_hiprand() {
echo "Start build"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
cd $COMPONENT_SRC
remote_name=$(git remote show | head -n 1)
[ "$remote_name" == "origin" ] || git remote rename "$remote_name" origin
git submodule update --init --force
mkdir "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
CXX=$(set_build_variables CXX)\
cmake \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DBUILD_TEST=ON \
-DBUILD_BENCHMARK=ON \
-DBUILD_CRUSH_TEST=ON \
-DDEPENDENCIES_FORCE_DOWNLOAD=ON \
-DHIP_COMPILER=clang \
-DCMAKE_MODULE_PATH="${ROCM_PATH}/lib/cmake/hip" \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
$SCCACHE_BIN -s || echo "Unable to display sccache stats"
}
clean_hiprand() {
echo "Cleaning hipRAND build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${DEB_PATH};;
("rpm")
echo ${RPM_PATH};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
case $TARGET in
build) build_hiprand ;;
outdir) print_output_directory ;;
clean) clean_hiprand ;;
*) die "Invalid target $TARGET" ;;
esac

64
rocm-build/build_hipsolver.sh Executable file
View File

@@ -0,0 +1,64 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src hipSOLVER
build_hipsolver() {
echo "Start build"
cd $COMPONENT_SRC
CXX="g++"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
echo "C compiler: $CC"
echo "CXX compiler: $CXX"
echo "FC compiler: $FC"
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
rebuild_lapack
fi
cmake \
-DUSE_CUDA=OFF \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DBUILD_CLIENTS_TESTS=ON \
-DBUILD_CLIENTS_BENCHMARKS=ON \
-DBUILD_CLIENTS_SAMPLES=ON \
-DCPACK_SET_DESTDIR=OFF \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_hipsolver() {
echo "Cleaning hipSOLVER build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_hipsolver ;;
outdir) print_output_directory ;;
clean) clean_hipsolver ;;
*) die "Invalid target $TARGET" ;;
esac

61
rocm-build/build_hipsparse.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
PATH=${ROCM_PATH}/bin:$PATH
set_component_src hipSPARSE
build_hipsparse() {
echo "Start build"
cd $COMPONENT_SRC
CXX="g++"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
echo "C compiler: $CC"
echo "CXX compiler: $CXX"
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
cmake \
-DCPACK_SET_DESTDIR=OFF \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DUSE_CUDA=OFF \
-DBUILD_CLIENTS_SAMPLES=ON \
-DBUILD_CLIENTS_TESTS=ON \
-DCMAKE_INSTALL_PREFIX=${ROCM_PATH} \
-DCMAKE_MODULE_PATH="${ROCM_PATH}/lib/cmake/hip;${ROCM_PATH}/hip/cmake" \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_hipsparse() {
echo "Cleaning hipSPARSE build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_hipsparse ;;
outdir) print_output_directory ;;
clean) clean_hipsparse ;;
*) die "Invalid target $TARGET" ;;
esac

89
rocm-build/build_hipsparselt.sh Executable file
View File

@@ -0,0 +1,89 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src hipSPARSELt
while [ "$1" != "" ];
do
case $1 in
-o | --outdir )
shift 1; PKGTYPE=$1 ; TARGET="outdir" ;;
-c | --clean )
TARGET="clean" ;;
*)
break ;;
esac
shift 1
done
build_hipsparselt() {
echo "Start build"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
cd $COMPONENT_SRC
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
# gfx940;gfx941;gfx942
GPU_TARGETS=all
fi
FC=gfortran \
CXX="${ROCM_PATH}/bin/hipcc" \
cmake \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DTensile_LOGIC= \
-DTensile_CODE_OBJECT_VERSION=default \
-DTensile_CPU_THREADS= \
-DTensile_LIBRARY_FORMAT=msgpack \
-DBUILD_CLIENTS_SAMPLES=ON \
-DBUILD_CLIENTS_TESTS=ON \
-DBUILD_CLIENTS_BENCHMARKS=ON \
-DCPACK_SET_DESTDIR=OFF \
-DCMAKE_INSTALL_PREFIX=${ROCM_PATH} \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
$SCCACHE_BIN -s || echo "Unable to display sccache stats"
}
clean_hipsparselt() {
echo "Cleaning hipSPARSELt build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${DEB_PATH};;
("rpm")
echo ${RPM_PATH};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
case $TARGET in
build) build_hipsparselt ;;
outdir) print_output_directory ;;
clean) clean_hipsparselt ;;
*) die "Invalid target $TARGET" ;;
esac

57
rocm-build/build_hiptensor.sh Executable file
View File

@@ -0,0 +1,57 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src hipTensor
build_hiptensor() {
echo "Start build hipTensor"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
cd "$COMPONENT_SRC"
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942"
fi
cmake \
-B "${BUILD_DIR}" \
$(rocm_common_cmake_params) \
$(set_build_variables CMAKE_C_CXX) \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
${LAUNCHER_FLAGS} \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p "$PACKAGE_DIR" && cp ${BUILD_DIR}/*.${PKGTYPE} "$PACKAGE_DIR"
show_build_cache_stats
}
clean_hiptensor() {
echo "Cleaning hipTensor build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_hiptensor ;;
outdir) print_output_directory ;;
clean) clean_hiptensor ;;
*) die "Invalid target $TARGET" ;;
esac

135
rocm-build/build_hsa.sh Executable file
View File

@@ -0,0 +1,135 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...] [make options]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of type referred to by pkg_type"
echo " -h, --help Prints this help"
echo " -s, --static Build static lib (.a). build instead of dynamic/shared(.so) "
echo
echo
return 0
}
TARGET="build"
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_SRC="$(getSrcPath)"
PACKAGE_LIB="$(getLibPath)"
PACKAGE_BIN="$(getBinPath)"
PACKAGE_DEB="$(getPackageRoot)/deb/rocr"
PACKAGE_RPM="$(getPackageRoot)/rpm/rocr"
MAKEARG=""
CORE_BUILD_DIR="$(getBuildPath hsa-core)"
ROCR_DEV_BUILD_DIR="$(getBuildPath hsa-rocr-dev)"
PREFIX_PATH="$PACKAGE_ROOT"
BUILD_TYPE="Debug"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
unset HIP_DEVICE_LIB_PATH
unset ROCM_PATH
VALID_STR=`getopt -o hcraso: --long help,clean,release,static,address_sanitizer,outdir: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="RelWithDebInfo" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_hsa() {
echo "Cleaning HSA"
rm -rf "$CORE_BUILD_DIR"
rm -rf "$PACKAGE_RPM"
rm -rf "$PACKAGE_DEB"
rm -f "$PACKAGE_ROOT"/lib/libhsa-runtime*
rm -rf "$PACKAGE_ROOT/lib/cmake/hsa-runtime64"
rm -rf "$PACKAGE_ROOT/include/hsa"
rm -rf "$PACKAGE_ROOT/share/doc/hsa-runtime64"
rm -rf "$PACKAGE_ROOT/hsa"
}
build_hsa_core() {
echo "Build HSA"
local coreMakeOpts="$DASH_JAY -C $CORE_BUILD_DIR"
echo "$HSA_CORE_ROOT"
if [ ! -d "$CORE_BUILD_DIR" ]; then
mkdir -p "$CORE_BUILD_DIR"
pushd "$CORE_BUILD_DIR"
print_lib_type $SHARED_LIBS
cmake $(rocm_cmake_params) \
-DBUILD_SHARED_LIBS=$SHARED_LIBS \
-DENABLE_LDCONFIG=OFF \
$(rocm_common_cmake_params) \
-DADDRESS_SANITIZER="$ADDRESS_SANITIZER" \
"$HSA_CORE_ROOT"
popd
fi
time cmake --build "$CORE_BUILD_DIR" -- $coreMakeOpts
time cmake --build "$CORE_BUILD_DIR" -- $coreMakeOpts install
time cmake --build "$CORE_BUILD_DIR" -- $coreMakeOpts package
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_DEB" $CORE_BUILD_DIR/hsa-rocr*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_RPM" $CORE_BUILD_DIR/hsa-rocr*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${PACKAGE_DEB};;
("rpm")
echo ${PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
case $TARGET in
(clean) clean_hsa ;;
(build) build_hsa_core;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

1253
rocm-build/build_lightning.sh Executable file

File diff suppressed because it is too large Load Diff

73
rocm-build/build_miopen-deps.sh Executable file
View File

@@ -0,0 +1,73 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src MIOpen
build_miopen_mlir() {
echo "Building rocMLIR"
mlir_commit="$1"
if [ -z "$mlir_commit" ]; then
echo "rocMLIR entry was not found in requirements.txt"
return
fi
mkdir -p /var/tmp/rocMLIR && cd /var/tmp/rocMLIR
wget -nv "https://www.github.com/ROCmSoftwarePlatform/rocMLIR/archive/${mlir_commit}.tar.gz"
tar -xzf "${mlir_commit}.tar.gz"
cd "rocMLIR-${mlir_commit}"
mkdir build && cd build
cmake \
-G Ninja \
-DCMAKE_C_COMPILER="${ROCM_PATH}/llvm/bin/clang" \
-DCMAKE_CXX_COMPILER="${ROCM_PATH}/llvm/bin/clang++" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="${ROCM_PATH};${HOME}/miopen-deps" \
-DCMAKE_INSTALL_PREFIX="$ROCM_PATH" \
-DBUILD_FAT_LIBROCKCOMPILER=1 \
..
cmake --build . -- librockCompiler -j${PROC}
cmake --build . -- install
rm -rf _CPack_Packages/ && find -name '*.o' -delete
echo "Finished building rocMLIR"
}
clean_miopen_mlir() {
echo "Cleaning rocMLIR"
rm -rf /var/tmp/rocMLIR
}
build_miopen_deps() {
echo "Start build"
cd "$COMPONENT_SRC"
# Commenting the rocMLIR & composable_kernel from requirements.txt
sed -i '/ROCmSoftwarePlatform\/rocMLIR@\|ROCmSoftwarePlatform\/composable_kernel@/s/^/#/' requirements.txt
# Extract MLIR commit from requirements.txt
MLIR_COMMIT="$(awk '/rocMLIR/ {split($1, s, "@"); print s[2]}' requirements.txt)"
pip3 install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz
PATH="${PATH}:${ROCM_PATH}:${HOME}/.local/bin" rbuild prepare -d "$HOME/miopen-deps" --cxx=${ROCM_PATH}/llvm/bin/clang++ --cc ${ROCM_PATH}/llvm/bin/clang
build_miopen_mlir "$MLIR_COMMIT"
show_build_cache_stats
}
clean_miopen_deps() {
echo "Cleaning MIOpen-Deps build directory: ${BUILD_DIR}"
rm -rf "$BUILD_DIR"
clean_miopen_mlir
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_miopen_deps ;;
outdir) ;;
clean) clean_miopen_deps ;;
*) die "Invalid target $TARGET" ;;
esac

62
rocm-build/build_miopen-hip.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src MIOpen
PACKAGE_DIR=${PACKAGE_DIR%\/*}/miopen-hip
DEB_PATH=$PACKAGE_DIR
RPM_PATH=$PACKAGE_DIR
build_miopen_hip() {
echo "Start build"
cd $COMPONENT_SRC
checkout_lfs
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
mkdir "$BUILD_DIR" && cd "$BUILD_DIR"
cmake \
$(rocm_common_cmake_params) \
-DMIOPEN_BACKEND=HIP \
-DCMAKE_CXX_COMPILER="${ROCM_PATH}/llvm/bin/clang++" \
-DCMAKE_C_COMPILER="${ROCM_PATH}/llvm/bin/clang" \
-DCMAKE_PREFIX_PATH="${ROCM_PATH};${ROCM_PATH}/hip;${HOME}/miopen-deps" \
-DHIP_OC_COMPILER="${ROCM_PATH}/bin/clang-ocl" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf $BUILD_DIR/_CPack_Packages/ && find $BUILD_DIR -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_miopen_hip() {
echo "Cleaning MIOpen-HIP build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
checkout_lfs() {
git lfs install --local --force
git lfs pull --exclude=
}
stage2_command_args "$@"
case $TARGET in
build) build_miopen_hip ;;
outdir) print_output_directory ;;
clean) clean_miopen_hip ;;
*) die "Invalid target $TARGET" ;;
esac

59
rocm-build/build_mivisionx.sh Executable file
View File

@@ -0,0 +1,59 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src MIVisionX
BUILD_DEV=ON
build_mivisionx() {
echo "Start build"
mkdir -p $BUILD_DIR && cd $BUILD_DIR
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
BUILD_DEV=OFF
fi
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908;gfx90a;gfx940;gfx941;gfx942;gfx1030;gfx1100"
fi
cmake \
$(rocm_common_cmake_params) \
-DROCM_PATH="$ROCM_PATH" \
-DBUILD_DEV=$BUILD_DEV \
-DCMAKE_INSTALL_LIBDIR=$(getInstallLibDir) \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DROCM_DEP_ROCMCORE=ON \
-DROCAL_PYTHON=OFF \
${LAUNCHER_FLAGS} \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cpack -G ${PKGTYPE^^}
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR
cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_mivisionx() {
echo "Cleaning MIVisionX build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_mivisionx ;;
outdir) print_output_directory ;;
clean) clean_mivisionx ;;
*) die "Invalid target $TARGET" ;;
esac

View File

@@ -0,0 +1,155 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...] [make options]"
echo
echo "Options:"
echo " -h, --help Prints this help"
echo " -s, --static Supports static CI by accepting this param & not bailing out. No effect of the param though"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of type referred to by pkg_type"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
MAKEOPTS="$DASH_JAY"
BUILD_PATH="$(getBuildPath opencl-on-rocclr)"
TARGET="build"
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_DEB="$PACKAGE_ROOT/deb/opencl-on-rocclr"
PACKAGE_RPM="$PACKAGE_ROOT/rpm/opencl-on-rocclr"
CORE_BUILD_DIR="$(getBuildPath hsa-core)"
ROCclr_BUILD_DIR="$(getBuildPath rocclr)"
BUILD_TYPE="Debug"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
VALID_STR=`getopt -o hcraso: --long help,clean,release,static,address_sanitizer,outdir: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="RelWithDebInfo" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_opencl_on_rocclr() {
rm -rf "$BUILD_PATH"
rm -rf "$PACKAGE_DEB"
rm -rf "$PACKAGE_RPM"
rm -rf "$PACKAGE_ROOT/bin/clinfo"
rm -rf "$PACKAGE_ROOT/lib/libOpenCL.so*"
rm -rf "$PACKAGE_ROOT/lib/libamdocl64.so"
rm -rf "$PACKAGE_ROOT/lib/libcltrace.so"
}
build_opencl_on_rocclr() {
if [ -e "$CLR_ROOT/CMakeLists.txt" ]; then
_OCL_CMAKELIST_DIR="$CLR_ROOT"
_OCL_CMAKELIST_OPT="-DCLR_BUILD_HIP=OFF -DCLR_BUILD_OCL=ON"
elif [ ! -e "$OPENCL_ON_ROCclr_ROOT/CMakeLists.txt" ]; then
echo "No $OPENCL_ON_ROCclr_ROOT/CMakeLists.txt file, skipping opencl on rocclr" >&2
echo "No $OPENCL_ON_ROCclr_ROOT/CMakeLists.txt file, skipping opencl on rocclr"
exit 0
else
_OCL_CMAKELIST_DIR="$OPENCL_ON_ROCclr_ROOT"
_OCL_CMAKELIST_OPT=""
fi
echo "$_OCL_CMAKELIST_DIR"
mkdir -p "$BUILD_PATH"
pushd "$BUILD_PATH"
if [ ! -e Makefile ]; then
echo "Building OpenCL-On-ROCclr CMake environment"
cmake \
$(rocm_cmake_params) \
-DUSE_COMGR_LIBRARY=ON \
$(rocm_common_cmake_params) \
-DLINK_COMGR_STATIC="no" \
-DBUILD_TESTS=ON \
$_OCL_CMAKELIST_OPT \
"$_OCL_CMAKELIST_DIR"
echo "CMake complete"
fi
echo "Building OpenCL-On-ROCclr"
cmake --build . -- $MAKEOPTS
echo "Installing OpenCL-On-ROCclr"
cmake --build . -- $MAKEOPTS install
popd
}
package_opencl_on_rocclr() {
echo "Packaging OpenCL-On-ROCclr"
pushd "$BUILD_PATH"
cmake --build . -- package
mkdir -p $PACKAGE_DEB
mkdir -p $PACKAGE_RPM
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_DEB" *.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_RPM" *.rpm
popd
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${PACKAGE_DEB};;
("rpm")
echo ${PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
case $TARGET in
(clean) clean_opencl_on_rocclr ;;
(build) build_opencl_on_rocclr ; package_opencl_on_rocclr ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

673
rocm-build/build_openmp_extras.sh Executable file
View File

@@ -0,0 +1,673 @@
#!/bin/bash
source ${BASH_SOURCE%/*}/compute_utils.sh
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -p, --package <type> Specify packaging format"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
packageMajorVersion="17.60"
packageMinorVersion="0"
packageVersion="${packageMajorVersion}.${packageMinorVersion}.${ROCM_LIBPATCH_VERSION}"
BUILD_PATH="$(getBuildPath openmp-extras)"
DEB_PATH="$(getDebPath openmp-extras)"
RPM_PATH="$(getRpmPath openmp-extras)"
TARGET="build"
MAKEOPTS="$DASH_JAY"
export INSTALL_PREFIX=${ROCM_INSTALL_PATH}
while [ "$1" != "" ];
do
case $1 in
-c | --clean )
TARGET="clean" ;;
-p | --package )
TARGET="package" ;;
-r | --release )
;;
-a | --address_sanitizer )
set_asan_env_vars
set_address_sanitizer_on
export ROCM_CMAKECONFIG_PATH="$INSTALL_PREFIX/lib/asan/cmake"
export VERBOSE=1
export LDSHARED="$INSTALL_PREFIX/lib/llvm/bin/clang -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2"
export SANITIZER=1 ;;
-o | --outdir )
shift 1; PKGTYPE=$1 ; TARGET="outdir" ;;
-h | --help )
printUsage ; exit 0 ;;
*)
MAKEARG=$@ ; break ;;
esac
shift 1
done
clean_openmp_extras() {
rm -rf "$BUILD_PATH"
rm -rf "$INSTALL_PREFIX/openmp-extras"
}
toStdoutStderr(){
printf '%s\n' "$@" >&2
printf '%s\n' "$@"
}
clean_examples(){
rm -f "$1"/*.sh
rm -f "$1"/fortran/*.sh
rm -f "$1"/openmp/*.sh
}
build_openmp_extras() {
mkdir -p "$BUILD_PATH"
pushd "$BUILD_PATH"
echo "Building openmp-extras"
echo BUILD_PATH: $BUILD_PATH
echo "INSTALL_PREFIX:$INSTALL_PREFIX"
export AOMP_STANDALONE_BUILD=0
set +e
checkDevel=$(grep "ENABLE_DEVEL_PACKAGE=ON" $AOMP_REPOS/aomp/bin/build_openmp.sh)
set -e
if [ "$checkDevel" == "" ]; then
export AOMP=$INSTALL_PREFIX/lib/llvm
else
export DEVEL_PACKAGE="devel/"
export AOMP=$INSTALL_PREFIX/openmp-extras
fi
export BUILD_AOMP=$BUILD_PATH
if [ "$EPSDB" == "1" ]; then
export ROCM_DIR=$ROCM_INSTALL_PATH
else
export ROCM_DIR=$INSTALL_PREFIX
fi
if [ -d "$ROCM_DIR" ]; then
echo "--------------------------"
echo "ROCM_DIR:"
echo "----------"
ls $ROCM_DIR
echo "--------------------------"
fi
if [ -d "$ROCM_DIR"/include ]; then
echo "ROCM_DIR/include:"
echo "----------"
ls $ROCM_DIR/include
echo "--------------------------"
fi
if [ -d "$ROCM_DIR"/include/hsa ]; then
echo "ROCM_DIR/include/hsa:"
echo "----------"
ls $ROCM_DIR/include/hsa
echo "--------------------------"
fi
export AOMP_JENKINS_BUILD_LIST="extras openmp pgmath flang flang_runtime"
echo "BEGIN Build of openmp-extras"
"$AOMP_REPOS"/aomp/bin/build_aomp.sh $MAKEARG
popd
}
package_openmp_extras_deb() {
local packageName=$1
local packageDeb="$packageDir/deb"
local packageArch="amd64"
local packageMaintainer="Openmp Extras Support <openmp-extras.support@amd.com>"
local packageSummary="OpenMP Extras provides openmp and flang libraries."
local packageSummaryLong="openmp-extras $packageVersion is based on LLVM 15 and is used for offloading to Radeon GPUs."
local debDependencies="rocm-llvm, rocm-device-libs, rocm-core"
local debRecommends="gcc, g++"
local controlFile="$packageDeb/openmp-extras/DEBIAN/control"
if [ "$packageName" == "openmp-extras-runtime" ]; then
packageType="runtime"
debDependencies="rocm-core, hsa-rocr"
else
local debProvides="openmp-extras"
local debConflicts="openmp-extras"
local debReplaces="openmp-extras"
packageType="devel"
debDependencies="$debDependencies, openmp-extras-runtime, hsa-rocr-dev"
fi
if [ -f "$BUILD_PATH"/build/installed_files.txt ] && [ ! -d "$INSTALL_PREFIX"/openmp-extras/devel ]; then
if [ "$packageType" == "runtime" ]; then
rm -rf "$packageDir"
rm -rf "$DEB_PATH"
mkdir -p "$DEB_PATH"
mkdir -p $packageDeb/openmp-extras
mkdir -p $packageDeb/openmp-extras$copyPath/share/doc/openmp-extras
cp -r $AOMP_REPOS/aomp/LICENSE $packageDeb/openmp-extras$copyPath/share/doc/openmp-extras/LICENSE.apache2
cp -r $AOMP_REPOS/aomp-extras/LICENSE $packageDeb/openmp-extras$copyPath/share/doc/openmp-extras/LICENSE.mit
cp -r $AOMP_REPOS/flang/LICENSE.txt $packageDeb/openmp-extras$copyPath/share/doc/openmp-extras/LICENSE.flang
else
rm -rf $packageDeb/openmp-extras/*
mkdir -p $packageDeb/openmp-extras$copyPath/bin
cp -r --parents "$installPath"/lib-debug/src $packageDeb/openmp-extras
fi
else
if [ "$packageType" == "runtime" ]; then
rm -rf "$packageDir"
rm -rf "$DEB_PATH"
mkdir -p "$DEB_PATH"
mkdir -p $packageDeb/openmp-extras$installPath
mkdir -p $packageDeb/openmp-extras$installPath/lib/clang/$llvm_ver/include
mkdir -p $packageDeb/openmp-extras$copyPath/share/doc/openmp-extras
cp -r $AOMP_REPOS/aomp/LICENSE $packageDeb/openmp-extras$copyPath/share/doc/openmp-extras/LICENSE.apache2
cp -r $AOMP_REPOS/aomp-extras/LICENSE $packageDeb/openmp-extras$copyPath/share/doc/openmp-extras/LICENSE.mit
cp -r $AOMP_REPOS/flang/LICENSE.txt $packageDeb/openmp-extras$copyPath/share/doc/openmp-extras/LICENSE.flang
else
rm -rf $packageDeb/openmp-extras$installPath/*
rm -rf $packageDeb/openmp-extras/bin
rm -rf $packageDeb/openmp-extras$copyPath/share
echo mkdir -p $packageDeb/openmp-extras$copyPath/bin
mkdir -p $packageDeb/openmp-extras$copyPath/bin
mkdir -p $packageDeb/openmp-extras$installPath/lib/clang/$llvm_ver/include
fi
fi
mkdir -p "$(dirname $controlFile)"
if [ -f "$BUILD_PATH"/build/installed_files.txt ] && [ ! -d "$INSTALL_PREFIX"/openmp-extras/devel ]; then
if [ "$packageType" == "runtime" ]; then
cat "$BUILD_PATH"/build/installed_files.txt | grep -P '\.so|\.a' | cut -d":" -f2 | cut -d" " -f2 | xargs -I {} cp -d --parents {} "$packageDeb"/openmp-extras
cp -d --parents "$installPath/lib/libgomp.so" "$packageDeb"/openmp-extras
cp -d --parents "$installPath/lib/libiomp5.so" "$packageDeb"/openmp-extras
cp -d --parents "$installPath/lib-debug/libgomp.so" "$packageDeb"/openmp-extras
cp -d --parents "$installPath/lib-debug/libiomp5.so" "$packageDeb"/openmp-extras
else
cat "$BUILD_PATH"/build/installed_files.txt | grep -Pv '\.so|\.a' | cut -d":" -f2 | cut -d" " -f2 | xargs -I {} cp -d --parents {} "$packageDeb"/openmp-extras
fi
else
cp -r "$AOMP"/"$packageType"/* "$packageDeb"/openmp-extras"$installPath"
fi
if [ "$packageType" == "devel" ]; then
mkdir -p "$packageDeb"/openmp-extras"$copyPath"/share/openmp-extras/examples
echo cp -r "$AOMP_REPOS"/aomp/examples/fortran "$packageDeb"/openmp-extras"$copyPath"/share/openmp-extras/examples
cp -r "$AOMP_REPOS"/aomp/examples/fortran "$packageDeb"/openmp-extras"$copyPath"/share/openmp-extras/examples
cp -r "$AOMP_REPOS"/aomp/examples/openmp "$packageDeb"/openmp-extras"$copyPath"/share/openmp-extras/examples
cp -r "$AOMP_REPOS"/aomp/examples/tools "$packageDeb"/openmp-extras"$copyPath"/share/openmp-extras/examples
clean_examples "$packageDeb"/openmp-extras"$copyPath"/share/openmp-extras/examples
fi
if [ "$packageType" == "devel" ]; then
ln -s ../../../../include/omp.h $packageDeb/openmp-extras$installPath/lib/clang/$llvm_ver/include/omp.h
ln -s ../../../../include/ompt.h $packageDeb/openmp-extras$installPath/lib/clang/$llvm_ver/include/ompt.h
ln -s ../../../../include/omp-tools.h $packageDeb/openmp-extras$installPath/lib/clang/$llvm_ver/include/omp-tools.h
if [ ! -h "$packageDeb"/openmp-extras"$copyPath"/bin/aompcc ] && [ -e "$packageDeb"/openmp-extras"$installPath"/bin/aompcc ]; then
ln -s ../lib/llvm/bin/aompcc "$packageDeb"/openmp-extras"$copyPath"/bin/aompcc
fi
if [ -e "$packageDeb"/openmp-extras"$installPath"/bin/mymcpu ]; then
ln -s ../lib/llvm/bin/mymcpu "$packageDeb"/openmp-extras"$copyPath"/bin/mymcpu
fi
if [ -e "$packageDeb"/openmp-extras"$installPath"/bin/mygpu ]; then
ln -s ../lib/llvm/bin/mygpu "$packageDeb"/openmp-extras"$copyPath"/bin/mygpu
fi
fi
ls -l "$packageDeb"/openmp-extras"$installPath"
if [ "$packageType" == "devel" ]; then
ls -l "$packageDeb"/openmp-extras"$installPath"/bin
ls -l "$packageDeb"/openmp-extras"$copyPath"/bin
fi
{
echo "Package: $packageName"
echo "Architecture: $packageArch"
echo "Section: devel"
echo "Priority: optional"
echo "Maintainer: $packageMaintainer"
echo "Version: $packageVersion-${CPACK_DEBIAN_PACKAGE_RELEASE}"
echo "Depends: $debDependencies"
echo "Recommends: $debRecommends"
if [ "$packageType" == "devel" ]; then
echo "Provides: $debProvides"
echo "Conflicts: $debConflicts"
echo "Replaces: $debReplaces"
fi
echo "Description: $packageSummary"
echo " $packageSummaryLong"
} > $controlFile
fakeroot dpkg-deb -Zgzip --build $packageDeb/openmp-extras \
"$DEB_PATH/${packageName}_${packageVersion}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${packageArch}.deb"
}
package_openmp_extras_asan_deb() {
local packageName=$1
local packageDeb="$packageDir/deb"
local packageArch="amd64"
local packageMaintainer="Openmp Extras Support <openmp-extras.support@amd.com>"
local packageSummary="AddressSanitizer OpenMP Extras provides instrumented openmp and flang libraries."
local packageSummaryLong="openmp-extras $packageVersion is based on LLVM 15 and is used for offloading to Radeon GPUs."
local debDependencies="hsa-rocr-asan, rocm-core-asan"
local debRecommends="gcc, g++"
local controlFile="$packageDeb/openmp-extras/DEBIAN/control"
local asanLibDir="runtime"
rm -rf "$packageDir"
rm -rf "$DEB_PATH"
mkdir -p "$DEB_PATH"
local licenseDir="$packageDeb/openmp-extras$copyPath/share/doc/openmp-extras-asan"
mkdir -p $licenseDir
cp -r $AOMP_REPOS/aomp/LICENSE $licenseDir/LICENSE.apache2
cp -r $AOMP_REPOS/aomp-extras/LICENSE $licenseDir/LICENSE.mit
cp -r $AOMP_REPOS/flang/LICENSE.txt $licenseDir/LICENSE.flang
mkdir -p "$(dirname $controlFile)"
if [ -f "$BUILD_PATH"/build/installed_files.txt ] && [ ! -d "$INSTALL_PREFIX"/openmp-extras ]; then
cat "$BUILD_PATH"/build/installed_files.txt | grep -P 'asan' | cut -d":" -f2 | cut -d" " -f2 | xargs -I {} cp -d --parents {} "$packageDeb"/openmp-extras
cp -d --parents "$installPath/lib/asan/libgomp.so" "$packageDeb"/openmp-extras
cp -d --parents "$installPath/lib/asan/libiomp5.so" "$packageDeb"/openmp-extras
cp -d --parents "$installPath/lib-debug/asan/libgomp.so" "$packageDeb"/openmp-extras
cp -d --parents "$installPath/lib-debug/asan/libiomp5.so" "$packageDeb"/openmp-extras
else
mkdir -p $packageDeb/openmp-extras$installPath/lib/asan
mkdir -p $packageDeb/openmp-extras$installPath/lib-debug/asan
cp -r "$AOMP"/lib/asan/* "$packageDeb"/openmp-extras"$installPath"/lib/asan/
cp -r "$AOMP"/lib-debug/asan/* "$packageDeb"/openmp-extras"$installPath"/lib-debug/asan/
cp -r "$AOMP"/"$asanLibDir"/lib/asan/* "$packageDeb"/openmp-extras"$installPath"/lib/asan/
cp -r "$AOMP"/"$asanLibDir"/lib-debug/asan/* "$packageDeb"/openmp-extras"$installPath"/lib-debug/asan/
cp -r "$AOMP"/devel/lib/asan/* "$packageDeb"/openmp-extras"$installPath"/lib/asan/
cp -r "$AOMP"/devel/lib-debug/asan/* "$packageDeb"/openmp-extras"$installPath"/lib-debug/asan/
fi
{
echo "Package: $packageName"
echo "Architecture: $packageArch"
echo "Section: devel"
echo "Priority: optional"
echo "Maintainer: $packageMaintainer"
echo "Version: $packageVersion-${CPACK_DEBIAN_PACKAGE_RELEASE}"
echo "Depends: $debDependencies"
echo "Recommends: $debRecommends"
echo "Description: $packageSummary"
echo " $packageSummaryLong"
} > $controlFile
fakeroot dpkg-deb -Zgzip --build $packageDeb/openmp-extras \
"$DEB_PATH/${packageName}_${packageVersion}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${packageArch}.deb"
}
package_openmp_extras_rpm() {
local packageName=$1
local packageRpm="$packageDir/rpm"
local specFile="$packageDir/$packageName.spec"
local packageSummary="OpenMP Extras provides openmp and flang libraries."
local packageSummaryLong="openmp-extras $packageVersion is based on LLVM 15 and is used for offloading to Radeon GPUs."
local rpmRequires="rocm-llvm, rocm-device-libs, rocm-core"
if [ "$packageName" == "openmp-extras-runtime" ]; then
packageType="runtime"
rpmRequires="rocm-core, hsa-rocr"
else
local rpmProvides="openmp-extras"
local rpmObsoletes="openmp-extras"
packageType="devel"
rpmRequires="$rpmRequires, openmp-extras-runtime, hsa-rocr-devel"
fi
rm -f "$AOMP_REPOS"/aomp/examples/*.sh
rm -f "$AOMP_REPOS"/aomp/examples/fortran/*.sh
rm -f "$AOMP_REPOS"/aomp/examples/openmp/*.sh
if [ "$packageType" == "runtime" ]; then
rm -rf "$packageDir"
rm -rf "$RPM_PATH"
mkdir -p "$RPM_PATH"
fi
echo RPM_PATH: $RPM_PATH
echo mkdir -p $(dirname $specFile)
mkdir -p "$(dirname $specFile)"
{
echo "%define is_runtime %( if [ $packageType == runtime ]; then echo "1" ; else echo "0"; fi )"
echo "%define is_devel %( if [ $packageType == devel ]; then echo "1" ; else echo "0"; fi )"
echo "Name: $packageName"
echo "Version: $packageVersion"
echo "Release: ${CPACK_RPM_PACKAGE_RELEASE}%{?dist}"
echo "Summary: $packageSummary"
echo "Group: System Environment/Libraries"
echo "License: MIT and ASL 2.0 and ASL 2.0 with exceptions"
echo "Vendor: Advanced Micro Devices, Inc."
echo "Requires: $rpmRequires"
echo "%if %is_devel"
echo "Provides: $rpmProvides"
echo "Obsoletes: $rpmObsoletes"
echo "%endif"
echo "%define debug_package %{nil}"
echo "%define __os_install_post %{nil}"
echo "%description"
echo "$packageSummaryLong"
echo "%prep"
echo "%setup -T -D -c -n $packageName"
echo "%build"
echo "%install"
echo "if [ -f $BUILD_PATH/build/installed_files.txt ] && [ ! -d $INSTALL_PREFIX/openmp-extras/devel ]; then"
echo " %if %is_runtime"
echo " mkdir -p \$RPM_BUILD_ROOT/openmp-extras"
echo " %else"
echo " mkdir -p \$RPM_BUILD_ROOT$copyPath/bin"
echo " mkdir -p \$RPM_BUILD_ROOT$installPath/lib/clang/$llvm_ver/include"
echo " %endif"
echo "else"
echo " %if %is_runtime"
echo " mkdir -p \$RPM_BUILD_ROOT$installPath"
echo " %else"
echo " rm -rf \$RPM_BUILD_ROOT/openmp-extras$installPath/*"
echo " echo mkdir -p \$RPM_BUILD_ROOT$copyPath/bin"
echo " mkdir -p \$RPM_BUILD_ROOT$copyPath/bin"
echo " mkdir -p \$RPM_BUILD_ROOT$installPath/lib/clang/$llvm_ver/include"
echo " %endif"
echo "fi"
echo "if [ -f $BUILD_PATH/build/installed_files.txt ] && [ ! -d $INSTALL_PREFIX/openmp-extras/devel ]; then"
echo " %if %is_runtime"
echo " cat $BUILD_PATH/build/installed_files.txt | grep -P '\.so|\.a' | cut -d':' -f2 | cut -d' ' -f2 | xargs -I {} cp -d --parents {} \$RPM_BUILD_ROOT"
echo " cp -d --parents "$installPath/lib/libgomp.so" \$RPM_BUILD_ROOT"
echo " cp -d --parents "$installPath/lib/libiomp5.so" \$RPM_BUILD_ROOT"
echo " cp -d --parents "$installPath/lib-debug/libgomp.so" \$RPM_BUILD_ROOT"
echo " cp -d --parents "$installPath/lib-debug/libiomp5.so" \$RPM_BUILD_ROOT"
echo " %endif"
echo "%if %is_devel"
echo " cat "$BUILD_PATH"/build/installed_files.txt | grep -Pv '\.so|\.a' | cut -d':' -f2 | cut -d' ' -f2 | xargs -I {} cp -d --parents {} \$RPM_BUILD_ROOT"
echo "%endif"
echo "else"
echo " cp -r $AOMP/$packageType/* \$RPM_BUILD_ROOT$installPath"
echo " %if %is_devel"
echo " rm -rf \$RPM_BUILD_ROOT$installPath/share"
echo " %endif"
echo "fi"
echo "%if %is_devel"
echo " if [ ! -h \$RPM_BUILD_ROOT$copyPath/bin/aompcc ] && [ -e \$RPM_BUILD_ROOT$installPath/bin/aompcc ]; then"
echo " ln -s ../lib/llvm/bin/aompcc \$RPM_BUILD_ROOT$copyPath/bin/aompcc"
echo " fi"
echo " if [ -e \$RPM_BUILD_ROOT$installPath/bin/mymcpu ]; then"
echo " ln -s ../lib/llvm/bin/mymcpu \$RPM_BUILD_ROOT$copyPath/bin/mymcpu"
echo " fi"
echo " if [ -e \$RPM_BUILD_ROOT$installPath/bin/mygpu ]; then"
echo " ln -s ../lib/llvm/bin/mygpu \$RPM_BUILD_ROOT$copyPath/bin/mygpu"
echo " fi"
echo " ls \$RPM_BUILD_ROOT$copyPath"
echo " ln -s ../../../../include/omp.h \$RPM_BUILD_ROOT/$installPath/lib/clang/$llvm_ver/include/omp.h"
echo " ln -s ../../../../include/ompt.h \$RPM_BUILD_ROOT/$installPath/lib/clang/$llvm_ver/include/ompt.h"
echo " ln -s ../../../../include/omp-tools.h \$RPM_BUILD_ROOT/$installPath/lib/clang/$llvm_ver/include/omp-tools.h"
echo "%endif"
echo 'find $RPM_BUILD_ROOT \! -type d | sed "s|$RPM_BUILD_ROOT||"> files.list'
echo "%if %is_runtime"
echo " mkdir -p \$RPM_BUILD_ROOT$copyPath/share/doc/openmp-extras"
echo " cp -r $AOMP_REPOS/aomp/LICENSE \$RPM_BUILD_ROOT$copyPath/share/doc/openmp-extras/LICENSE.apache2"
echo " cp -r $AOMP_REPOS/aomp-extras/LICENSE \$RPM_BUILD_ROOT$copyPath/share/doc/openmp-extras/LICENSE.mit"
echo " cp -r $AOMP_REPOS/flang/LICENSE.txt \$RPM_BUILD_ROOT$copyPath/share/doc/openmp-extras/LICENSE.flang"
echo "%else"
echo " mkdir -p \$RPM_BUILD_ROOT$copyPath/share/openmp-extras/examples"
echo " cp -r $AOMP_REPOS/aomp/examples/fortran \$RPM_BUILD_ROOT$copyPath/share/openmp-extras/examples"
echo " cp -r $AOMP_REPOS/aomp/examples/openmp \$RPM_BUILD_ROOT$copyPath/share/openmp-extras/examples"
echo " cp -r $AOMP_REPOS/aomp/examples/tools \$RPM_BUILD_ROOT$copyPath/share/openmp-extras/examples"
clean_examples \$RPM_BUILD_ROOT$copyPath/share/openmp-extras/examples
echo "%endif"
echo "%clean"
echo "rm -rf \$RPM_BUILD_ROOT"
echo "%files -f files.list"
echo "%if %is_runtime"
echo " $copyPath/share/doc/openmp-extras"
echo "%else"
echo " $copyPath/share/openmp-extras"
echo "%endif"
echo "%defattr(-,root,root,-)"
echo "%if %is_runtime || %is_devel"
echo " $copyPath"
echo "%endif"
} > $specFile
rpmbuild --define "_topdir $packageRpm" -ba $specFile
mv $packageRpm/RPMS/x86_64/*.rpm $RPM_PATH
}
package_openmp_extras_asan_rpm() {
local packageName=$1
local packageRpm="$packageDir/rpm"
local specFile="$packageDir/$packageName.spec"
local packageSummary="AddressSanitizer OpenMP Extras provides instrumented openmp and flang libraries."
local packageSummaryLong="openmp-extras $packageVersion is based on LLVM 15 and is used for offloading to Radeon GPUs."
local rpmRequires="hsa-rocr-asan, rocm-core-asan"
local asanLibDir="runtime"
rm -rf "$packageDir"
rm -rf "$RPM_PATH"
mkdir -p "$RPM_PATH"
echo RPM_PATH: $RPM_PATH
echo mkdir -p $(dirname $specFile)
mkdir -p "$(dirname $specFile)"
{
echo "Name: $packageName"
echo "Version: $packageVersion"
echo "Release: ${CPACK_RPM_PACKAGE_RELEASE}%{?dist}"
echo "Summary: $packageSummary"
echo "Group: System Environment/Libraries"
echo "License: MIT and ASL 2.0 and ASL 2.0 with exceptions"
echo "Vendor: Advanced Micro Devices, Inc."
echo "Requires: $rpmRequires"
echo "%define __os_install_post %{nil}"
echo "%description"
echo "%undefine _debugsource_packages"
echo "$packageSummaryLong"
echo "%prep"
echo "%setup -T -D -c -n $packageName"
echo "%build"
echo "%install"
echo "if [ -f $BUILD_PATH/build/installed_files.txt ] && [ ! -d "$INSTALL_PREFIX"/openmp-extras ]; then"
echo " cat $BUILD_PATH/build/installed_files.txt | grep -P 'asan' | cut -d':' -f2 | cut -d' ' -f2 | xargs -I {} cp -d --parents {} \$RPM_BUILD_ROOT"
echo " cp -d --parents "$installPath/lib/asan/libgomp.so" \$RPM_BUILD_ROOT"
echo " cp -d --parents "$installPath/lib/asan/libiomp5.so" \$RPM_BUILD_ROOT"
echo " cp -d --parents "$installPath/lib-debug/asan/libgomp.so" \$RPM_BUILD_ROOT"
echo " cp -d --parents "$installPath/lib-debug/asan/libiomp5.so" \$RPM_BUILD_ROOT"
echo "else"
echo " mkdir -p \$RPM_BUILD_ROOT$installPath/lib/asan"
echo " mkdir -p \$RPM_BUILD_ROOT$installPath/lib-debug/asan"
echo " cp -r $AOMP/lib/asan/* \$RPM_BUILD_ROOT$installPath/lib/asan"
echo " cp -r $AOMP/lib-debug/asan/* \$RPM_BUILD_ROOT$installPath/lib-debug/asan"
echo " cp -r $AOMP/$asanLibDir/lib/asan/* \$RPM_BUILD_ROOT$installPath/lib/asan"
echo " cp -r $AOMP/$asanLibDir/lib-debug/asan/* \$RPM_BUILD_ROOT$installPath/lib-debug/asan"
echo " cp -r $AOMP/devel/lib/asan/* \$RPM_BUILD_ROOT$installPath/lib/asan"
echo " cp -r $AOMP/devel/lib-debug/asan/* \$RPM_BUILD_ROOT$installPath/lib-debug/asan"
echo "fi"
echo 'find $RPM_BUILD_ROOT \! -type d | sed "s|$RPM_BUILD_ROOT||"> files.list'
echo " mkdir -p \$RPM_BUILD_ROOT$copyPath/share/doc/openmp-extras-asan"
echo " cp -r $AOMP_REPOS/aomp/LICENSE \$RPM_BUILD_ROOT$copyPath/share/doc/openmp-extras-asan/LICENSE.apache2"
echo " cp -r $AOMP_REPOS/aomp-extras/LICENSE \$RPM_BUILD_ROOT$copyPath/share/doc/openmp-extras-asan/LICENSE.mit"
echo " cp -r $AOMP_REPOS/flang/LICENSE.txt \$RPM_BUILD_ROOT$copyPath/share/doc/openmp-extras-asan/LICENSE.flang"
echo "%clean"
echo "rm -rf \$RPM_BUILD_ROOT"
echo "%files -f files.list"
echo " $copyPath/share/doc/openmp-extras-asan"
echo "%defattr(-,root,root,-)"
echo " $copyPath"
} > $specFile
rpmbuild --define "_topdir $packageRpm" -ba $specFile
mv $packageRpm/RPMS/x86_64/*.rpm $RPM_PATH
}
package_openmp_extras() {
local DISTRO_NAME=$(cat /etc/os-release | grep -e ^NAME=)
local installPath="$ROCM_INSTALL_PATH/lib/llvm"
local copyPath="$ROCM_INSTALL_PATH"
local packageDir="$BUILD_PATH/package"
local llvm_ver=`$INSTALL_PREFIX/lib/llvm/bin/clang --print-resource-dir | sed 's^/llvm/lib/clang/^ ^' | awk '{print $2}'`
local debNames="openmp-extras-runtime openmp-extras-dev"
local rpmNames="openmp-extras-runtime openmp-extras-devel"
if [ "$SANITIZER" == "1" ]; then
local asanPkgName="openmp-extras-asan"
if [[ $DISTRO_NAME =~ "Ubuntu" ]]; then
package_openmp_extras_asan_deb $asanPkgName
else
package_openmp_extras_asan_rpm $asanPkgName
fi
return 0
fi
if [[ $DISTRO_NAME =~ "Ubuntu" ]]; then
for name in $debNames; do
package_openmp_extras_deb $name
done
else
for name in $rpmNames; do
package_openmp_extras_rpm $name
done
fi
}
package_tests_deb(){
local packageDir="$BUILD_PATH/package"
local packageDeb="$packageDir/deb"
local packageArch="amd64"
local packageMaintainer="Openmp Extras Support <openmp-extras.support@amd.com>"
local packageSummary="Tests for openmp-extras."
local packageSummaryLong="Tests for openmp-extras $packageMajorVersion-$packageMinorVersion is based on LLVM 15 and is used for offloading to Radeon GPUs."
local debDependencies="rocm-core"
local debRecommends="gcc, g++"
local controlFile="$packageDeb/openmp-extras/DEBIAN/control"
local installPath="$ROCM_INSTALL_PATH/share/openmp-extras/tests"
local packageName="openmp-extras-tests"
rm -rf "$packageDir"
mkdir -p $packageDeb/openmp-extras$installPath; mkdir -p $packageDeb/openmp-extras$copyPath/bin
if [ -e $(dirname $controlFile) ]; then
rm $(dirname $controlFile)
fi
mkdir -p "$(dirname $controlFile)"
cp -r "$AOMP_REPOS/aomp/test/smoke" "$packageDeb$installPath"
{
echo "Package: $packageName"
echo "Architecture: $packageArch"
echo "Section: devel"
echo "Priority: optional"
echo "Maintainer: $packageMaintainer"
echo "Version: $packageVersion-${CPACK_DEBIAN_PACKAGE_RELEASE}"
echo "Depends: $debDependencies"
echo "Recommends: $debRecommends"
echo "Description: $packageSummary"
echo " $packageSummaryLong"
} > $controlFile
fakeroot dpkg-deb -Zgzip --build $packageDeb/openmp-extras \
"${DEB_PATH}/${packageName}_${packageVersion}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${packageArch}.deb"
}
package_tests_rpm(){
AOMP_STANDALONE_BUILD=1 $AOMP_REPOS/aomp/bin/build_fixups.sh
local copyPath="$ROCM_INSTALL_PATH"
local packageDir="$BUILD_PATH/package"
local packageRpm="$packageDir/rpm"
local installPath="$ROCM_INSTALL_PATH/share/openmp-extras/tests"
local packageName="openmp-extras-tests"
local specFile="$packageDir/$packageName.spec"
local packageSummary="Tests for openmp-extras."
local packageSummaryLong="Tests for openmp-extras $packageVersion is based on LLVM 15 and is used for offloading to Radeon GPUs."
rm -rf "$packageDir"
mkdir -p "$packageRpm$installPath"
{
echo "Name: $packageName"
echo "Version: $packageVersion"
echo "Release: ${CPACK_RPM_PACKAGE_RELEASE}%{?dist}"
echo "Summary: $packageSummary"
echo "Group: System Environment/Libraries"
echo "License: Advanced Micro Devices, Inc."
echo "Vendor: Advanced Micro Devices, Inc."
echo "%define debug_package %{nil}"
echo "%define __os_install_post %{nil}"
echo "%description"
echo "$packageSummaryLong"
echo "%prep"
echo "%setup -T -D -c -n $packageName"
echo "%build"
echo "%install"
echo "mkdir -p \$RPM_BUILD_ROOT$copyPath/share/aomp/tests"
echo "cp -R $AOMP_REPOS/aomp/test/smoke \$RPM_BUILD_ROOT$copyPath/share/aomp/tests"
echo 'find $RPM_BUILD_ROOT \! -type d | sed "s|$RPM_BUILD_ROOT||"> files.list'
echo "%clean"
echo "rm -rf \$RPM_BUILD_ROOT"
echo "%files -f files.list"
echo "%defattr(-,root,root,-)"
echo "%postun"
echo "rm -rf $ROCM_INSTALL_PATH/share/aomp"
} > $specFile
rpmbuild --define "_topdir $packageRpm" -ba $specFile
mv $packageRpm/RPMS/x86_64/*.rpm $RPM_PATH
}
package_tests() {
local DISTRO_NAME=$(cat /etc/os-release | grep -e ^NAME=)
if [[ $DISTRO_NAME =~ "Ubuntu" ]]; then
package_tests_deb
else
package_tests_rpm
fi
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${DEB_PATH};;
("rpm")
echo ${RPM_PATH};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
case $TARGET in
(clean) clean_openmp_extras ;;
(build) build_openmp_extras; package_openmp_extras ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

65
rocm-build/build_rccl.sh Executable file
View File

@@ -0,0 +1,65 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src rccl
ENABLE_ADDRESS_SANITIZER=false
build_rccl() {
echo "Start build"
mkdir -p $ROCM_PATH/.info/
echo $ROCM_VERSION | tee $ROCM_PATH/.info/version
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
mkdir -p $BUILD_DIR && cd $BUILD_DIR
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
CC=${ROCM_PATH}/bin/amdclang \
CXX=$(set_build_variables CXX) \
cmake \
$(rocm_common_cmake_params) \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DHIP_COMPILER=clang \
-DCMAKE_PREFIX_PATH="${ROCM_PATH};${ROCM_PATH}/share/rocm/cmake/" \
-DCPACK_GENERATOR="${PKGTYPE^^}" \
-DROCM_PATCH_VERSION=$ROCM_LIBPATCH_VERSION \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
-DBUILD_TESTS=ON \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rccl() {
echo "Cleaning rccl build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_rccl ;;
outdir) print_output_directory ;;
clean) clean_rccl ;;
*) die "Invalid target $TARGET" ;;
esac

234
rocm-build/build_rdc.sh Executable file
View File

@@ -0,0 +1,234 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename $0) [-c|-r|-h] [makeopts]"
echo
echo "Options:"
echo " -c, --clean Removes all rdc build artifacts, except grpc"
echo " -g, --clean_grpc Removes the grpc files and artifacts"
echo " -r, --release Build release version of RDC (default is debug)"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -s, --static Build static lib (.a). build instead of dynamic/shared(.so) "
echo " -h, --help Prints this help"
echo
return 0
}
PACKAGE_ROOT="$(getPackageRoot)"
RDC_BUILD_DIR=$(getBuildPath rdc)
GRPC_BUILD_DIR=$(getBuildPath grpc)
TARGET="build"
PACKAGE_LIB=$(getLibPath)
PACKAGE_INCLUDE="$(getIncludePath)"
PACKAGE_BIN="$(getBinPath)"
RDC_PACKAGE_DEB_DIR="$PACKAGE_ROOT/deb/rdc"
RDC_PACKAGE_RPM_DIR="$PACKAGE_ROOT/rpm/rdc"
BUILD_TYPE="Debug"
MAKETARGET="deb"
MAKEARG="$DASH_JAY O=$RDC_BUILD_DIR"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
CLEAN_GRPC="no"
PKGTYPE="deb"
RDC_MAKE_OPTS="$DASH_JAY O=$RDC_BUILD_DIR -C $RDC_BUILD_DIR"
BUILD_DOCS="no"
RDC_PKG_NAME_ROOT="rdc"
RDC_PKG_NAME="${RDC_PKG_NAME_ROOT}"
GRPC_PROTOC_ROOT="${RDC_BUILD_DIR}/grpc"
GRPC_SEARCH_ROOT="/usr/grpc"
GRPC_DESIRED_VERSION="1.59.1" # do not include 'v'
RDC_LIB_RPATH='$ORIGIN'
RDC_LIB_RPATH=$RDC_LIB_RPATH:'$ORIGIN/..'
RDC_LIB_RPATH=$RDC_LIB_RPATH:'$ORIGIN/rdc/grpc/lib'
RDC_LIB_RPATH=$RDC_LIB_RPATH:'$ORIGIN/grpc/lib'
RDC_EXE_RPATH='$ORIGIN/../lib'
RDC_EXE_RPATH=$RDC_EXE_RPATH:'$ORIGIN/../lib/rdc/grpc/lib'
VALID_STR=`getopt -o hcgradso:p: --long help,clean,clean_grpc,release,documentation,static,address_sanitizer,outdir:,package: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-g | --clean_grpc)
TARGET="clean_grpc" ; shift ;;
(-r | --release)
BUILD_TYPE="Release" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-d | --documentation )
BUILD_DOCS="yes" ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-p | --package)
MAKETARGET="$2" ; shift 2;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_rdc() {
rm -rf "$RDC_BUILD_DIR"
rm -rf "$RDC_PACKAGE_DEB_DIR"
rm -rf "$RDC_PACKAGE_RPM_DIR"
rm -rf "$RDC_BUILD_DIR/rdc"
rm -rf "$PACKAGE_INCLUDE/rdc"
rm -f $PACKAGE_LIB/librdc*
rm -f $PACKAGE_BIN/rdci
return 0
}
clean_grpc() {
rm -rf "$GRPC_BUILD_DIR"
}
find_grpc() {
grep -s -F "$GRPC_DESIRED_VERSION" ${GRPC_SEARCH_ROOT}/*/cmake/grpc/gRPCConfigVersion.cmake &&
GRPC_PROTOC_ROOT=$GRPC_SEARCH_ROOT
}
build_grpc() {
if find_grpc; then
return 0
fi
echo "GRPC SEARCH FAILED! Building from scratch..."
mkdir -p $PACKAGE_ROOT/build
pushd $PACKAGE_ROOT/build
if [ ! -d $PACKAGE_ROOT/build/grpc/.git ]; then
git clone \
--shallow-submodules \
--recurse-submodules \
$DASH_JAY \
-b v${GRPC_DESIRED_VERSION} \
--depth 1 \
https://github.com/grpc/grpc
fi
cd grpc
mkdir -p cmake/build
cd cmake/build
cmake \
-DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${GRPC_PROTOC_ROOT} \
../..
cmake --build . -- $DASH_JAY
cmake --build . -- install
cp ../../LICENSE ${GRPC_PROTOC_ROOT}
popd
}
rdc_backwards_compat_cmake_params() {
grep -q "RDC_CLIENT_INSTALL_PREFIX" "$RDC_ROOT/CMakeLists.txt" &&
echo "-DRDC_CLIENT_INSTALL_PREFIX=$PACKAGE_ROOT"
}
build_rdc() {
echo "Building RDC"
echo "RDC_BUILD_DIR: ${RDC_BUILD_DIR}"
echo "GRPC_PROTOC_ROOT: ${GRPC_PROTOC_ROOT}"
export LD_PRELOAD="$ASAN_LIB_PATH"
if [ ! -d "$RDC_BUILD_DIR/rdc_libs" ]; then
mkdir -p $RDC_BUILD_DIR
pushd $RDC_BUILD_DIR
cmake \
-DGRPC_ROOT="$GRPC_PROTOC_ROOT" \
-DGRPC_DESIRED_VERSION="$GRPC_DESIRED_VERSION" \
-DCMAKE_MODULE_PATH="$RDC_ROOT/cmake_modules" \
$(rocm_cmake_params) \
$(rdc_backwards_compat_cmake_params) \
$(rocm_common_cmake_params) \
-DROCM_DIR=$ROCM_INSTALL_PATH \
-DRDC_PACKAGE="${RDC_PKG_NAME}" \
-DCPACK_PACKAGE_VERSION_MAJOR="1" \
-DCPACK_PACKAGE_VERSION_MINOR="$ROCM_LIBPATCH_VERSION" \
-DCPACK_PACKAGE_VERSION_PATCH="0" \
-DADDRESS_SANITIZER="$ADDRESS_SANITIZER" \
-DBUILD_TESTS=ON \
-DCMAKE_SKIP_BUILD_RPATH=TRUE \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-Wl,--no-as-needed,-z,origin,--enable-new-dtags,--build-id=sha1,--rpath,$RDC_EXE_RPATH" \
-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,--no-as-needed,-z,origin,--enable-new-dtags,--build-id=sha1,--rpath,$RDC_LIB_RPATH" \
"$RDC_ROOT"
popd
fi
echo "Making rdc package:"
cmake --build "$RDC_BUILD_DIR" -- $RDC_MAKE_OPTS
cmake --build "$RDC_BUILD_DIR" -- $RDC_MAKE_OPTS install
unset LD_PRELOAD
cmake --build "$RDC_BUILD_DIR" -- $RDC_MAKE_OPTS package
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$RDC_PACKAGE_DEB_DIR" "$RDC_BUILD_DIR/$RDC_PKG_NAME"*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$RDC_PACKAGE_RPM_DIR" "$RDC_BUILD_DIR/$RDC_PKG_NAME"*.rpm
if [ ! -e $ROCM_INSTALL_PATH/include/rdc/rdc.h ]; then
cp -r "$ROCM_INSTALL_PATH/rdc/lib/." "$PACKAGE_LIB"
cp -r "$ROCM_INSTALL_PATH/rdc/bin/." "$PACKAGE_BIN"
cp -r "$ROCM_INSTALL_PATH/rdc/include/." "$PACKAGE_INCLUDE"
fi
if [ "$BUILD_DOCS" = "yes" ]; then
echo "Building Docs"
cmake --build "$RDC_BUILD_DIR" -- $RDC_MAKE_OPTS doc
pushd $RDC_BUILD_DIR/latex
cmake --build . --
mv refman.pdf "$ROCM_INSTALL_PATH/rdc/RDC_Manual.pdf"
popd
fi
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${RDC_PACKAGE_DEB_DIR};;
("rpm")
echo ${RDC_PACKAGE_RPM_DIR};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
verifyEnvSetup
case $TARGET in
(clean) clean_rdc ;;
(clean_grpc) clean_grpc ;;
(build) build_grpc; build_rdc ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

68
rocm-build/build_rocalution.sh Executable file
View File

@@ -0,0 +1,68 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
PATH=${ROCM_PATH}/bin:$PATH
set_component_src rocALUTION
build_rocalution() {
echo "Start build"
cd $COMPONENT_SRC
CXX="g++"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
echo "C compiler: $CC"
echo "CXX compiler: $CXX"
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
cmake \
-DSUPPORT_HIP=ON \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DCPACK_SET_DESTDIR=OFF \
-DBUILD_CLIENTS_SAMPLES=ON \
-DBUILD_CLIENTS_TESTS=ON \
-DBUILD_CLIENTS_BENCHMARKS=ON \
-DCMAKE_MODULE_PATH="${ROCM_PATH}/lib/cmake/hip;${ROCM_PATH}/hip/cmake" \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rocalution() {
echo "Cleaning rocALUTION build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_rocalution ;;
outdir) print_output_directory ;;
clean) clean_rocalution ;;
*) die "Invalid target $TARGET" ;;
esac

76
rocm-build/build_rocblas.sh Executable file
View File

@@ -0,0 +1,76 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src rocBLAS
DEPS_DIR=${HOME}/rocblas
stage2_command_args "$@"
build_rocblas() {
echo "Start build"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
export ASAN_OPTIONS="detect_leaks=0:verify_asan_link_order=0"
fi
cd $COMPONENT_SRC
mkdir -p $DEPS_DIR && cp -r /usr/blis $DEPS_DIR
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
cmake \
-DCMAKE_TOOLCHAIN_FILE=toolchain-linux.cmake \
-DBUILD_DIR="${BUILD_DIR}" \
$(rocm_common_cmake_params) \
-DROCM_DIR="${ROCM_PATH}" \
${LAUNCHER_FLAGS} \
-DCMAKE_PREFIX_PATH="${DEPS_DIR};${ROCM_PATH}" \
-DCPACK_SET_DESTDIR=OFF \
-DBUILD_CLIENTS_TESTS=ON \
-DBUILD_CLIENTS_BENCHMARKS=ON \
-DBUILD_CLIENTS_SAMPLES=ON \
-DLINK_BLIS=ON \
-DAMDGPU_TARGETS="${GPU_TARGETS}" \
-DTensile_CODE_OBJECT_VERSION=default \
-DTensile_LOGIC=asm_full \
-DTensile_SEPARATE_ARCHITECTURES=ON \
-DTensile_LAZY_LIBRARY_LOADING=ON \
-DTensile_LIBRARY_FORMAT=msgpack \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
-DTENSILE_VENV_UPGRADE_PIP=ON \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && rm -rf ./library/src/build_tmp && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rocblas() {
echo "Cleaning rocBLAS build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
case $TARGET in
build) build_rocblas ;;
outdir) print_output_directory ;;
clean) clean_rocblas ;;
*) die "Invalid target $TARGET" ;;
esac

127
rocm-build/build_rocclr.sh Executable file
View File

@@ -0,0 +1,127 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...] [make options]"
echo
echo "Options:"
echo " -h, --help Prints this help"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -s, --static Build static lib (.a). build instead of dynamic/shared(.so) "
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of type referred to by pkg_type"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
MAKEOPTS="$DASH_JAY"
BUILD_PATH="$(getBuildPath rocclr)"
TARGET="build"
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_DEB="$(getPackageRoot)/deb/rocclr"
PACKAGE_RPM="$(getPackageRoot)/rpm/rocclr"
CORE_BUILD_DIR="$(getBuildPath hsa-core)"
BUILD_TYPE="Debug"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
VALID_STR=`getopt -o hcraso: --long help,clean,release,static,address_sanitizer,outdir: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="Release" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_rocclr() {
rm -rf "$BUILD_PATH"
rm -rf "$PACKAGE_DEB"
rm -rf "$PACKAGE_RPM"
}
build_rocclr() {
if [ "$SHARED_LIBS" = "ON" ]; then
echo "rocclr not a standalone repo. skipping build" >&2
echo "rocclr not a standalone repo. skipping build"
exit 0
fi
if [ ! -e "$CLR_ROOT/CMakeLists.txt" ]; then
_ROCclr_CMAKELIST_DIR="$CLR_ROOT"
elif [ ! -e "$ROCclr_ROOT/CMakeLists.txt" ]; then
echo "No $ROCclr_ROOT/CMakeLists.txt file, skipping rocclr" >&2
echo "No $ROCclr_ROOT/CMakeLists.txt file, skipping rocclr"
exit 0
else
_ROCclr_CMAKELIST_DIR="$ROCclr_ROOT"
fi
echo "$_ROCclr_CMAKELIST_DIR"
mkdir -p "$BUILD_PATH"
pushd "$BUILD_PATH"
print_lib_type $SHARED_LIBS
if [ ! -e Makefile ]; then
echo "Building ROCclr CMake environment"
cmake -DUSE_COMGR_LIBRARY=ON \
$(rocm_cmake_params) \
-DBUILD_SHARED_LIBS=$SHARED_LIBS \
-DLLVM_INCLUDES="$LLVM_ROOT/include" \
$(rocm_common_cmake_params) \
"$_ROCclr_CMAKELIST_DIR"
echo "CMake complete"
fi
echo "Building ROCclr"
cmake --build . -- $MAKEOPTS "VERBOSE=1"
popd
}
case $TARGET in
(clean) clean_rocclr ;;
(build) build_rocclr ;;
(outdir) exit ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

38
rocm-build/build_rocdecode.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src rocDecode
BUILD_DEV=ON
build_rocdecode() {
if [ "$DISTRO_ID" = "centos-7" ] ; then
echo "Not building rocDecode for ${DISTRO_ID}. Exiting..."
return 0
fi
echo "Start build"
mkdir -p $BUILD_DIR && cd $BUILD_DIR
cmake ${COMPONENT_SRC}
make -j8
make install
make package
cmake --build "$BUILD_DIR" -- -j${PROC}
cpack -G ${PKGTYPE^^} -B ${BUILD_DIR}
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR
cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rocdecode() {
echo "Cleaning rocDecode build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_rocdecode ;;
outdir) print_output_directory ;;
clean) clean_rocdecode ;;
*) die "Invalid target $TARGET" ;;
esac

62
rocm-build/build_rocfft.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
PATH=${ROCM_PATH}/bin:$PATH
set_component_src rocFFT
build_rocfft() {
echo "Start Build"
cd $COMPONENT_SRC
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908;gfx90a;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
CXX="${ROCM_PATH}/bin/hipcc" \
cmake \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DUSE_HIP_CLANG=ON \
-DHIP_COMPILER=clang \
-DBUILD_CLIENTS_SAMPLES=ON \
-DBUILD_CLIENTS_TESTS=ON \
-DBUILD_CLIENTS_RIDER=ON \
-DCPACK_SET_DESTDIR=OFF \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rocfft() {
echo "Cleaning rocFFT build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_rocfft ;;
outdir) print_output_directory ;;
clean) clean_rocfft ;;
*) die "Invalid target $TARGET" ;;
esac

121
rocm-build/build_rocm-cmake.sh Executable file
View File

@@ -0,0 +1,121 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -r, --release Build a release version of the package"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -s, --static Supports static CI by accepting this param & not bailing out. No effect of the param though"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -p, --package <type> Specify packaging format"
echo " -h, --help Prints this help"
echo
echo
return 0
}
TARGET="build"
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_DEB="$(getPackageRoot)/deb/rocm-cmake"
PACKAGE_RPM="$(getPackageRoot)/rpm/rocm-cmake"
ROCM_CMAKE_BUILD_DIR="$(getBuildPath rocm-cmake)"
ROCM_CMAKE_BUILD_DIR="$(getBuildPath rocm-cmake)"
ROCM_CMAKE_PACKAGE_DEB="$(getPackageRoot)/deb/rocm-cmake"
ROCM_CMAKE_PACKAGE_RPM="$(getPackageRoot)/rpm/rocm-cmake"
ROCM_CMAKE_BUILD_TYPE="debug"
BUILD_TYPE="Debug"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
PKGTYPE="deb"
MAKETARGET="deb"
VALID_STR=`getopt -o hcraso:p: --long help,clean,release,static,address_sanitizer,outdir:,package: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="Release" ; shift ;;
(-a | --address_sanitizer)
ack_and_ignore_asan ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-p | --package)
MAKETARGET="$2" ; shift 2;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_rocm_cmake() {
rm -rf $ROCM_CMAKE_BUILD_DIR
rm -rf $ROCM_CMAKE_PACKAGE_DEB
rm -rf $ROCM_CMAKE_PACKAGE_RPM
}
build_rocm_cmake() {
echo "Building ROCm cmake"
if [ ! -d "$ROCM_CMAKE_BUILD_DIR" ]; then
mkdir -p "$ROCM_CMAKE_BUILD_DIR"
pushd "$ROCM_CMAKE_BUILD_DIR"
cmake \
$(rocm_cmake_params) \
-DCPACK_SET_DESTDIR="OFF" \
-DROCM_DISABLE_LDCONFIG=ON \
$ROCM_CMAKE_ROOT
cmake --build . -- install
cmake --build . -- package
popd
fi
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$ROCM_CMAKE_PACKAGE_DEB" $ROCM_CMAKE_BUILD_DIR/rocm-cmake*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$ROCM_CMAKE_PACKAGE_RPM" $ROCM_CMAKE_BUILD_DIR/rocm-cmake*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${ROCM_CMAKE_PACKAGE_DEB};;
("rpm")
echo ${ROCM_CMAKE_PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
case $TARGET in
(clean) clean_rocm_cmake ;;
(build) build_rocm_cmake ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

131
rocm-build/build_rocm-core.sh Executable file
View File

@@ -0,0 +1,131 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -p, --package <type> Specify packaging format"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo " -s, --static Supports static CI by accepting this param & not bailing out. No effect of the param though"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
PACKAGE_ROOT="$(getPackageRoot)"
ROCM_CORE_BUILD_DIR="$(getBuildPath rocm_core)"
ROCM_CORE_PACKAGE_DEB="$(getPackageRoot)/deb/rocm-core"
ROCM_CORE_PACKAGE_RPM="$(getPackageRoot)/rpm/rocm-core"
ROCM_CORE_MAKE_OPTS="$DASH_JAY -C $ROCM_CORE_BUILD_DIR"
BUILD_TYPE="Debug"
TARGET="build"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
ADDRESS_SANITIZER=false
VALID_STR=`getopt -o hcraso:p: --long help,clean,release,static,address_sanitizer,outdir:,package: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="Release" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on
ADDRESS_SANITIZER=true ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-p | --package )
MAKETARGET=$2 ; shift 2 ;;
--) shift; break;; # end delimiter
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_rocm_core() {
rm -rf "$ROCM_CORE_BUILD_DIR"
rm -rf "$ROCM_CORE_PACKAGE_DEB"
rm -rf "$ROCM_CORE_PACKAGE_RPM"
}
build_rocm_core() {
echo "Building rocm-core "
if [ ! -d "$ROCM_CORE_BUILD_DIR" ]; then
mkdir -p "$ROCM_CORE_BUILD_DIR"
fi
pushd "$ROCM_CORE_BUILD_DIR"
cmake \
-DCMAKE_VERBOSE_MAKEFILE=1 \
$(rocm_common_cmake_params) \
-DCMAKE_INSTALL_PREFIX="$ROCM_INSTALL_PATH" \
-DCPACK_PACKAGING_INSTALL_PREFIX="$ROCM_INSTALL_PATH" \
-DCPACK_GENERATOR="${CPACKGEN:-"DEB;RPM"}" \
-DCPACK_DEBIAN_PACKAGE_RELEASE=$CPACK_DEBIAN_PACKAGE_RELEASE \
-DCPACK_RPM_PACKAGE_RELEASE=$CPACK_RPM_PACKAGE_RELEASE \
-DROCM_VERSION="$ROCM_VERSION" \
-DBUILD_ID="$BUILD_ID" \
$ROCM_CORE_ROOT
make && make install && make package
popd
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$ROCM_CORE_PACKAGE_DEB" $ROCM_CORE_BUILD_DIR/rocm*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$ROCM_CORE_PACKAGE_RPM" $ROCM_CORE_BUILD_DIR/rocm*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${ROCM_CORE_PACKAGE_DEB};;
("rpm")
echo ${ROCM_CORE_PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
verifyEnvSetup
case $TARGET in
(clean) clean_rocm_core ;;
(build) build_rocm_core ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

14
rocm-build/build_rocm-dev.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
stage2_command_args "$@"
case $TARGET in
build) echo "end of rocm-dev build..." ;;
outdir) ;;
clean) echo "Cleaning rocm-dev is not required..." ;;
*) die "Invalid target $TARGET" ;;
esac

437
rocm-build/build_rocm-gdb.sh Executable file
View File

@@ -0,0 +1,437 @@
#!/bin/bash
source "${BASH_SOURCE%/*}/compute_utils.sh" || return
remove_make_r_flags
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -p, --package <type> Specify packaging format"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo " -s, --static Supports static CI by accepting this param & not bailing out. No effect of the param though"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
toStdoutStderr(){
printf '%s\n' "$@" >&2
printf '%s\n' "$@"
}
linkFiles(){
cp -lfR "$1" "$2" || cp -fR "$1" "$2"
}
PROJ_NAME=rocm-gdb
TARGET=build
MAKETARGET=deb
BUILD_DIR=$(getBuildPath $PROJ_NAME)
PACKAGE_DEB=$(getPackageRoot)/deb/$PROJ_NAME
PACKAGE_RPM=$(getPackageRoot)/rpm/$PROJ_NAME
MAKE_OPTS="$DASH_JAY"
BUG_URL="https://github.com/ROCm-Developer-Tools/ROCgdb/issues"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
LDFLAGS="$LDFLAGS -Wl,--enable-new-dtags"
tokeep=(
main${ROCM_INSTALL_PATH}/bin/rocgdb
main${ROCM_INSTALL_PATH}/bin/roccoremerge
main${ROCM_INSTALL_PATH}/share/rocgdb/python/gdb/.*
main${ROCM_INSTALL_PATH}/share/rocgdb/syscalls/amd64-linux.xml
main${ROCM_INSTALL_PATH}/share/rocgdb/syscalls/gdb-syscalls.dtd
main${ROCM_INSTALL_PATH}/share/rocgdb/syscalls/i386-linux.xml
main${ROCM_INSTALL_PATH}/share/doc/rocgdb/NOTICES.txt
main${ROCM_INSTALL_PATH}/share/doc/rocgdb/rocannotate.pdf
main${ROCM_INSTALL_PATH}/share/doc/rocgdb/rocgdb.pdf
main${ROCM_INSTALL_PATH}/share/doc/rocgdb/rocrefcard.pdf
main${ROCM_INSTALL_PATH}/share/doc/rocgdb/rocstabs.pdf
main${ROCM_INSTALL_PATH}/share/info/rocgdb/dir
main${ROCM_INSTALL_PATH}/share/info/rocgdb/annotate.info
main${ROCM_INSTALL_PATH}/share/info/rocgdb/gdb.info
main${ROCM_INSTALL_PATH}/share/info/rocgdb/stabs.info
main${ROCM_INSTALL_PATH}/share/man/man1/rocgdb.1
main${ROCM_INSTALL_PATH}/share/man/man1/roccoremerge.1
main${ROCM_INSTALL_PATH}/share/man/man5/rocgdbinit.5
main${ROCM_INSTALL_PATH}/share/html/rocannotate/.*
main${ROCM_INSTALL_PATH}/share/html/rocgdb/.*
main${ROCM_INSTALL_PATH}/share/html/rocstabs/.*
)
keep_wanted_files(){
(
cd "$BUILD_DIR/package/"
printf -v keeppattern '%s\n' "${tokeep[@]}"
find main/opt -type f | grep -xv "$keeppattern" | xargs -r rm
find main/opt -type d -empty -delete
)
return 0
}
copy_testsuite_files() {
(
dest="$BUILD_DIR/package/tests${ROCM_INSTALL_PATH}/test/gdb/"
cd "$ROCM_GDB_ROOT"
find \
config.guess \
config.sub \
contrib/dg-extract-results.py \
contrib/dg-extract-results.sh \
gdb/contrib \
gdb/disable-implicit-rules.mk \
gdb/features \
gdb/silent-rules.mk \
gdb/testsuite \
include/dwarf2.def \
include/dwarf2.h \
install-sh \
-print0 | cpio -pdu0 "$dest"
)
}
clean() {
echo "Cleaning $PROJ_NAME"
rm -rf $BUILD_DIR
rm -rf $PACKAGE_DEB
rm -rf $PACKAGE_RPM
}
get_version(){
VERSION=$(sed -n 's/^.*char version[^"]*"\([^"]*\)".*;.*/\1/p' $BUILD_DIR/gdb/version.c || : )
VERSION=${VERSION:-$1}
}
package_deb(){
mkdir -p "$BUILD_DIR/package/main/DEBIAN"
local VERSION
get_version unknown
VERSION="${VERSION}.${ROCM_LIBPATCH_VERSION}"
grep -v '^# ' > "$BUILD_DIR/package/main/DEBIAN/control" <<EOF
# Required fields
Version: ${VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}
Package: ${PROJ_NAME}
Maintainer: ROCm Debugger Support <rocm-gdb.support@amd.com>
Description: ROCgdb
This is ROCgdb, the AMD ROCm source-level debugger for Linux,
based on GDB, the GNU source-level debugger.
# Optional fields
Section: utils
Architecture: amd64
Essential: no
Priority: optional
Depends: libexpat1, libtinfo5, libncurses5, rocm-dbgapi, libpython3.10 | libpython3.8, libbabeltrace-ctf1 (>= 1.2.1), libbabeltrace1 (>= 1.2.1), rocm-core
EOF
mkdir -p "$OUT_DIR/deb/$PROJ_NAME"
fakeroot dpkg-deb -Zgzip --build "$BUILD_DIR/package/main" "$OUT_DIR/deb/$PROJ_NAME"
mkdir -p "$BUILD_DIR/package/tests/DEBIAN"
mkdir -p "$BUILD_DIR/package/tests/${ROCM_INSTALL_PATH}/test/gdb"
grep -v '^# ' > "$BUILD_DIR/package/tests/DEBIAN/control" <<EOF
# Required fields
Version: ${VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}
Package: ${PROJ_NAME}-tests
Maintainer: ROCm Debugger Support <rocm-gdb.support@amd.com>
Description: ROCgdb tests
Test Suite for ROCgdb
# Optional fields
Section: utils
Architecture: amd64
Essential: no
Priority: optional
# rocm-core as policy says everything to depend on rocm-core
Depends: ${PROJ_NAME} (=${VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), dejagnu, rocm-core, make
EOF
copy_testsuite_files
fakeroot dpkg-deb -Zgzip --build "$BUILD_DIR/package/tests" "$OUT_DIR/deb/$PROJ_NAME"
}
package_rpm(){
set -- rocm-gdb
local packageDir="$BUILD_DIR/package_rpm/$1"
local specFile="$packageDir/$1.spec"
local packageRpm="$packageDir/rpm"
local VERSION
get_version 0.0.0
VERSION=${VERSION}.${ROCM_LIBPATCH_VERSION}
local ospost="$(echo '%define __os_install_post \'
rpm --showrc | sed '1,/^-14: __os_install_post/d;
/^-14:/,$d;/^%{nil}/!s/$/ \\/;
/brp-python-bytecompile/d')"
echo "specFile: $specFile"
echo "packageRpm: $packageRpm"
mkdir -p "$packageDir"
grep -v '^## ' <<- EOF > $specFile
## Set up where this stuff goes
%define _topdir $packageRpm
%define _rpmfilename %%{ARCH}/%%{NAME}-${VERSION}-${CPACK_RPM_PACKAGE_RELEASE}%{?dist}.%%{ARCH}.rpm
## The __os_install_post macro on centos creates .pyc and .pyo objects
## by calling brp-python-bytecompile
## This then creates an issue as the script doesn't package these files
## override it
$ospost
##
Name: ${PROJ_NAME}
Group: Development/Tools/Debuggers
Summary: ROCm source-level debugger for Linux
## rpm requires the version to be dot separated numbers
Version: ${VERSION//-/_}
Release: ${CPACK_RPM_PACKAGE_RELEASE}%{?dist}
License: GPL
Requires: rocm-core
%description
This is ROCgdb, the ROCm source-level debugger for Linux, based on
GDB, the GNU source-level debugger.
The ROCgdb documentation is available at:
https://github.com/RadeonOpenCompute/ROCm
## these things are commented out as they are not needed, but are
## left in for documentation.
# %prep
# : Should not need to do anything in prep
# %build
# : Should not need to do anything in build as make does that
# %clean
# : Should not need to do anything in clean
## This is the meat. Get a copy of the files from where we built them
## into the local RPM_BUILD_ROOT and left the defaults take over. Need
## to quote the dollar signs as we want rpm to expand them when it is
## run, rather than the shell when we build the spec file.
%install
rm -rf \$RPM_BUILD_ROOT
mkdir -p \$RPM_BUILD_ROOT
# Get a copy of the built tree.
cp -ar $BUILD_DIR/package/main/opt \$RPM_BUILD_ROOT/opt
## The file section is generated by walking the tree.
%files
EOF
find $BUILD_DIR/package/main/opt -type d | sed "s:$BUILD_DIR/package/main:%dir :" >> $specFile
find $BUILD_DIR/package/main/opt ! -type d | sed "s:$BUILD_DIR/package/main::" >> $specFile
rpmbuild --define "_topdir $packageRpm" -ba $specFile
mkdir -p "$PACKAGE_RPM" # e.g. out/ubuntu-16.04/16.04/rpm/rocm-gdb
mv $packageRpm/RPMS/x86_64/*.rpm "$PACKAGE_RPM"
}
package_rpm_tests(){
set -- rocm-gdb-tests
local packageDir="$BUILD_DIR/package_rpm/$1"
local specFile="$packageDir/$1.spec"
local packageRpm="$packageDir/rpm"
local VERSION
get_version 0.0.0
VERSION=${VERSION}.${ROCM_LIBPATCH_VERSION}
local RELEASE=${CPACK_RPM_PACKAGE_RELEASE}%{?dist}
echo "specFile: $specFile"
echo "packageRpm: $packageRpm"
mkdir -p "$packageRpm"
local ospost="$(echo '%define __os_install_post \'
rpm --showrc | sed '1,/^-14: __os_install_post/d;
/^-14:/,$d;/^%{nil}/!s/$/ \\/;
/brp-python-bytecompile/d')"
grep -v '^## ' <<- EOF > $specFile
## Set up where this stuff goes
%define _topdir $packageRpm
%define _rpmfilename %%{ARCH}/%%{NAME}-${VERSION}-${RELEASE}.%%{ARCH}.rpm
## The __os_install_post macro on centos creates .pyc and .pyo objects
## by calling brp-python-bytecompile
## This then creates an issue as the script doesn't package these files
## override it
$ospost
##
Name: ${PROJ_NAME}-tests
Group: Development/Tools/Debuggers
Summary: Tests for gdb enhanced to debug AMD GPUs
Version: ${VERSION//-/_}
Release: ${RELEASE}
License: GPL
Requires: dejagnu, ${PROJ_NAME} = ${VERSION//-/_}-${RELEASE}, rocm-core, make
%description
Tests for ROCgdb
## these things are commented out as they are not needed, but are
## left in for documentation.
# %prep
# : Should not need to do anything in prep
# %build
# : Should not need to do anything in build as make does that
# %clean
# : Should not need to do anything in clean
## This is the meat. Get a copy of the files from where we built them
## into the local RPM_BUILD_ROOT and left the defaults take over. Need
## to quote the dollar signs as we want rpm to expand them when it is
## run, rather than the shell when we build the spec file.
%install
rm -rf \$RPM_BUILD_ROOT
mkdir -p \$RPM_BUILD_ROOT
# Get a copy of the built tree.
cp -ar $BUILD_DIR/package/tests/opt \$RPM_BUILD_ROOT/opt
## The file section is generated by walking the tree.
%files
## package everything in \$RPM_BUILD_ROOT/${ROCM_INSTALL_PATH}/test.
## A little excessive but this is just an internal test package
${ROCM_INSTALL_PATH}/test
EOF
copy_testsuite_files
find $BUILD_DIR/package/tests/opt -type f -exec sed -i '1s:^#! */usr/bin/python\>:&3:' {} +
rpmbuild --define "_topdir $packageRpm" -ba $specFile
mkdir -p "$PACKAGE_RPM"
mv $packageRpm/RPMS/x86_64/*.rpm "$PACKAGE_RPM"
}
build() {
if [ ! -e "$ROCM_GDB_ROOT/configure" ]
then
toStdoutStderr "No $ROCM_GDB_ROOT/configure file, skippping rocm-gdb"
exit 0
fi
local pythonver=python3
if [[ "$DISTRO_ID" == "ubuntu-18.04" ]]; then
pythonver=python3.8
fi
if [[ "$DISTRO_ID" == "centos-9" ]] || [[ "$DISTRO_ID" == "rhel-9.0" ]]; then
fmtutil-user --missing
fi
echo "Building $PROJ_NAME"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR" || die "Failed to cd to '$BUILD_DIR'"
$ROCM_GDB_ROOT/configure --program-prefix=roc --prefix="${ROCM_INSTALL_PATH}" \
--htmldir="\${prefix}/share/html" --pdfdir="\${prefix}/share/doc/rocgdb" \
--infodir="\${prefix}/share/info/rocgdb" \
--with-separate-debug-dir="\${prefix}/lib/debug:/usr/lib/debug" \
--with-gdb-datadir="\${prefix}/share/rocgdb" --enable-64-bit-bfd \
--with-bugurl="$BUG_URL" --with-pkgversion="${ROCM_BUILD_ID:-ROCm}" \
--enable-targets="x86_64-linux-gnu,amdgcn-amd-amdhsa" \
--disable-ld --disable-gas --disable-gdbserver --disable-sim --enable-tui \
--disable-gdbtk --disable-shared --disable-gprofng \
--with-expat --with-system-zlib --without-guile --with-babeltrace --with-lzma \
--with-python=$pythonver --with-rocm-dbgapi=$ROCM_INSTALL_PATH \
--with-amd-dbgapi PKG_CONFIG_PATH="${ROCM_INSTALL_PATH}/share/pkgconfig" \
LDFLAGS="$LDFLAGS"
LD_RUN_PATH='${ORIGIN}/../lib' make $MAKE_OPTS
mkdir -p $BUILD_DIR/package/main${ROCM_INSTALL_PATH}/{share/rocgdb,bin}
make $MAKE_OPTS -C gdb DESTDIR=$BUILD_DIR/package/main install install-pdf install-html
make $MAKE_OPTS -C binutils DESTDIR=$BUILD_DIR/package/main install
linkFiles $ROCM_GDB_ROOT/gdb/NOTICES.txt $BUILD_DIR/package/main${ROCM_INSTALL_PATH}/share/doc/rocgdb
keep_wanted_files
[ "${CPACKGEN}" = "DEB" ] || package_rpm && package_rpm_tests
[ "${CPACKGEN}" = "RPM" ] || package_deb
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${PACKAGE_DEB};;
("rpm")
echo ${PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
verifyEnvSetup
main(){
VALID_STR=`getopt -o hcraso:p: --long help,clean,release,static,address_sanitizer,outdir:,package: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="Release" ; shift ; MAKEARG="$MAKEARG REL=1" ;; # For compatability with other scripts
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-p | --package) #FIXME
MAKETARGET="$2" ; shift 2;;
# I think it would be better to use -- to indicate end of args
# and insert an error message about unknown args at this point.
--) shift; break;; # end delimiter
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
if [[ $CXX == *"clang++" ]]
then
CXX="$CXX -std=gnu++17"
fi
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
case $TARGET in
("clean") clean ;;
("build") build ;;
("outdir") print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"
}
if [ "$0" = "$BASH_SOURCE" ]
then
main "$@"
else
set +e
fi

View File

@@ -0,0 +1,155 @@
#!/bin/bash -x
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -s, --static Supports static CI by accepting this param & not bailing out. No effect of the param though"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -p, --package <type> Specify packaging format"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
TEST_BIN_DIR="$(getBinPath)"
TEST_NAME="rocm-bandwidth-test"
TEST_UTILS_DIR="$(getUtilsPath)"
TEST_SRC_DIR="rocm_bandwidth_test"
TEST_BLD_DIR="$(getBuildPath $TEST_SRC_DIR)"
ROCM_PKG_PREFIX="$ROCM_INSTALL_PATH"
TEST_PKG_ROOT="$(getPackageRoot)"
TEST_PKG_DEB="$(getPackageRoot)/deb/$TEST_SRC_DIR"
TEST_PKG_RPM="$(getPackageRoot)/rpm/$TEST_SRC_DIR"
ROCR_LIB_DIR="$(getPackageRoot)/lib"
ROCR_INC_DIR="$(getPackageRoot)/hsa/include"
RUN_SCRIPT=$(echo $(basename "${BASH_SOURCE}") | sed "s/build_/run_/")
TARGET="build"
MAKETARGET="all"
BUILD_TYPE="Debug"
MAKEARG="$DASH_JAY"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
PKGTYPE="deb"
VALID_STR=`getopt -o hcraso:p: --long help,clean,release,static,address_sanitizer,outdir:,package: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="Release" ; MAKEARG="$MAKEARG REL=1" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-p | --package)
MAKETARGET="$2" ; CPACKGEN="${2^^}" ; shift 2;;
--) shift; break;; # end delimiter
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_rocm_bandwidth_test() {
echo "Cleaning $TEST_NAME"
rm -rf $TEST_BLD_DIR
rm -rf $TEST_PKG_DEB
rm -rf $TEST_PKG_RPM
rm -rf $TEST_BIN_DIR/$TEST_NAME
rm -f $TEST_UTILS_DIR/$RUN_SCRIPT
}
build_rocm_bandwidth_test() {
echo "Building $TEST_NAME"
if [ ! -d "$TEST_BLD_DIR" ]; then
mkdir -p "$TEST_BLD_DIR"
pushd "$TEST_BLD_DIR"
cmake \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DCMAKE_VERBOSE_MAKEFILE=1 \
-DCMAKE_INSTALL_PREFIX="$TEST_PKG_ROOT" \
-DCPACK_PACKAGING_INSTALL_PREFIX="$ROCM_INSTALL_PATH" \
-DCMAKE_PREFIX_PATH="$ROCM_INSTALL_PATH" \
$(rocm_common_cmake_params) \
-DCPACK_GENERATOR="${CPACKGEN:-"DEB;RPM"}" \
-DROCM_PATCH_VERSION=$ROCM_LIBPATCH_VERSION \
-DCMAKE_MODULE_PATH="$ROCM_BANDWIDTH_TEST_ROOT/cmake_modules" \
-DADDRESS_SANITIZER="$ADDRESS_SANITIZER" \
"$ROCM_BANDWIDTH_TEST_ROOT"
popd
fi
echo "Building $TEST_NAME"
cmake --build "$TEST_BLD_DIR" -- $MAKEARG -C $TEST_BLD_DIR
echo "Installing $TEST_NAME"
cmake --build "$TEST_BLD_DIR" -- $MAKEARG -C $TEST_BLD_DIR install
echo "Packaging $TEST_NAME"
cmake --build "$TEST_BLD_DIR" -- $MAKEARG -C $TEST_BLD_DIR package
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$TEST_PKG_DEB" $TEST_BLD_DIR/*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$TEST_PKG_RPM" $TEST_BLD_DIR/*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${TEST_PKG_DEB};;
("rpm")
echo ${TEST_PKG_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
verifyEnvSetup
case $TARGET in
(clean) clean_rocm_bandwidth_test ;;
(build) build_rocm_bandwidth_test ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

153
rocm-build/build_rocm_smi_lib.sh Executable file
View File

@@ -0,0 +1,153 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [-c|-r|-32|-h] [makeopts]"
echo
echo "Options:"
echo " -c, --clean Removes all rocm_smi build artifacts"
echo " -r, --release Build non-debug version rocm_smi (default is debug)"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -s, --static Build static lib (.a). build instead of dynamic/shared(.so) "
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of type referred to by pkg_type"
echo " -p, --package <type> Specify packaging format"
echo " -32, Build 32b version (default is 64b)"
echo " -h, --help Prints this help"
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
PACKAGE_ROOT="$(getPackageRoot)"
TARGET="build"
PACKAGE_LIB=$(getLibPath)
PACKAGE_INCLUDE="$(getIncludePath)"
RSMI_BUILD_DIR=$(getBuildPath rsmi)
RSMI_PACKAGE_DEB_DIR="$(getPackageRoot)/deb/rsmi"
RSMI_PACKAGE_RPM_DIR="$(getPackageRoot)/rpm/rsmi"
RSMI_BUILD_TYPE="debug"
BUILD_TYPE="Debug"
MAKETARGET="deb"
MAKEARG="$DASH_JAY O=$RSMI_BUILD_DIR"
RSMI_MAKE_OPTS="$DASH_JAY O=$RSMI_BUILD_DIR -C $RSMI_BUILD_DIR"
ROCM_SMI_BLD_BITS=64
RSMI_PKG_NAME_ROOT="rocm-smi-lib"
RSMI_PKG_NAME="${RSMI_PKG_NAME_ROOT}${ROCM_SMI_BLD_BITS}"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
PKGTYPE="deb"
VALID_STR=`getopt -o hcraso:p: --long help,clean,release,static,address_sanitizer,outdir:,package: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="RelWithDebInfo" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on
# TODO - support standard option of passing cmake environment vars - CFLAGS,CXXFLAGS etc., to enable address sanitizer
ADDRESS_SANITIZER=true ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-p | --package)
MAKETARGET="$2" ; shift 2;;
(-32)
ROCM_SMI_BLD_BITS="32"; shift ;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_rsmi() {
rm -rf "$RSMI_BUILD_DIR"
rm -rf "$RSMI_PACKAGE_DEB_DIR"
rm -rf "$RSMI_PACKAGE_RPM_DIR"
rm -rf "$PACKAGE_ROOT/rocm_smi"
rm -rf "$PACKAGE_INCLUDE/rocm_smi"
rm -f $PACKAGE_LIB/librocm_smi${ROCM_SMI_BLD_BITS}.*
rm -f $PACKAGE_LIB/librocm_smi${ROCM_SMI_BLD_BITS}.*
return 0
}
build_rsmi() {
echo "Building RSMI"
echo "RSMI_BUILD_DIR: ${RSMI_BUILD_DIR}"
if [ ! -d "$RSMI_BUILD_DIR" ]; then
mkdir -p $RSMI_BUILD_DIR
pushd $RSMI_BUILD_DIR
print_lib_type $SHARED_LIBS
cmake \
-DCMAKE_MODULE_PATH="$ROCM_SMI_LIB_ROOT/cmake_modules" \
-DBUILD_SHARED_LIBS=$SHARED_LIBS \
$(rocm_common_cmake_params) \
$(rocm_cmake_params) \
-DENABLE_LDCONFIG=OFF \
-DROCM_SMI_PACKAGE="${RSMI_PKG_NAME}" \
-DCPACK_PACKAGE_VERSION_MAJOR="1" \
-DCPACK_PACKAGE_VERSION_MINOR="$ROCM_LIBPATCH_VERSION" \
-DCPACK_PACKAGE_VERSION_PATCH="0" \
-DADDRESS_SANITIZER="$ADDRESS_SANITIZER" \
-DBUILD_TESTS=ON \
"$ROCM_SMI_LIB_ROOT"
popd
fi
echo "Making rocm_smi package:"
cmake --build "$RSMI_BUILD_DIR" -- $RSMI_MAKE_OPTS
cmake --build "$RSMI_BUILD_DIR" -- $RSMI_MAKE_OPTS install
cmake --build "$RSMI_BUILD_DIR" -- $RSMI_MAKE_OPTS package
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$RSMI_PACKAGE_DEB_DIR" $RSMI_BUILD_DIR/*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$RSMI_PACKAGE_RPM_DIR" $RSMI_BUILD_DIR/*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${RSMI_PACKAGE_DEB_DIR};;
("rpm")
echo ${RSMI_PACKAGE_RPM_DIR};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
verifyEnvSetup
case $TARGET in
(clean) clean_rsmi ;;
(build) build_rsmi ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"
exit 0

133
rocm-build/build_rocminfo.sh Executable file
View File

@@ -0,0 +1,133 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [-c|-r|-h] [makeopts]"
echo
echo "Options:"
echo " -c, --clean Removes all rocminfo build artifacts"
echo " -r, --release Build non-debug version rocminfo (default is debug)"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -s, --static Supports static CI by accepting this param & not bailing out. No effect of the param though"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo "Possible values for <pkg_type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
TARGET="build"
ROCMINFO_DEST="$(getBinPath)"
ROCMINFO_SRC_ROOT="$ROCMINFO_ROOT"
ROCMINFO_BUILD_DIR="$(getBuildPath rocminfo)"
MAKEARG="$DASH_JAY"
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_UTILS="$(getUtilsPath)"
ROCMINFO_PACKAGE_DEB="$(getPackageRoot)/deb/rocminfo"
ROCMINFO_PACKAGE_RPM="$(getPackageRoot)/rpm/rocminfo"
BUILD_TYPE="debug"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
VALID_STR=`getopt -o hcraso:g: --long help,clean,release,static,address_sanitizer,outdir:,gpu_list: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
MAKEARG="$MAKEARG BUILD_TYPE=rel"; BUILD_TYPE="RelWithDebInfo" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-g | --gpu_list)
GPU_LIST="$2" ; shift 2;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean_rocminfo() {
echo "Removing rocminfo"
rm -rf $ROCMINFO_DEST/rocminfo
rm -rf $ROCMINFO_BUILD_DIR
rm -rf $ROCMINFO_PACKAGE_DEB
rm -rf $ROCMINFO_PACKAGE_RPM
}
build_rocminfo() {
if [ ! -d "$ROCMINFO_BUILD_DIR" ]; then
mkdir -p $ROCMINFO_BUILD_DIR
pushd $ROCMINFO_BUILD_DIR
cmake \
$(rocm_cmake_params) \
-DROCRTST_BLD_TYPE="$BUILD_TYPE" \
$(rocm_common_cmake_params) \
-DCPACK_PACKAGE_VERSION_MAJOR="1" \
-DCPACK_PACKAGE_VERSION_MINOR="$ROCM_LIBPATCH_VERSION" \
-DCPACK_PACKAGE_VERSION_PATCH="0" \
-DCMAKE_SKIP_BUILD_RPATH=TRUE\
$ROCMINFO_SRC_ROOT
echo "Making rocminfo:"
cmake --build . -- $MAKEARG
cmake --build . -- $MAKEARG install
cmake --build . -- $MAKEARG package
popd
fi
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$ROCMINFO_PACKAGE_DEB" $ROCMINFO_BUILD_DIR/*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$ROCMINFO_PACKAGE_RPM" $ROCMINFO_BUILD_DIR/*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${ROCMINFO_PACKAGE_DEB};;
("rpm")
echo ${ROCMINFO_PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
case $TARGET in
(clean) clean_rocminfo ;;
(build) build_rocminfo ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"
exit 0

View File

@@ -0,0 +1,51 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src ROCmValidationSuite
ROCM_RVS_LIB_RPATH="\$ORIGIN/.."
build_rocmvalidationsuite() {
echo "Start build"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
cd "${COMPONENT_SRC}"
mkdir -p "$BUILD_DIR"
cmake \
$(rocm_common_cmake_params) \
-DFETCH_ROCMPATH_FROM_ROCMCORE=ON \
-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,--enable-new-dtags,--rpath,$ROCM_LIB_RPATH:$ROCM_RVS_LIB_RPATH" \
-B "$BUILD_DIR" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p "${PACKAGE_DIR}" && cp "${BUILD_DIR}"/*."${PKGTYPE}" "${PACKAGE_DIR}"
show_build_cache_stats
}
clean_rocmvalidationsuite() {
echo "Cleaning ROCmValidationSuite build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "${BUILD_DIR}" "${PACKAGE_DIR}"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_rocmvalidationsuite ;;
outdir) print_output_directory ;;
clean) clean_rocmvalidationsuite ;;
*) die "Invalid target ${TARGET}" ;;
esac

61
rocm-build/build_rocprim.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src rocPRIM
build_rocprim() {
echo "Start build"
cd $COMPONENT_SRC
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
ASAN_CMAKE_PARAMS="false"
fi
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
CXX="${ROCM_PATH}/bin/hipcc" \
cmake \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DBUILD_BENCHMARK=OFF \
-DBUILD_BENCHMARK=OFF \
-DBUILD_TEST=ON \
-DCMAKE_MODULE_PATH="${ROCM_PATH}/lib/cmake/hip;${ROCM_PATH}/hip/cmake" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rocprim() {
echo "Cleaning rocPRIM build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_rocprim ;;
outdir) print_output_directory ;;
clean) clean_rocprim ;;
*) die "Invalid target $TARGET" ;;
esac

View File

@@ -0,0 +1,139 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: ${BASH_SOURCE##*/} [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -s, --static Build static lib (.a). build instead of dynamic/shared(.so) "
echo " -p, --package <type> Specify packaging format"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
API_NAME="rocprofiler-register"
PROJ_NAME="$API_NAME"
LIB_NAME="lib${API_NAME}"
TARGET="build"
MAKETARGET="deb"
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_LIB="$(getLibPath)"
PACKAGE_INCLUDE="$(getIncludePath)"
BUILD_DIR="$(getBuildPath $API_NAME)"
PACKAGE_DEB="$(getPackageRoot)/deb/$API_NAME"
PACKAGE_RPM="$(getPackageRoot)/rpm/$API_NAME"
PACKAGE_PREFIX="$ROCM_INSTALL_PATH"
BUILD_TYPE="Debug"
MAKE_OPTS="$DASH_JAY -C $BUILD_DIR"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
VALID_STR=`getopt -o hcraso:p: --long help,clean,release,static,address_sanitizer,outdir:,package: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="Release" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-p | --package)
MAKETARGET="$2" ; shift 2;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean() {
echo "Cleaning $PROJ_NAME"
rm -rf "$BUILD_DIR"
rm -rf "$PACKAGE_DEB"
rm -rf "$PACKAGE_RPM"
rm -rf "$PACKAGE_ROOT/${PROJ_NAME}"
rm -rf "$PACKAGE_LIB/${LIB_NAME}"*
}
build() {
echo "Building $PROJ_NAME"
if [ ! -d "$BUILD_DIR" ]; then
mkdir -p "$BUILD_DIR"
pushd "$BUILD_DIR"
print_lib_type $SHARED_LIBS
cmake \
$(rocm_cmake_params) \
$(rocm_common_cmake_params) \
-DBUILD_SHARED_LIBS=$SHARED_LIBS \
-DENABLE_LDCONFIG=OFF \
-DROCPROFILER_REGISTER_BUILD_CI=1 \
-DROCPROFILER_REGISTER_BUILD_TESTS=1 \
-DROCPROFILER_REGISTER_BUILD_SAMPLES=1 \
"$ROCPROFILER_REGISTER_ROOT"
popd
fi
make $MAKE_OPTS
make $MAKE_OPTS install
make $MAKE_OPTS package
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_DEB" "$BUILD_DIR/${API_NAME}"*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_RPM" "$BUILD_DIR/${API_NAME}"*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${PACKAGE_DEB};;
("rpm")
echo ${PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
verifyEnvSetup
case "$TARGET" in
(clean) clean ;;
(build) build ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

179
rocm-build/build_rocprofiler.sh Executable file
View File

@@ -0,0 +1,179 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: ${BASH_SOURCE##*/} [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -s, --static Build static lib (.a). build instead of dynamic/shared(.so) "
echo " -p, --package <type> Specify packaging format"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
API_NAME="rocprofiler"
PROJ_NAME="$API_NAME"
LIB_NAME="lib${API_NAME}"
TARGET="build"
MAKETARGET="deb"
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_LIB="$(getLibPath)"
PACKAGE_INCLUDE="$(getIncludePath)"
BUILD_DIR="$(getBuildPath $API_NAME)"
PACKAGE_DEB="$(getPackageRoot)/deb/$API_NAME"
PACKAGE_RPM="$(getPackageRoot)/rpm/$API_NAME"
PACKAGE_PREFIX="$ROCM_INSTALL_PATH"
BUILD_TYPE="Debug"
MAKE_OPTS="$DASH_JAY -C $BUILD_DIR"
SHARED_LIBS="ON"
CLEAN_OR_OUT=0
MAKETARGET="deb"
PKGTYPE="deb"
GPU_LIST="gfx900,gfx906,gfx908,gfx90a,gfx940,gfx941,gfx942,gfx1030,gfx1100,gfx1101,gfx1102"
VALID_STR=$(getopt -o hcraso:p: --long help,clean,release,static,address_sanitizer,outdir:,package: -- "$@")
eval set -- "$VALID_STR"
while true; do
case "$1" in
-h | --help)
printUsage
exit 0
;;
-c | --clean)
TARGET="clean"
((CLEAN_OR_OUT |= 1))
shift
;;
-r | --release)
BUILD_TYPE="RelWithDebInfo"
shift
;;
-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on
shift
;;
-s | --static)
SHARED_LIBS="OFF"
shift
;;
-o | --outdir)
TARGET="outdir"
PKGTYPE=$2
OUT_DIR_SPECIFIED=1
((CLEAN_OR_OUT |= 2))
shift 2
;;
-p | --package)
MAKETARGET="$2"
shift 2
;;
--)
shift
break
;;
*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] " >&2
exit 20
;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean() {
echo "Cleaning $PROJ_NAME"
rm -rf "$BUILD_DIR"
rm -rf "$PACKAGE_DEB"
rm -rf "$PACKAGE_RPM"
rm -rf "$PACKAGE_ROOT/${PROJ_NAME}"
rm -rf "$PACKAGE_ROOT/libexec/${PROJ_NAME}"
rm -rf "$PACKAGE_INCLUDE/${PROJ_NAME}"
rm -rf "$PACKAGE_LIB/${LIB_NAME}"*
rm -rf "$PACKAGE_LIB/${PROJ_NAME}"
}
build_rocprofiler() {
echo "Building $PROJ_NAME"
sed -i 's/set(CPACK_GENERATOR "DEB" "RPM" "TGZ")/set(CPACK_GENERATOR "DEB" "TGZ")/' "${ROCPROFILER_ROOT}/CMakeLists.txt"
PACKAGE_CMAKE="$(getCmakePath)"
if [ ! -d "$BUILD_DIR" ]; then
mkdir -p "$BUILD_DIR"
pushd "$BUILD_DIR"
print_lib_type $SHARED_LIBS
cmake \
$(rocm_cmake_params) \
-DCMAKE_MODULE_PATH="$ROCPROFILER_ROOT/cmake_modules;$PACKAGE_CMAKE/hip" \
$(rocm_common_cmake_params) \
-DBUILD_SHARED_LIBS=$SHARED_LIBS \
-DENABLE_LDCONFIG=OFF \
-DUSE_PROF_API=1 \
-DGPU_TARGETS="$GPU_LIST" \
-DPROF_API_HEADER_PATH="$WORK_ROOT/roctracer/inc/ext" \
-DHIP_HIPCC_FLAGS=$HIP_HIPCC_FLAGS";--offload-arch=$GPU_LIST" \
-DCPACK_OBJCOPY_EXECUTABLE="${ROCM_INSTALL_PATH}/llvm/bin/llvm-objcopy" \
-DCPACK_READELF_EXECUTABLE="${ROCM_INSTALL_PATH}/llvm/bin/llvm-readelf" \
-DCPACK_STRIP_EXECUTABLE="${ROCM_INSTALL_PATH}/llvm/bin/llvm-strip" \
-DCPACK_OBJDUMP_EXECUTABLE="${ROCM_INSTALL_PATH}/llvm/bin/llvm-objdump" \
"$ROCPROFILER_ROOT"
popd
fi
cmake --build "$BUILD_DIR" -- $MAKE_OPTS
cmake --build "$BUILD_DIR" -- $MAKE_OPTS mytest
cmake --build "$BUILD_DIR" -- $MAKE_OPTS install
cmake --build "$BUILD_DIR" -- $MAKE_OPTS package
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_DEB" "$BUILD_DIR/${API_NAME}"*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_RPM" "$BUILD_DIR/${API_NAME}"*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
"deb")
echo ${PACKAGE_DEB}
;;
"rpm")
echo ${PACKAGE_RPM}
;;
*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2
exit 1
;;
esac
exit
}
verifyEnvSetup
case "$TARGET" in
clean) clean ;;
build) build_rocprofiler ;;
outdir) print_output_directory ;;
*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

View File

@@ -0,0 +1,153 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -s, --static Supports static CI by accepting this param & not bailing out. No effect of the param though"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -p, --package <type> Specify packaging format"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
API_NAME=rocm-debug-agent
PROJ_NAME=$API_NAME
LIB_NAME=lib${API_NAME}.so
TARGET=build
MAKETARGET=deb
PACKAGE_ROOT=$(getPackageRoot)
PACKAGE_BIN="$(getBinPath)"
PACKAGE_LIB=$(getLibPath)
PACKAGE_INCLUDE=$(getIncludePath)
BUILD_DIR=$(getBuildPath $API_NAME)
PACKAGE_DEB=$(getPackageRoot)/deb/$API_NAME
PACKAGE_RPM=$(getPackageRoot)/rpm/$API_NAME
PACKAGE_PREFIX=$ROCM_INSTALL_PATH
BUILD_TYPE=Debug
MAKE_OPTS="$DASH_JAY -C"
TEST_PACKAGE_DIR="$(getBinPath)/rocm-debug-agent-test"
PACKAGE_UTILS=$(getUtilsPath)
BC_DIR="$PACKAGE_ROOT/lib/bitcode"
if [ -d "$BC_DIR" ] ; then
export DEVICE_LIB_PATH=$BC_DIR
fi
SHARED_LIBS="ON"
CLEAN_OR_OUT=0;
MAKETARGET="deb"
PKGTYPE="deb"
VALID_STR=`getopt -o hcraso:p: --long help,clean,release,static,address_sanitizer,outdir:,package: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="RelWithDebInfo" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s | --static)
SHARED_LIBS="OFF" ; shift ;;
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-p | --package)
MAKETARGET="$2" ; shift 2;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean() {
echo "Cleaning $PROJ_NAME"
rm -rf $BUILD_DIR
rm -rf $TEST_PACKAGE_DIR
rm -rf $PACKAGE_DEB
rm -rf $PACKAGE_RPM
rm -rf $PACKAGE_ROOT/${PROJ_NAME}
rm -rf $PACKAGE_LIB/${LIB_NAME}*
rm -f $PACKAGE_UTILS/run_rocr_debug_agent_test.sh
}
build() {
echo "Building $PROJ_NAME"
PACKAGE_CMAKE="$(getCmakePath)"
export HIPCC_COMPILE_FLAGS_APPEND="--rocm-path=$ROCM_PATH"
if [ ! -d "$BUILD_DIR" ]; then
mkdir -p "$BUILD_DIR"
pushd "$BUILD_DIR"
cmake $(rocm_cmake_params) \
-DCMAKE_PREFIX_PATH="$PACKAGE_CMAKE/amd-dbgapi" \
-DCMAKE_MODULE_PATH="$PACKAGE_CMAKE/hip" \
$(rocm_common_cmake_params) \
-DCMAKE_HIP_ARCHITECTURES=OFF \
$ROCR_DEBUG_AGENT_ROOT
popd
fi
cmake --build "$BUILD_DIR" -- $MAKE_OPTS $BUILD_DIR
cmake --build "$BUILD_DIR" -- $MAKE_OPTS $BUILD_DIR install
cmake --build "$BUILD_DIR" -- $MAKE_OPTS $BUILD_DIR package
mkdir -p $PACKAGE_LIB
cp -R $BUILD_DIR/${LIB_NAME}* $PACKAGE_LIB
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "${PACKAGE_DEB}" "$BUILD_DIR/${API_NAME}"*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "${PACKAGE_RPM}" "$BUILD_DIR/${API_NAME}"*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${PACKAGE_DEB};;
("rpm")
echo ${PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
verifyEnvSetup
case $TARGET in
(clean) clean ;;
(build) build ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $target" ;;
esac
echo "Operation complete"

66
rocm-build/build_rocrand.sh Executable file
View File

@@ -0,0 +1,66 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src rocRAND
build_rocrand() {
echo "Start build"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
cd $COMPONENT_SRC && mkdir "$BUILD_DIR"
remote_name=$(git remote show | head -n 1)
[ "$remote_name" == "origin" ] || git remote rename "$remote_name" origin
git submodule update --init --force
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
CXX=$(set_build_variables CXX)\
cmake \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DBUILD_TEST=ON \
-DBUILD_BENCHMARK=ON \
-DBUILD_CRUSH_TEST=ON \
-DDEPENDENCIES_FORCE_DOWNLOAD=OFF \
-DHIP_COMPILER=clang \
-DCMAKE_MODULE_PATH="${ROCM_PATH}/lib/cmake/hip" \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
-B "${BUILD_DIR}" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rocrand() {
echo "Cleaning rocRAND build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_rocrand ;;
outdir) print_output_directory ;;
clean) clean_rocrand ;;
*) die "Invalid target $TARGET" ;;
esac

69
rocm-build/build_rocsolver.sh Executable file
View File

@@ -0,0 +1,69 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src rocSOLVER
build_rocsolver() {
echo "Start build"
cd $COMPONENT_SRC
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
rebuild_lapack
fi
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
CXX="${ROCM_PATH}/bin/hipcc" \
cmake \
-DCPACK_SET_DESTDIR=OFF \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-Drocblas_DIR="${ROCM_PATH}/rocblas/lib/cmake/rocblas" \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DBUILD_CLIENTS_TESTS=ON \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
-DBUILD_CLIENTS_BENCHMARKS=ON \
-DBUILD_CLIENTS_SAMPLES=ON \
-DBUILD_TESTING=ON \
-DBUILD_CLIENTS_EXTRA_TESTS=ON \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rocsolver() {
echo "Cleaning rocSOLVER build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_rocsolver ;;
outdir) print_output_directory ;;
clean) clean_rocsolver ;;
*) die "Invalid target $TARGET" ;;
esac

68
rocm-build/build_rocsparse.sh Executable file
View File

@@ -0,0 +1,68 @@
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
PATH=${ROCM_PATH}/bin:$PATH
set_component_src rocSPARSE
build_rocsparse() {
echo "Start build"
cd $COMPONENT_SRC
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
MIRROR="http://compute-artifactory.amd.com/artifactory/list/rocm-generic-local/mathlib/sparse/"
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
ROCSPARSE_TEST_MIRROR=$MIRROR \
CXX=$(set_build_variables CXX)\
CC=$(set_build_variables CC)\
cmake \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DBUILD_CLIENTS_SAMPLES=ON \
-DBUILD_CLIENTS_TESTS=ON \
-DBUILD_CLIENTS_BENCHMARKS=ON \
-DCPACK_SET_DESTDIR=OFF \
-DCMAKE_INSTALL_PREFIX=${ROCM_PATH} \
-DBUILD_ADDRESS_SANITIZER="${ADDRESS_SANITIZER}" \
-DCMAKE_MODULE_PATH="${ROCM_PATH}/lib/cmake/hip;${ROCM_PATH}/hip/cmake" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rocsparse() {
echo "Cleaning rocSPARSE build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_rocsparse ;;
outdir) print_output_directory ;;
clean) clean_rocsparse ;;
*) die "Invalid target $TARGET" ;;
esac

64
rocm-build/build_rocthrust.sh Executable file
View File

@@ -0,0 +1,64 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
ENABLE_ADDRESS_SANITIZER=false
build_release=true
set_component_src rocThrust
build_rocthrust() {
echo "Start build"
cd $COMPONENT_SRC
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
ASAN_CMAKE_PARAMS="false"
fi
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101"
fi
CXX=$(set_build_variables CXX)\
cmake \
${LAUNCHER_FLAGS} \
$(rocm_common_cmake_params) \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DCMAKE_MODULE_PATH="${ROCM_PATH}/lib/cmake/hip;${ROCM_PATH}/hip/cmake" \
-DROCPRIM_ROOT="${ROCM_PATH}/rocprim" \
-DBUILD_TEST=ON \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rocthrust() {
echo "Cleaning rocThrust build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
(clean) clean_rocthrust ;;
(build) build_rocthrust ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac

180
rocm-build/build_roctracer.sh Executable file
View File

@@ -0,0 +1,180 @@
#!/bin/bash
source "$(dirname $BASH_SOURCE)/compute_utils.sh"
printUsage() {
echo
echo "Usage: ${BASH_SOURCE##*/} [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of
type referred to by pkg_type"
echo " -h, --help Prints this help"
echo " -s, --static Build static lib (.a). build instead of dynamic/shared(.so) "
echo
return 0
}
API_NAME="roctracer"
PROJ_NAME="$API_NAME"
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_INCLUDE="$(getIncludePath)"
BUILD_DIR="$(getBuildPath $API_NAME)"
PACKAGE_DEB="$(getPackageRoot)/deb/$API_NAME"
PACKAGE_RPM="$(getPackageRoot)/rpm/$API_NAME"
PACKAGE_PREFIX="$ROCM_INSTALL_PATH"
export HIP_PATH="${ROCM_INSTALL_PATH}"
export HCC_HOME="${PACKAGE_ROOT}/hcc"
TARGET="build"
BUILD_TYPE="Debug"
MAKE_OPTS="$DASH_JAY -C $BUILD_DIR"
HIP_VDI=1
SHARED_LIBS="ON"
CLEAN_OR_OUT=0
MAKETARGET="deb"
PKGTYPE="deb"
GPU_LIST="gfx900;gfx906;gfx908;gfx90a;gfx940;gfx941;gfx942;gfx1030;gfx1100;gfx1101;gfx1102"
VALID_STR=$(getopt -o hcraso: --long help,clean,release,static,address_sanitizer,outdir: -- "$@")
eval set -- "$VALID_STR"
while true; do
case "$1" in
-h | --help)
printUsage
exit 0
;;
-c | --clean)
TARGET="clean"
((CLEAN_OR_OUT |= 1))
shift
;;
-r | --release)
BUILD_TYPE="RelWithDebInfo"
shift
;;
-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on
shift
;;
-s | --static)
SHARED_LIBS="OFF"
shift
;;
-o | --outdir)
TARGET="outdir"
PKGTYPE=$2
OUT_DIR_SPECIFIED=1
((CLEAN_OR_OUT |= 2))
shift 2
;;
--)
shift
break
;;
*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] " >&2
exit 20
;;
esac
done
RET_CONFLICT=1
check_conflicting_options $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
if [ $RET_CONFLICT -ge 30 ]; then
print_vars $API_NAME $TARGET $BUILD_TYPE $SHARED_LIBS $CLEAN_OR_OUT $PKGTYPE $MAKETARGET
exit $RET_CONFLICT
fi
clean() {
echo "Cleaning $PROJ_NAME"
rm -rf "$BUILD_DIR"
rm -rf "$PACKAGE_DEB"
rm -rf "$PACKAGE_RPM"
rm -rf "$PACKAGE_INCLUDE/${PROJ_NAME}"
rm -rf "$PACKAGE_ROOT/${PROJ_NAME}"
}
copy_libs_to_workspace() {
if [ "$ASAN_CMAKE_PARAMS" != "true" ]; then
cp -R "${ROCM_INSTALL_PATH}/lib/roctracer/" "${OUT_DIR}/lib/roctracer/"
fi
}
build() {
echo "Building $PROJ_NAME"
PACKAGE_CMAKE="$(getCmakePath)"
export ROCM_PATH="${ROCM_INSTALL_PATH}"
export HIPCC_COMPILE_FLAGS_APPEND="--rocm-path=$ROCM_PATH"
if [ ! -d "$BUILD_DIR" ]; then
mkdir -p "$BUILD_DIR"
pushd "$BUILD_DIR"
print_lib_type $SHARED_LIBS
export HIPCC_COMPILE_FLAGS_APPEND="--rocm-path=$ROCM_PATH --offload-arch=gfx900 --offload-arch=gfx906 --offload-arch=gfx908 \
--offload-arch=gfx90a --offload-arch=gfx940 --offload-arch=gfx1030 \
--offload-arch=gfx1100 --offload-arch=gfx1101 --offload-arch=gfx1102"
cmake $(rocm_cmake_params) \
-DCPACK_PACKAGING_INSTALL_PREFIX="$PACKAGE_PREFIX/$PROJ_NAME" \
-DCMAKE_MODULE_PATH="$PACKAGE_CMAKE/hip" \
-DCMAKE_HIP_ARCHITECTURES=OFF \
-DBUILD_SHARED_LIBS=$SHARED_LIBS \
$(rocm_common_cmake_params) \
-DCMAKE_HIP_ARCHITECTURES=OFF \
-DENABLE_LDCONFIG=OFF \
-DROCM_ROOT_DIR="$ROCM_INSTALL_PATH" \
-DHIP_VDI="$HIP_VDI" \
-DROCM_RPATH="$ROCM_RPATH" \
-DGPU_TARGETS="$GPU_LIST" \
-DCPACK_OBJCOPY_EXECUTABLE="${ROCM_INSTALL_PATH}/llvm/bin/llvm-objcopy" \
-DCPACK_READELF_EXECUTABLE="${ROCM_INSTALL_PATH}/llvm/bin/llvm-readelf" \
-DCPACK_STRIP_EXECUTABLE="${ROCM_INSTALL_PATH}/llvm/bin/llvm-strip" \
-DCPACK_OBJDUMP_EXECUTABLE="${ROCM_INSTALL_PATH}/llvm/bin/llvm-objdump" \
"$ROCTRACER_ROOT"
popd
fi
cmake --build "$BUILD_DIR" -- $MAKE_OPTS
cmake --build "$BUILD_DIR" -- $MAKE_OPTS mytest
cmake --build "$BUILD_DIR" -- $MAKE_OPTS doc
cmake --build "$BUILD_DIR" -- $MAKE_OPTS install
cmake --build "$BUILD_DIR" -- $MAKE_OPTS package
copy_if DEB "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_DEB" "$BUILD_DIR/${API_NAME}"*.deb
copy_if RPM "${CPACKGEN:-"DEB;RPM"}" "$PACKAGE_RPM" "$BUILD_DIR/${API_NAME}"*.rpm
}
print_output_directory() {
case ${PKGTYPE} in
"deb")
echo ${PACKAGE_DEB}
;;
"rpm")
echo ${PACKAGE_RPM}
;;
*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2
exit 1
;;
esac
exit
}
verifyEnvSetup
case $TARGET in
clean) clean ;;
build) build && copy_libs_to_workspace ;;
outdir) print_output_directory ;;
*) die "$BASH_SOURCE Invalid target $TARGET - exiting" ;;
esac
echo "Operation complete"

63
rocm-build/build_rocwmma.sh Executable file
View File

@@ -0,0 +1,63 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src rocWMMA
build_rocwmma() {
echo "Start build"
if [ ! -e $COMPONENT_SRC/CMakeLists.txt ]; then
echo "Skipping rocWMMA as source is not available"
mkdir -p $COMPONENT_SRC
exit 0
fi
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
ASAN_CMAKE_PARAMS="false"
fi
mkdir -p $BUILD_DIR && cd $BUILD_DIR
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx940;gfx941;gfx942;gfx1100;gfx1101"
fi
CXX=$(set_build_variables CXX)\
cmake \
$(rocm_common_cmake_params) \
${LAUNCHER_FLAGS} \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DROCWMMA_BUILD_VALIDATION_TESTS=ON \
-DROCWMMA_VALIDATE_WITH_ROCBLAS=ON \
-DROCWMMA_BUILD_BENCHMARK_TESTS=ON \
-DROCWMMA_BENCHMARK_WITH_ROCBLAS=ON \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cmake --build "$BUILD_DIR" -- package
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR && cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rocwmma() {
echo "Cleaning rocWMMA build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_rocwmma ;;
outdir) print_output_directory ;;
clean) clean_rocwmma ;;
*) die "Invalid target $TARGET" ;;
esac

78
rocm-build/build_rpp.sh Executable file
View File

@@ -0,0 +1,78 @@
#!/bin/bash
set -ex
source "$(dirname "${BASH_SOURCE[0]}")/compute_helper.sh"
set_component_src rpp
DEPS_DIR="$RPP_DEPS_LOCATION"
LLVM_LIBDIR="${ROCM_PATH}/llvm/lib"
ROCM_LLVM_LIB_RPATH="\$ORIGIN/llvm/lib"
rpp_specific_cmake_params() {
local rpp_cmake_params
if [ "${ASAN_CMAKE_PARAMS}" == "true" ] ; then
rpp_cmake_params="-DCMAKE_EXE_LINKER_FLAGS_INIT=-Wl,--enable-new-dtags,--rpath,$ROCM_ASAN_EXE_RPATH:$LLVM_LIBDIR"
else
rpp_cmake_params=""
fi
printf '%s ' "${rpp_cmake_params}"
}
build_rpp() {
echo "Start build"
if [ ! -e $COMPONENT_SRC/CMakeLists.txt ]; then
echo "Skipping RPP build as source is not available"
mkdir -p $COMPONENT_SRC
exit 0
fi
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ]; then
set_asan_env_vars
set_address_sanitizer_on
fi
mkdir -p $BUILD_DIR && cd $BUILD_DIR
if [ -n "$GPU_ARCHS" ]; then
GPU_TARGETS="$GPU_ARCHS"
else
GPU_TARGETS="gfx908;gfx90a;gfx940;gfx941;gfx942;gfx1030;gfx1100"
fi
cmake \
$(rocm_common_cmake_params) \
${LAUNCHER_FLAGS} \
-DBACKEND=HIP \
-DCMAKE_INSTALL_LIBDIR=$(getInstallLibDir) \
$(rpp_specific_cmake_params) \
-DAMDGPU_TARGETS=${GPU_TARGETS} \
-DCMAKE_SHARED_LINKER_FLAGS_INIT="-fno-openmp-implicit-rpath -Wl,--enable-new-dtags,--rpath,${ROCM_LIB_RPATH}:${DEPS_DIR}/lib:${ROCM_LLVM_LIB_RPATH}" \
-DCMAKE_PREFIX_PATH="${DEPS_DIR};${ROCM_PATH}" \
"$COMPONENT_SRC"
cmake --build "$BUILD_DIR" -- -j${PROC}
cmake --build "$BUILD_DIR" -- install
cpack -G ${PKGTYPE^^}
rm -rf _CPack_Packages/ && find -name '*.o' -delete
mkdir -p $PACKAGE_DIR
cp ${BUILD_DIR}/*.${PKGTYPE} $PACKAGE_DIR
show_build_cache_stats
}
clean_rpp() {
echo "Cleaning rpp build directory: ${BUILD_DIR} ${PACKAGE_DIR}"
rm -rf "$BUILD_DIR" "$PACKAGE_DIR"
echo "Done!"
}
stage2_command_args "$@"
case $TARGET in
build) build_rpp ;;
outdir) print_output_directory ;;
clean) clean_rpp ;;
*) die "Invalid target $TARGET" ;;
esac

205
rocm-build/build_thunk.sh Executable file
View File

@@ -0,0 +1,205 @@
#!/bin/bash
source "$(dirname "${BASH_SOURCE}")/compute_utils.sh"
printUsage() {
echo
echo "Usage: $(basename "${BASH_SOURCE}") [options ...]"
echo
echo "Options:"
echo " -c, --clean Clean output and delete all intermediate work"
echo " -p, --package <type> Specify packaging format"
echo " -r, --release Make a release build instead of a debug build"
echo " -a, --address_sanitizer Enable address sanitizer"
echo " -o, --outdir <pkg_type> Print path of output directory containing packages of type referred to by pkg_type"
echo " -h, --help Prints this help"
echo
echo "Possible values for <type>:"
echo " deb -> Debian format (default)"
echo " rpm -> RPM format"
echo
return 0
}
PACKAGE_ROOT="$(getPackageRoot)"
PACKAGE_DEB="$(getPackageRoot)/deb/libhsakmt"
PACKAGE_RPM="$(getPackageRoot)/rpm/libhsakmt"
THUNK_BUILD_DIR="$(getBuildPath thunk)"
TARGET="build"
MAKETARGET="deb"
MAKEARG="$DASH_JAY O=$THUNK_BUILD_DIR"
PACKAGE_LIB="$(getLibPath)"
PACKAGE_INCLUDE="$(getIncludePath)"
ROCT_BUILD_DIR="$(getBuildPath roct)"
ROCT_PACKAGE_DEB="$(getPackageRoot)/deb/roct"
ROCT_PACKAGE_RPM="$(getPackageRoot)/rpm/roct"
ROCT_BUILD_TYPE="debug"
BUILD_TYPE="Debug"
ROCT_MAKE_OPTS="$DASH_JAY -C $ROCT_BUILD_DIR"
CLEAN_OR_OUT=0;
print_vars() {
echo " Var status thunk "
echo "TARGET= $TARGET"
echo "BUILD_TYPE = $BUILD_TYPE"
echo "MAKETARGE = $MAKETARGET"
echo "CLEAN_OR_OUT = $CLEAN_OR_OUT"
echo "PKGTYPE= $PKGTYPE"
}
check_conflicting_options() {
if [ "$MAKETARGET" != "deb" ] && [ "$MAKETARGET" != "rpm" ] && [ "$MAKETARGET" != "tar" ]; then
echo " Wrong Param Passed for Package Type. Aborting .. "
print_vars
exit 30
fi
if [ $CLEAN_OR_OUT -ge 2 ]; then
if [ "$PKGTYPE" != "deb" ] && [ "$PKGTYPE" != "rpm" ] && [ "$PKGTYPE" != "tar" ]; then
echo " Wrong Param Passed for Package Type for the Outdir. Aborting .. "
print_vars
exit 40
fi
fi
if [ $CLEAN_OR_OUT -ge 3 ]; then
echo " Clean & Out Both are sepcified. Not accepted. Bailing .. "
exit 50
fi
}
VALID_STR=`getopt -o hcraso:p: --long help,clean,release,address_sanitizer,clean,outdir:,package: -- "$@"`
eval set -- "$VALID_STR"
while true ;
do
case "$1" in
(-h | --help)
printUsage ; exit 0;;
(-c | --clean)
TARGET="clean" ; ((CLEAN_OR_OUT|=1)) ; shift ;;
(-r | --release)
BUILD_TYPE="RelWithDebInfo" ; shift ;;
(-a | --address_sanitizer)
set_asan_env_vars
set_address_sanitizer_on ; shift ;;
(-s)
shift ;; # Static build requested, NO-OP for this package. Required for static Jenkins builds
(-o | --outdir)
TARGET="outdir"; PKGTYPE=$2 ; OUT_DIR_SPECIFIED=1 ; ((CLEAN_OR_OUT|=2)) ; shift 2 ;;
(-p | --package)
MAKETARGET="$2" ; shift 2;;
--) shift; break;;
(*)
echo " This should never come but just incase : UNEXPECTED ERROR Parm : [$1] ">&2 ; exit 20;;
esac
done
check_conflicting_options
clean_roct() {
rm -rf "$ROCT_BUILD_DIR"
rm -rf "$ROCT_PACKAGE_DEB"
rm -rf "$ROCT_PACKAGE_RPM"
rm -rf "$PACKAGE_ROOT/libhsakmt"
rm -rf "$PACKAGE_INCLUDE/libhsakmt"
rm -f $PACKAGE_LIB/libhsakmt.so*
rm -f $PACKAGE_LIB/libhsakmt.a
rm -f $PACKAGE_INCLUDE/hsakmt*.h $PACKAGE_INCLUDE/linux/kfd_ioctl.h
}
build_roct() {
echo "Building ROCt"
rm -f $ROCT_BUILD_DIR/hsakmt-roct*.deb
rm -f $ROCT_BUILD_DIR/hsakmt-roct-dev/hsakmt-roct*.deb
rm -f "$ROCT_PACKAGE_DEB"/*
rm -f $ROCT_BUILD_DIR/hsakmt-roct*.rpm
rm -f $ROCT_BUILD_DIR/hsakmt-roct-dev/hsakmt-roct*.rpm
rm -f "$ROCT_PACKAGE_RPM"/*
if [ "${DISTRO_ID}" = "centos-7" ]; then
libdrm_cmake_var="-DHSAKMT_REQUIRES_LIBDRM=true"
fi
if [ ! -d "$ROCT_BUILD_DIR" ]; then
mkdir -p "$ROCT_BUILD_DIR"
pushd "$ROCT_BUILD_DIR"
cmake \
-DCMAKE_MODULE_PATH="$THUNK_ROOT/cmake_modules" \
-DBUILD_SHARED_LIBS="OFF" \
$(rocm_cmake_params) \
$(rocm_common_cmake_params) \
-DHSAKMT_INSTALL_PREFIX="$PACKAGE_ROOT" \
-DHSAKMT_INSTALL_LIBDIR="$PACKAGE_LIB" \
-DHSAKMT_PACKAGING_INSTALL_PREFIX="$ROCM_PATH" \
-DENABLE_LDCONFIG=OFF \
-DHSAKMT_WERROR=1 \
-DADDRESS_SANITIZER="$ADDRESS_SANITIZER" \
$libdrm_cmake_var \
"$THUNK_ROOT"
popd
fi
cmake --build "$ROCT_BUILD_DIR" -- $ROCT_MAKE_OPTS
cmake --build "$ROCT_BUILD_DIR" -- $ROCT_MAKE_OPTS install
cmake --build "$ROCT_BUILD_DIR" -- $ROCT_MAKE_OPTS package
if [ -e "$THUNK_ROOT/hsakmt-dev.txt" ]; then
cmake --build "$ROCT_BUILD_DIR" -- $ROCT_MAKE_OPTS install-dev
cmake --build "$ROCT_BUILD_DIR" -- $ROCT_MAKE_OPTS package-dev
fi
mkdir -p "$PACKAGE_LIB"
if [ -e "$ROCT_BUILD_DIR/libhsakmt.so" ]; then
cp -R "$ROCT_BUILD_DIR/libhsakmt.so"* "$PACKAGE_LIB"
fi
if [ -e "$ROCT_BUILD_DIR/libhsakmt.a" ]; then
cp -R "$ROCT_BUILD_DIR/libhsakmt.a" "$PACKAGE_LIB"
fi
mkdir -p "$ROCT_PACKAGE_DEB"
if [[ "${CPACKGEN:-"DEB;RPM"}" =~ "DEB" ]] ; then
cp -a $ROCT_BUILD_DIR/hsakmt*.deb "$ROCT_PACKAGE_DEB"
if [ -e "$THUNK_ROOT/hsakmt-dev.txt" ]; then
cp -a $ROCT_BUILD_DIR/hsakmt-roct-dev/hsakmt-roct*.deb "$ROCT_PACKAGE_DEB"
fi
fi
mkdir -p "$ROCT_PACKAGE_RPM"
if [[ "${CPACKGEN:-"DEB;RPM"}" =~ "RPM" ]] ; then
cp -a $ROCT_BUILD_DIR/hsakmt*.rpm "$ROCT_PACKAGE_RPM"
if [ -e "$THUNK_ROOT/hsakmt-dev.txt" ]; then
cp -a $ROCT_BUILD_DIR/hsakmt-roct-dev/hsakmt-roct*.rpm "$ROCT_PACKAGE_RPM"
fi
fi
}
print_output_directory() {
case ${PKGTYPE} in
("deb")
echo ${ROCT_PACKAGE_DEB};;
("rpm")
echo ${ROCT_PACKAGE_RPM};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
verifyEnvSetup
case $TARGET in
(clean) clean_roct ;;
(build) build_roct ;;
(outdir) print_output_directory ;;
(*) die "Invalid target $TARGET" ;;
esac
echo "Operation complete"

View File

@@ -0,0 +1,9 @@
#!/bin/bash
# set ccache environment variable for math libraries
if [ "${CCACHE_ENABLED}" == "true" ] && [ -f "${OUT_DIR}"/logs/lightning ]; then
export LAUNCHER_FLAGS="-DCMAKE_CXX_COMPILER_LAUNCHER=/usr/local/bin/ccache -DCMAKE_C_COMPILER_LAUNCHER=/usr/local/bin/ccache"
export CCACHE_IGNOREHEADERS=${ROCM_PATH}/include:${ROCM_PATH}/llvm/include:${ROCM_PATH}/lib/llvm/lib/clang/17/include:${ROCM_PATH}/lib/llvm/include
export CCACHE_COMPILERCHECK=none
export CCACHE_EXTRAFILES=${OUT_DIR}/rocm_compilers_hash_file
fi

284
rocm-build/compute_helper.sh Executable file
View File

@@ -0,0 +1,284 @@
#!/bin/bash
# compute_helper.sh is created to add common functions similar to compute_utils.sh in stg1
# stg2 build scripts can make use of common function
# TODO: Component build scripts can be optimized by adding common function in this file(ex for ASAN, Debugging etc)
# All build scripts should use the common function.
set -e
set -o pipefail
# Set the LLVM directory path with respect to ROCM_PATH
# LLVM is installed in $ROCM_PATH/lib/llvm
ROCM_LLVMDIR="lib/llvm"
# Set ADDRESS_SANITIZER to OFF by default
export ADDRESS_SANITIZER="OFF"
# Print message to stderr
# param message string to print on exit
# Example: printErr "file not found"
printErr() {
echo "$@" 1>&2
}
# Print message to stderr and terminate current program
# param message string to print on exit
# Example: die "Your program" has terminated
die() {
printErr "FATAL: $@"
exit 1
}
# Die if first argument is empty
# param string to validate
# param error message
# Example: die "$VARIABLE" "Your program" has terminated
dieIfEmpty() {
if [ "$1" == "" ]; then
shift
die "$@"
fi
}
# Copy a file or directory to target location and show single line progress
progressCopy() {
if [ -d "$1" ]; then
rsync -a "$1"/* "$2"
else
rsync -a "$1" "$2"
fi
}
# Get OS identification string
# xargs will remove the trailing whitespaces
getOsVersion() {
lsb_release -d | cut -d: -f2 | xargs
}
# Get kernel identification string
getKernelVersion() {
uname -r
}
# Trim excessive whitespace from a string
strTrim() {
echo "$@" | xargs
}
# Return whether the booted OS is Fedora or not
isFedora() {
grep -iq fedora /etc/os-release
}
# Return whether the booted system is EFI or not
isEFI() {
[ -d "/sys/firmware/efi" ]
}
print_lib_type() {
if [ "$1" == "OFF" ];
then
echo " Building Archive "
else
echo " Building Shared Object "
fi
}
# Get CMAKE build flags for CMAKE build trigger
set_build_variables() {
local cmake_cxx_flag_params
local cmake_cc_flag_params
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ] ; then
cmake_cxx_flag_params="$ROCM_PATH/llvm/bin/clang++"
cmake_cc_flag_params="$ROCM_PATH/llvm/bin/clang"
cmake_comp_params=(
"-DCMAKE_C_COMPILER=$ROCM_PATH/llvm/bin/clang"
"-DCMAKE_CXX_COMPILER=$ROCM_PATH/llvm/bin/clang++"
)
else
cmake_cxx_flag_params="$ROCM_PATH/bin/hipcc"
cmake_cc_flag_params="$ROCM_PATH/bin/hipcc"
cmake_comp_params=(
"-DCMAKE_C_COMPILER=$ROCM_PATH/bin/hipcc"
"-DCMAKE_CXX_COMPILER=$ROCM_PATH/bin/hipcc"
)
fi
case "$1" in
("CXX")
printf "%s" "${cmake_cxx_flag_params}"
;;
("CC")
printf "%s" "${cmake_cc_flag_params}"
;;
("CMAKE_C_CXX")
printf '%s ' "${cmake_comp_params[@]}"
;;
(*)
exit 1
;;
esac
exit
}
# Get the directory containing the cmake config files
getCmakePath() {
local rocmInstallPath=${ROCM_PATH}
local cmakePath="lib/cmake"
dieIfEmpty "$rocmInstallPath"
echo "$rocmInstallPath/$cmakePath"
}
# Get the install directory name for libraries
# lib - For normal builds
# lib/asan -For ASAN builds
getInstallLibDir() {
local libDir="lib"
if [ "${ENABLE_ADDRESS_SANITIZER}" == "true" ] ; then
libDir="lib/asan"
fi
echo "$libDir"
}
# TODO: Use the function to set the LDFLAGS and CXXFLAGS for ASAN
# rather than setting in individual build scripts
set_asan_env_vars() {
# Flag to set cmake build params for ASAN builds
ASAN_CMAKE_PARAMS="true"
export ADDRESS_SANITIZER="ON"
LLVM_BIN_DIR="${ROCM_PATH}/llvm/bin"
export CC="$LLVM_BIN_DIR/clang"
export CXX="$LLVM_BIN_DIR/clang++"
export FC="$LLVM_BIN_DIR/flang"
export PATH="$LLVM_BIN_DIR/:$PATH"
# get exact path to ASAN lib containing clang version
ASAN_LIB_PATH=$(clang --print-file-name=libclang_rt.asan-x86_64.so)
export LD_LIBRARY_PATH="${ASAN_LIB_PATH%/*}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export ASAN_OPTIONS="detect_leaks=0"
}
set_address_sanitizer_on() {
export CFLAGS="-fsanitize=address -shared-libasan -g -gz"
export CXXFLAGS="-fsanitize=address -shared-libasan -g -gz"
export LDFLAGS="-Wl,--enable-new-dtags -fuse-ld=lld -fsanitize=address -shared-libasan -g -gz -Wl,--build-id=sha1 -L${ROCM_PATH}/lib/asan"
}
rebuild_lapack() {
wget -nv -O lapack-3.9.1.tar.gz \
http://compute-artifactory.amd.com/artifactory/rocm-generic-thirdparty-deps/ubuntu/lapack-v3.9.1.tar.gz
sh -c "echo 'd0085d2caf997ff39299c05d4bacb6f3d27001d25a4cc613d48c1f352b73e7e0 *lapack-3.9.1.tar.gz' | sha256sum -c"
tar xzf lapack-3.9.1.tar.gz --one-top-level=lapack-src --strip-components 1
rm lapack-3.9.1.tar.gz
cmake -Slapack-src -Blapack-bld \
${LAUNCHER_FLAGS} \
-DBUILD_TESTING=OFF \
-DCBLAS=ON \
-DLAPACKE=OFF
cmake --build lapack-bld -- -j${PROC}
cmake --build lapack-bld -- install
rm -r lapack-src lapack-bld
}
# debug function #dumping values in case of error to solve the same
print_vars() {
echo " Status of Vars in $1 build "
echo " TARGET= $2 "
echo " BUILD_TYPE = $3 "
echo " SHARED_LIBS = $4 "
echo " CLEAN_OR_OUT = $5 "
echo " PKGTYPE= $6 "
echo " MAKETARGET = $7 "
}
# Common cmake parameters can be set
# component build scripts can use this function
rocm_common_cmake_params() {
local cmake_params
if [ "${ASAN_CMAKE_PARAMS}" == "true" ] ; then
local ASAN_LIBDIR="lib/asan"
local CMAKE_PATH=$(getCmakePath)
cmake_params=(
"-DCMAKE_PREFIX_PATH=$CMAKE_PATH;${ROCM_PATH}/$ASAN_LIBDIR;$ROCM_PATH/llvm;$ROCM_PATH"
"-DCMAKE_BUILD_TYPE=${BUILD_TYPE:-'RelWithDebInfo'}"
"-DCMAKE_SHARED_LINKER_FLAGS_INIT=-Wl,--enable-new-dtags,--rpath,$ROCM_ASAN_LIB_RPATH"
"-DCMAKE_EXE_LINKER_FLAGS_INIT=-Wl,--enable-new-dtags,--rpath,$ROCM_ASAN_EXE_RPATH"
"-DENABLE_ASAN_PACKAGING=true"
)
else
cmake_params=(
"-DCMAKE_PREFIX_PATH=${ROCM_PATH}/llvm;${ROCM_PATH}"
"-DCMAKE_BUILD_TYPE=${BUILD_TYPE:-'Release'}"
"-DCMAKE_SHARED_LINKER_FLAGS_INIT=-Wl,--enable-new-dtags,--rpath,$ROCM_LIB_RPATH"
"-DCMAKE_EXE_LINKER_FLAGS_INIT=-Wl,--enable-new-dtags,--rpath,$ROCM_EXE_RPATH"
)
fi
printf '%s ' "${cmake_params[@]}"
local common_cmake_params
common_cmake_params=(
"-DCMAKE_VERBOSE_MAKEFILE=1"
"-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE"
"-DCMAKE_INSTALL_PREFIX=${ROCM_PATH}"
"-DCMAKE_PACKAGING_INSTALL_PREFIX=${ROCM_PATH}"
"-DBUILD_FILE_REORG_BACKWARD_COMPATIBILITY=OFF"
"-DROCM_SYMLINK_LIBS=OFF"
"-DCPACK_PACKAGING_INSTALL_PREFIX=${ROCM_PATH}"
"-DROCM_DISABLE_LDCONFIG=ON"
"-DROCM_PATH=${ROCM_PATH}"
)
printf '%s ' "${common_cmake_params[@]}"
}
# Setup a number of variables to specify where to find the source
# where to do the build and where to put the packages
# Note the PACKAGE_DIR downcases the package name
# This could be extended to do different things based on $1
set_component_src(){
COMPONENT_SRC="$LIBS_WORK_DIR/$1"
BUILD_DIR="$OUT_DIR/build/$1"
DEB_PATH="$OUT_DIR/${PKGTYPE}/${1,,}"
RPM_PATH="$OUT_DIR/${PKGTYPE}/${1,,}"
PACKAGE_DIR="$OUT_DIR/${PKGTYPE}/${1,,}"
}
# Standard definition of function to print the package location. If
# for some reason a custom version is needed then it can overwrite
# this definition
# TODO: Don't use a global PKGTYPE, pass the value in as a parameter
print_output_directory() {
case ${1:-$PKGTYPE} in
("deb")
echo ${DEB_PATH};;
("rpm")
echo ${RPM_PATH};;
(*)
echo "Invalid package type \"${PKGTYPE}\" provided for -o" >&2; exit 1;;
esac
exit
}
# Standard argument processing
# Here to avoid repetition
TARGET="build" # default target
stage2_command_args(){
while [ "$1" != "" ];
do
case $1 in
-o | --outdir )
shift 1; PKGTYPE=$1 ; TARGET="outdir" ;;
-c | --clean )
TARGET="clean" ;;
*)
break ;;
esac
shift 1
done
}
show_build_cache_stats(){
if [ "$CCACHE_ENABLED" = "true" ] ; then
if ! ccache -s ; then
echo "Unable to display ccache stats"
fi
fi
}

372
rocm-build/compute_utils.sh Executable file
View File

@@ -0,0 +1,372 @@
#!/bin/bash
: <<'END_COMMENT'
This script retains only those functions from the original compute_utils.sh
that the ROCm build scripts utilize.
END_COMMENT
set -e
set -o pipefail
# Set a sensible default value for DASH_JAY in case none is provided
DASH_JAY=${DASH_JAY:-"-j $(nproc)"}
# Enable ccache by default unless requested otherwhise
if [[ "$ROCM_USE_CCACHE" != "0" ]] ; then
for d in /usr/lib/ccache /usr/lib64/ccache ;do
if [ -d "$d" ]; then
PATH="$d:$PATH"
break # Only add one ccache at most
fi
done
fi
# Print message to stderr
# param message string to print on exit
# Example: printErr "file not found"
printErr() {
echo "$@" 1>&2
}
# Print message to stderr and terminate current program
# param message string to print on exit
# Example: die "Your program" has terminated
die() {
printErr "FATAL: $@"
exit 1
}
# Die if first argument is empty
# param string to validate
# param error message
# Example: die "$VARIABLE" "Your program" has terminated
dieIfEmpty() {
if [ "$1" == "" ]; then
shift
die "$@"
fi
}
# Get directory with build output package
# Precedence:
# 1. PWD
# 2. Caller's folder
# 3. Known build output folder
getPackageRoot() {
local scriptPath=$(readlink -f $(dirname $BASH_SOURCE))
local testFile="build.version"
if [ -a "$PWD/$testFile" ]; then
echo "$PWD"
elif [ -a "$scriptPath/../$testFile" ]; then
echo "$scriptPath/.."
elif [ -a "$scriptPath/$testFile" ]; then
echo "$scriptPath"
elif [ ! -z "$OUT_DIR" ]; then
echo "$OUT_DIR"
else
die "Failed to determine package directory"
fi
}
# Get a list of directories containing the build output
# shared objects.
# Important: PWD takes precedence over build output folder
getLibPath() {
local packageRoot="$(getPackageRoot)"
dieIfEmpty "$packageRoot"
echo "$packageRoot/lib"
}
# Get a list of directories containing the output executables
# param binDir (optional) - package name
# Important: PWD takes precedence over build output folder
getBinPath() {
local binDir="$1"
local packageRoot=$(getPackageRoot)
dieIfEmpty "$packageRoot"
if [ "$binDir" == "" ]; then
echo "$packageRoot/bin"
else
echo "$packageRoot/bin/$binDir"
fi
}
# Get a list of directories containing the output source files
# Important: PWD takes precedence over build output folder
getSrcPath() {
local packageRoot=$(getPackageRoot)
dieIfEmpty "$packageRoot"
echo "$packageRoot/src"
}
# Get a list of directories to place build output
# param moduleName - name of the module for the build path
# Important: PWD takes precedence over build output folder
getBuildPath() {
local moduleName="$1"
local packageRoot=$(getPackageRoot)
dieIfEmpty "$packageRoot"
echo "$packageRoot/build/$moduleName"
}
# Get a list of directories containing the output etc files
# Important: PWD takes precedence over build output folder
getUtilsPath() {
local packageRoot=$(getPackageRoot)
dieIfEmpty "$packageRoot"
echo "$packageRoot/utils"
}
# Get a list of directories containing the output include files
# Important: PWD takes precedence over build output folder
getIncludePath() {
local packageRoot=$(getPackageRoot)
dieIfEmpty "$packageRoot"
echo "$packageRoot/include"
}
# Get the directory containing the cmake config files
getCmakePath() {
local rocmInstallPath=${ROCM_INSTALL_PATH}
local cmakePath="lib/cmake"
if [ "$ASAN_CMAKE_PARAMS" == "true" ] ; then
cmakePath="lib/asan/cmake"
fi
dieIfEmpty "$rocmInstallPath"
echo "$rocmInstallPath/$cmakePath"
}
# Get a list of directories containing the output debian files
# Important: PWD takes precedence over build output folder
getDebPath() {
local packageName="$1"
dieIfEmpty "$packageName" "No valid package name specified"
local packageRoot=$(getPackageRoot)
dieIfEmpty "$packageRoot"
echo "$packageRoot/deb/$packageName"
}
# Get a list of directories containing the output rpm files
# Important: PWD takes precedence over build output folder
getRpmPath() {
local packageName="$1"
dieIfEmpty "$packageName" "No valid package name specified"
local packageRoot=$(getPackageRoot)
dieIfEmpty "$packageRoot"
echo "$packageRoot/rpm/$packageName"
}
verifyEnvSetup() {
if [ -z "$OUT_DIR" ]; then
die "Please source build/envsetup.sh first."
fi
}
# Copy a file or directory to target location and show single line progress
progressCopy() {
if [ -d "$1" ]; then
rsync -a "$1"/* "$2"
else
rsync -a "$1" "$2"
fi
}
#following three common functions have been written to addition of static libraries
print_lib_type() {
if [ "$1" == "OFF" ];
then
echo " Building Archive "
else
echo " Building Shared Object "
fi
}
check_conflicting_options() {
# 1->CLEAN_OR_OUT 2->PKGTYPE 3->MAKETARGET
RET_CONFLICT=0
if [ $1 -ge 2 ]; then
if [ "$2" != "deb" ] && [ "$2" != "rpm" ] && [ "$2" != "tar" ]; then
echo " Wrong Param Passed for Package Type for the Outdir... "
RET_CONFLICT=30
fi
fi
# check Clean Vs Outdir
if [ $1 -ge 3 ] && [ $RET_CONFLICT -eq 0 ] ; then
echo " Clean & Out Both are sepcified. Not accepted. Bailing .. "
RET_CONFLICT=40
fi
if [ $RET_CONFLICT -eq 0 ] && [ "$3" != "deb" ] && [ "$3" != "rpm" ] && [ "$3" != "all" ] && [ "$3" != "tar" ]; then
echo " Wrong Param Passed for Package Type... "
RET_CONFLICT=50
fi
}
set_asan_env_vars() {
# Flag to set cmake build params for ASAN builds
ASAN_CMAKE_PARAMS="true"
# Pass the LLVM bin path as the first parameter
LLVM_BIN_DIR=${1:-"${ROCM_INSTALL_PATH}/llvm/bin"}
export CC="$LLVM_BIN_DIR/clang"
export CXX="$LLVM_BIN_DIR/clang++"
export PATH="$PATH:$LLVM_BIN_DIR/"
# get exact path to ASAN lib containing clang version
ASAN_LIB_PATH=$(clang --print-file-name=libclang_rt.asan-x86_64.so)
export LD_LIBRARY_PATH="${ASAN_LIB_PATH%/*}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export ASAN_OPTIONS="detect_leaks=0"
}
set_address_sanitizer_on() {
# In SLES and RHEL debuginfo package is not getting generated
# when compiler is set to clang. Using default -gdwarf-5 is getting unhandled in these distros
# So setting -gdwarf-4 as a quick fix
# TODO: -gdwarf-5 unhandling when compiler set to clang need to be fixed
SET_DWARF_VERSION_4=""
if [[ $DISTRO_ID == sles* ]] || [[ $DISTRO_ID == rhel* ]]; then
SET_DWARF_VERSION_4="-gdwarf-4"
fi
export CFLAGS="-fsanitize=address -shared-libasan -g $SET_DWARF_VERSION_4"
export CXXFLAGS="-fsanitize=address -shared-libasan -g $SET_DWARF_VERSION_4"
export LDFLAGS="-Wl,--enable-new-dtags -fuse-ld=lld -fsanitize=address -shared-libasan -g -Wl,--build-id=sha1 -L$ROCM_INSTALL_PATH/lib/asan"
}
ack_and_ignore_asan() {
echo "-a parameter accepted but ignored"
}
#debug function #dumping values in case of error to solve the same
print_vars() {
echo " Status of Vars in $1 build "
echo " TARGET= $2 "
echo " BUILD_TYPE = $3 "
echo " SHARED_LIBS = $4 "
echo " CLEAN_OR_OUT = $5 "
echo " PKGTYPE= $6 "
echo " MAKETARGET = $7 "
}
# Provide this as a function, rather than a variable to delay the evaluation
# of variables. In particular we might want to put code in here which changes
# depending on if we are building with the address sanitizer or not
# Can do things like set the packaging type - no point in packaging RPM on debian and
# vica versa.
# Set CPACK_RPM_INSTALL_WITH_EXEC so it packages debug info for shared libraries.
rocm_common_cmake_params(){
if [ "$BUILD_TYPE" = "RelWithDebInfo" ] ; then
printf '%s ' "-DCPACK_RPM_DEBUGINFO_PACKAGE=TRUE" \
"-DCPACK_DEBIAN_DEBUGINFO_PACKAGE=TRUE" \
"-DCPACK_RPM_INSTALL_WITH_EXEC=TRUE" \
# end of list comment or blank line
fi
printf '%s ' "-DROCM_DEP_ROCMCORE=ON" \
"-DCMAKE_EXE_LINKER_FLAGS_INIT=-Wl,--enable-new-dtags,--build-id=sha1,--rpath,$ROCM_EXE_RPATH" \
"-DCMAKE_SHARED_LINKER_FLAGS_INIT=-Wl,--enable-new-dtags,--build-id=sha1,--rpath,$ROCM_LIB_RPATH" \
"-DFILE_REORG_BACKWARD_COMPATIBILITY=OFF" \
"-DINCLUDE_PATH_COMPATIBILITY=OFF" \
# set lib directory to lib/asan for ASAN builds
# Disable file reorg backward compatibilty for ASAN builds
# ENABLE_ASAN_PACKAGING - Used for enabling ASAN packaging
if [ "$ASAN_CMAKE_PARAMS" == "true" ] ; then
local asan_common_cmake_params
local ASAN_LIBDIR="lib/asan"
local CMAKE_PATH=$(getCmakePath)
asan_common_cmake_params=(
"-DCMAKE_INSTALL_LIBDIR=$ASAN_LIBDIR"
"-DCMAKE_PREFIX_PATH=$CMAKE_PATH;${ROCM_INSTALL_PATH}/$ASAN_LIBDIR;$ROCM_INSTALL_PATH/llvm;$ROCM_INSTALL_PATH"
"-DENABLE_ASAN_PACKAGING=$ASAN_CMAKE_PARAMS"
"-DCMAKE_SHARED_LINKER_FLAGS_INIT=-Wl,--enable-new-dtags,--build-id=sha1,--rpath,$ROCM_ASAN_LIB_RPATH"
)
printf '%s ' "${asan_common_cmake_params[@]}"
else
printf '%s ' "-DCMAKE_INSTALL_LIBDIR=lib" \
# end of list comment or blank line
fi
}
rocm_cmake_params() {
local cmake_params
cmake_params=(
"-DCMAKE_PREFIX_PATH=${ROCM_INSTALL_PATH}/llvm;${ROCM_INSTALL_PATH}"
"-DCMAKE_BUILD_TYPE=${BUILD_TYPE:-'RelWithDebInfo'}"
"-DCMAKE_VERBOSE_MAKEFILE=1"
"-DCPACK_GENERATOR=${CPACKGEN:-'DEB;RPM'}"
"-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE"
"-DROCM_PATCH_VERSION=${ROCM_LIBPATCH_VERSION}"
"-DCMAKE_INSTALL_PREFIX=${ROCM_INSTALL_PATH}"
"-DCPACK_PACKAGING_INSTALL_PREFIX=${ROCM_INSTALL_PATH}"
)
printf '%s ' "${cmake_params[@]}"
}
copy_if(){
local type=$1 selector=$2 dir=$3
shift 3
mkdir -p "$dir"
if [[ "$selector" =~ "$type" ]] ; then
cp -a "$@" "$dir"
fi
# handle ddeb files as well, renaming them on the way
for f
do
case "$f" in
# Properly formed debian package name is a number of _ separated fields
# The first is the package name.
# Second is version number
# third is architecture
# Ensure we have at least one _ in the name
(*"_"*".deb")
local deb=${f%.deb}
local basename=${deb##*/}
local dirname=${f%/*}
# filename($f) can be either /some/path/pkgname.deb or pkgname.deb
# If its pkgname.deb, then directory should be .
[[ "$dirname" == "$f" ]] && dirname=.
local pkgname=${basename%%_*}
local pkgextra=${basename#*_}
# cmake 3.22 creates the filename by replacing .deb with -dbgsym.ddeb
# at least for hostcall. Mind you hostcall looks to be incorrectly packaged.
if [ -e "${deb}-dbgsym.ddeb" ]
then
dest=${deb##*/}
dest="${dest%%_*}-dbgsym_${dest#*_}"
cp -a "${deb}-dbgsym.ddeb" "$dir/${dest##*/}.deb"
fi
# This is needed for comgr
if [ -e "$dirname/${pkgname}-dbgsym_${pkgextra}.ddeb" ]
then
cp "$dirname/${pkgname}-dbgsym_${pkgextra}.ddeb" "$dir/${pkgname}-dbgsym_${pkgextra}.deb"
fi
;;
esac
done
}
# Function to remove -r or -R from MAKEFLAGS
remove_make_r_flags(){
local firstword='^[^ ]*'
if [[ "$MAKEFLAGS" =~ ${firstword}r ]] ; then MAKEFLAGS=${MAKEFLAGS/r/} ; fi
if [[ "$MAKEFLAGS" =~ ${firstword}R ]] ; then MAKEFLAGS=${MAKEFLAGS/R/} ; fi
}
# Set a variable to the value needed by cmake to use ninja if it is available
# If GEN_NINJA is already defined, even as the empty string, then leave the value alone
# Intended use in build_xxxx.sh is ${GEN_NINJA:+"$GEN_NINJA"} to cope with potentially weird values
# but in practice just ${GEN_NINJA} without quotes will be fine.
# e.g. cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" $GEN_NINJA
# If for some reason you wanted to build without ninja just export an empty GEN_NINJA variable
if [ "${GEN_NINJA+defined}" != "defined" ] && command -v ninja >/dev/null ; then
GEN_NINJA=-GNinja
fi

View File

@@ -0,0 +1,7 @@
FROM ubuntu:focal as builder
COPY packages /tmp/packages
COPY install-prerequisites.sh /tmp/install-prerequisites.sh
ENV KBUILD_PKG_ROOTCMD=
ENV RPP_DEPS_LOCATION=/usr/local/rpp-deps
RUN /tmp/install-prerequisites.sh
WORKDIR /src

View File

@@ -0,0 +1,26 @@
## Steps to build the Docker Image
1. Clone this repositry
```bash
git clone -b roc-6.1.x https://github.com/ROCm/ROCm.git
```
2. Go into the OS specific docker directory in build-infra
```bash
cd ROCm/rocm-build/docker/ubuntu20
```
3. Build the Docker image
```bash
docker build -t <docker Image Name> .
```
replace the `<docker Image Name>` with the new Docker image Name of your choice,
4. After successful build, verify your \<docker Image Name\> in the list all available docker images.
```bash
docker images
```

View File

@@ -0,0 +1,217 @@
#! /usr/bin/bash
set -ex
apt-get update
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install --no-install-recommends -y $(grep -v '^#' /tmp/packages)
apt-get clean
rm -rf /var/cache/apt/ /var/lib/apt/lists/* /etc/apt/apt.conf.d/01proxy
#Install git 2.17.1 version
curl -o git.tar.gz https://cdn.kernel.org/pub/software/scm/git/git-2.17.1.tar.gz
tar -zxf git.tar.gz
cd git-*
make prefix=/usr/local all
make prefix=/usr/local install
git --version
#install argparse and CppHeaderParser python modules for roctracer and rocprofiler
# CppHeader needs setuptools. setuptools needs wheel.
pip3 install --no-cache-dir setuptools wheel tox
pip3 install --no-cache-dir CppHeaderParser argparse requests lxml barectf recommonmark jinja2==3.0.0 websockets matplotlib numpy scipy minimal msgpack pytest sphinx joblib cmake==3.25.2 pandas myst-parser
# Allow sudo for everyone user
echo 'ALL ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/everyone
# Install OCaml packages to build LLVM's OCaml bindings to be used in lightning compiler test pipeline
wget -nv https://sourceforge.net/projects/opam.mirror/files/2.1.4/opam-2.1.4-x86_64-linux -O /usr/local/bin/opam
chmod +x /usr/local/bin/opam
opam init --yes --disable-sandboxing
opam install ctypes --yes
# Install and modify git-repo (#!/usr/bin/env python -> #!/usr/bin/env python3)
curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo
chmod a+x /usr/bin/repo
# Build a newer version of doxygen because of issue 6456
#Install doxygen 1.8.11 for dbgapi
mkdir /tmp/doxygen
cd /tmp/doxygen
curl -LO https://sourceforge.net/projects/doxygen/files/rel-1.8.18/doxygen-1.8.18.src.tar.gz
tar xzf doxygen-1.8.18.src.tar.gz
cd doxygen-1.8.18
mkdir -p build
cd build
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -Wno-dev ..
make -j install
cd ../..
rm -rf /tmp/doxygen
# Build ccache from the source
cd /tmp
git clone https://github.com/ccache/ccache -b v4.7.5
cd ccache
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
make install
cd /tmp
rm -rf ccache
# Install sharp from MLNX_OFED_LINUX as dependency for rccl-rdma-sharp-plugins
cd /var/tmp
mkdir mlnx
wget -O mlnx/tar.tgz https://content.mellanox.com/ofed/MLNX_OFED-5.2-1.0.4.0/MLNX_OFED_LINUX-5.2-1.0.4.0-ubuntu20.04-x86_64.tgz
tar -xz -C mlnx -f mlnx/tar.tgz
apt-key add mlnx/*/RPM-GPG-KEY-Mellanox
echo "deb [arch=amd64] file:$(echo $PWD/mlnx/*/DEBS) ./" > /etc/apt/sources.list.d/sharp.list
apt update
apt install -y sharp
apt clean
rm -rf /var/cache/apt/ /var/lib/apt/lists/* mlnx /etc/apt/sources.list.d/sharp.list
#Install older version of hwloc-devel package for rocrtst
curl -lO https://download.open-mpi.org/release/hwloc/v1.11/hwloc-1.11.13.tar.bz2
tar -xvf hwloc-1.11.13.tar.bz2
cd hwloc-1.11.13
./configure
make
make install
cp /usr/local/lib/libhwloc.so.5 /usr/lib
hwloc-info --version
## Install googletest from source
mkdir -p /tmp/gtest
cd /tmp/gtest
wget https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip -O googletest.zip
unzip googletest.zip
cd googletest-1.14.0/
mkdir build
cd build
cmake ..
make -j$(nproc)
make install
rm -rf /tmp/gtest
## Install gRPC from source
## RDC Pre-requisites
GRPC_ARCHIVE=grpc-1.61.0.tar.gz
mkdir /tmp/grpc
mkdir /usr/grpc
cd /tmp
git clone --recurse-submodules -b v1.61.0 https://github.com/grpc/grpc
cd grpc
mkdir -p cmake/build
cd cmake/build
cmake -DgRPC_INSTALL=ON -DBUILD_SHARED_LIBS=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr/grpc -DCMAKE_CXX_STANDARD=14 ../..
make -j$(nproc)
make install
cd /
rm -rf /tmp/grpc
## Download prebuilt AMD multithreaded blis (2.0)
## Reference : https://github.com/ROCmSoftwarePlatform/rocBLAS/blob/develop/install.sh#L403
mkdir -p /tmp/blis
cd /tmp/blis
wget -O - https://github.com/amd/blis/releases/download/2.0/aocl-blis-mt-ubuntu-2.0.tar.gz | tar xfz -
mv amd-blis-mt /usr/blis
cd /
rm -rf /tmp/blis
## Download aocl-linux-aocc-4.0_1_amd64.deb
mkdir -p /tmp/aocl
cd /tmp/aocl
wget -nv https://download.amd.com/developer/eula/aocl/aocl-4-0/aocl-linux-aocc-4.0_1_amd64.deb
apt install ./aocl-linux-aocc-4.0_1_amd64.deb
rm -rf /tmp/aocl
## lapack(3.9.1v)
## Reference https://github.com/ROCmSoftwarePlatform/rocSOLVER/blob/develop/install.sh#L174
lapack_version=3.9.1
lapack_srcdir=lapack-$lapack_version
lapack_blddir=lapack-$lapack_version-bld
mkdir -p /tmp/lapack
cd /tmp/lapack
mkdir -p /tmp/lapack
cd /tmp/lapack
rm -rf "$lapack_srcdir" "$lapack_blddir"
wget -O - https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v3.9.1.tar.gz | tar xzf -
cmake -H$lapack_srcdir -B$lapack_blddir -DCMAKE_BUILD_TYPE=Release -DCMAKE_Fortran_FLAGS=-fno-optimize-sibling-calls -DBUILD_TESTING=OFF -DCBLAS=ON -DLAPACKE=OFF
make -j$(nproc) -C "$lapack_blddir"
make -C "$lapack_blddir" install
cd $lapack_blddir
cp -r ./include/* /usr/local/include/
cp -r ./lib/* /usr/local/lib
cd /
rm -rf /tmp/lapack
## FMT(7.1.3v)
## Reference https://github.com/ROCmSoftwarePlatform/rocSOLVER/blob/develop/install.sh#L152
fmt_version=7.1.3
fmt_srcdir=fmt-$fmt_version
fmt_blddir=fmt-$fmt_version-bld
rm -rf "$fmt_srcdir" "$fmt_blddir"
wget -O - https://github.com/fmtlib/fmt/archive/refs/tags/$fmt_version.tar.gz | tar xzf -
cmake -H$fmt_srcdir -B$fmt_blddir -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_EXTENSIONS=OFF -DCMAKE_CXX_STANDARD_REQUIRED=ON -DFMT_DOC=OFF -DFMT_TEST=OFF
make -j$(nproc) -C "$fmt_blddir"
make -C "$fmt_blddir" install
# Build and install libjpeg-turbo
mkdir -p /tmp/libjpeg-turbo
cd /tmp/libjpeg-turbo
wget -nv https://github.com/rrawther/libjpeg-turbo/archive/refs/heads/2.0.6.2.zip -O libjpeg-turbo-2.0.6.2.zip
unzip libjpeg-turbo-2.0.6.2.zip
cd libjpeg-turbo-2.0.6.2
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_STATIC=FALSE -DCMAKE_INSTALL_DEFAULT_LIBDIR=lib ..
make -j$(nproc) install
rm -rf /tmp/libjpeg-turbo
# Get released ninja from source
mkdir -p /tmp/ninja
cd /tmp/ninja
wget -nv https://codeload.github.com/Kitware/ninja/zip/refs/tags/v1.11.1.g95dee.kitware.jobserver-1 -O ninja.zip
unzip ninja.zip
cd ninja-1.11.1.g95dee.kitware.jobserver-1
./configure.py --bootstrap
cp ninja /usr/local/bin/
rm -rf /tmp/ninja
# Install pre-built FFmpeg and dependencies
# See docker/build-deps for instructions on how to build these packages
wget -qO- https://www.ffmpeg.org/releases/ffmpeg-4.4.2.tar.gz | tar -xzv -C /usr/local
command -v lbzip2
ln -sf $(command -v lbzip2) /usr/local/bin/compressor || ln -sf $(command -v bzip2) /usr/local/bin/compressor
# Install Google Benchmark
mkdir -p /tmp/Gbenchmark
cd /tmp/Gbenchmark
wget -qO- https://github.com/google/benchmark/archive/refs/tags/v1.6.1.tar.gz | tar xz
cmake -Sbenchmark-1.6.1 -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_CXX_STANDARD=14
make -j -C build
cd /tmp/Gbenchmark/build
make install
# Build boost-1.82.0 from source for RPP
# Installing in a non-standard location since the test packages of hipFFT and rocFFT pick up the version of
# the installed Boost library and declare a package dependency on that specific version of Boost.
# For example, if this was installed in the standard location it would declare a dependency on libboost-dev(el)1.82.0
# which is not available as a package in any distro.
# Once this is fixed, we can remove the Boost package from the requirements list and install this
# in the standard location
# export RPP_DEPS_LOCATION=/usr/local/rpp-deps
mkdir -p /tmp/boost-1.82.0
cd /tmp/boost-1.82.0
wget -nv https://sourceforge.net/projects/boost/files/boost/1.82.0/boost_1_82_0.tar.bz2 -O ./boost_1_82_0.tar.bz2
tar -xf boost_1_82_0.tar.bz2 --use-compress-program="/usr/local/bin/compressor"
cd boost_1_82_0
./bootstrap.sh --prefix=${RPP_DEPS_LOCATION} --with-python=python3
./b2 stage -j$(nproc) threading=multi link=shared cxxflags="-std=c++11"
./b2 install threading=multi link=shared --with-system --with-filesystem
./b2 stage -j$(nproc) threading=multi link=static cxxflags="-std=c++11 -fpic" cflags="-fpic"
./b2 install threading=multi link=static --with-system --with-filesystem
rm -rf /tmp/boost-1.82.0

View File

@@ -0,0 +1,137 @@
# List of packages needed for stage1 build
apt-utils
aria2
autoconf
automake
bc
bison
bridge-utils
build-essential
bzip2
check
chrpath
cifs-utils
cpio
curl
devscripts
dkms
dos2unix
fakeroot
flex
freeglut3-dev
g++
g++-multilib
# gawk is needed for aomp
gawk
gcc
gcc-multilib
gfortran
git-lfs
gnupg
graphviz
kernel-wedge
lbzip2
# less is needed by repo
less
libass-dev
libatlas-base-dev
libbabeltrace-ctf-dev
libbabeltrace-dev
libboost-all-dev
libboost-dev
libboost-filesystem-dev
libboost-program-options-dev
libboost-system-dev
libbz2-dev
libc++-dev
libc++1
libc++abi-dev
libc++abi1
libc6-dev-i386
libcap-dev
libcurl4-openssl-dev
libdrm-dev
libdw-dev
libdw1
libdwarf-dev
libelf-dev
libelf1
libexpat1-dev
libfftw3-dev
libfile-find-rule-perl
libgflags-dev
libglew-dev
libgmp-dev
libgoogle-glog-dev
libgtk2.0-dev
libhdf5-serial-dev
libjpeg-dev
libleveldb-dev
liblmdb-dev
liblzma-dev
libmpfr-dev
libmpich-dev
libmsgpack-dev
libncurses5-dev
libnuma-dev
libomp-dev
libopenblas-base
libopenblas-dev
libpci-dev
libpci3
libpciaccess-dev
libpciaccess0
libprotobuf-dev
libpython2.7-dev
libpython3-dev
libreadline-dev
libsnappy-dev
libssl-dev
libsuitesparse-dev
libsystemd-dev
libtinfo-dev
libtool
libunwind-dev
liburi-encode-perl
libva-dev
libvirt-clients
libvirt-daemon-system
libyaml-cpp-dev
llvm
llvm-6.0-dev
llvm-dev
llvm-runtime
mesa-common-dev
mpich
ocaml
ocaml-findlib
patchelf
pigz
pkg-config
protobuf-compiler
python-is-python3
python-pip-whl
python-yaml
python3-dev
python3-pip
python3-venv
python3-yaml
python3.8-dev
re2c
redis-tools
rpm
rsync
ssh
strace
sudo
systemtap-sdt-dev
texinfo
texlive
texlive-extra-utils
texlive-plain-generic
texlive-xetex
unzip
vim
wget
xsltproc
zlib1g-dev

View File

@@ -0,0 +1,9 @@
FROM ubuntu:jammy as builder
COPY packages /tmp/packages
COPY local-pin-600 /tmp/local-pin-600
COPY install-prerequisities.sh /tmp/install-prerequisities.sh
RUN chmod +x /tmp/install-prerequisities.sh
ENV KBUILD_PKG_ROOTCMD=
ENV RPP_DEPS_LOCATION=/usr/local/rpp-deps
RUN /tmp/install-prerequisities.sh
WORKDIR /src

View File

@@ -0,0 +1,26 @@
## Steps to build the Docker Image
1. Clone this repositry
```bash
git clone -b roc-6.1.x https://github.com/ROCm/ROCm.git
```
2. Go into the OS specific docker directory in build-infra
```bash
cd ROCm/rocm-build/docker/ubuntu22
```
3. Build the docker image
```bash
docker build -t <docker Image Name> .
```
replace the `<docker Image Name>` with the new Docker image Name of your choice,
4. After successful build, verify your \<docker Image Name\> in the list all available docker images.
```bash
docker images
```

View File

@@ -0,0 +1,232 @@
#! /usr/bin/bash
set -ex
apt-get -y update
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install --no-install-recommends -y $(sed 's/#.*//' /tmp/packages)
apt-get clean
rm -rf /var/cache/apt/ /var/lib/apt/lists/* /etc/apt/apt.conf.d/01proxy
#Install 2.17.1 version of git as we are seeing issues with 2.25 , where it was not allowing to add git submodules if the user is different for parent git directory
curl -o git.tar.gz https://cdn.kernel.org/pub/software/scm/git/git-2.17.1.tar.gz
tar -zxf git.tar.gz
cd git-*
make prefix=/usr/local all
make prefix=/usr/local install
git --version
#install argparse and CppHeaderParser python modules for roctracer and rocprofiler
#install rocm-docs-core for the docs-as-code project. Only needed on one OS
# CppHeader needs setuptools. setuptools needs wheel.
# Looks like I need them as seperate commands
# Sigh, install both python2 and python 3 version
pip3 install --no-cache-dir setuptools wheel tox
pip3 install --no-cache-dir CppHeaderParser argparse requests lxml barectf recommonmark jinja2==3.0.0 websockets matplotlib numpy scipy minimal msgpack pytest sphinx joblib PyYAML rocm-docs-core cmake==3.25.2 pandas myst-parser
# Allow sudo for everyone user
echo 'ALL ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/everyone
# Install OCaml packages to build LLVM's OCaml bindings to be used in lightning compiler test pipeline
wget -nv https://sourceforge.net/projects/opam.mirror/files/2.1.4/opam-2.1.4-x86_64-linux -O /usr/local/bin/opam
chmod +x /usr/local/bin/opam
opam init --yes --disable-sandboxing
opam install ctypes --yes
# Install and modify git-repo (#!/usr/bin/env python -> #!/usr/bin/env python3)
curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo
chmod a+x /usr/bin/repo
# Build ccache from the source
cd /tmp
git clone https://github.com/ccache/ccache -b v4.7.5
cd ccache
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
make install
cd /tmp
rm -rf ccache
# Install sharp from MLNX_OFED_LINUX as dependency for rccl-rdma-sharp-plugins
cd /var/tmp
mkdir mlnx
wget -O mlnx/tar.tgz https://content.mellanox.com/ofed/MLNX_OFED-24.01-0.3.3.1/MLNX_OFED_LINUX-24.01-0.3.3.1-ubuntu22.04-x86_64.tgz
tar -xz -C mlnx -f mlnx/tar.tgz
apt-key add mlnx/*/RPM-GPG-KEY-Mellanox
echo "deb [arch=amd64] file:$(echo $PWD/mlnx/*/DEBS) ./" > /etc/apt/sources.list.d/sharp.list
apt update
apt install -y sharp
apt clean
rm -rf /var/cache/apt/ /var/lib/apt/lists/* mlnx /etc/apt/sources.list.d/sharp.list
apt update
apt -y install libunwind-dev
apt -y install libgoogle-glog-dev
# Install python3.8 from source
curl -LO https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tar.xz
tar -xvf Python-3.8.13.tar.xz
pwd
ls /var/tmp/
ls Python-3.8.13
mv Python-3.8.13 /opt/
apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev pkg-config make -y
cd /opt/Python-3.8.13/
./configure --enable-optimizations --enable-shared
make
make -j 6
make altinstall
ldconfig /opt/Python3.8.13
python3.8 --version
# roctracer and rocprofiler needs this python3.8
python3.8 -m pip install setuptools wheel
python3.8 -m pip install CppHeaderParser argparse requests lxml PyYAML joblib
#Install older version of hwloc-devel package for rocrtst
curl -lO https://download.open-mpi.org/release/hwloc/v1.11/hwloc-1.11.13.tar.bz2
tar -xvf hwloc-1.11.13.tar.bz2
cd hwloc-1.11.13
./configure
make
make install
cp /usr/local/lib/libhwloc.so.5 /usr/lib
hwloc-info --version
# Install gtest
mkdir -p /tmp/gtest
cd /tmp/gtest
wget https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip -O googletest.zip
unzip googletest.zip
cd googletest-1.14.0/
mkdir build
cd build
cmake ..
make -j$(nproc)
make install
rm -rf /tmp/gtest
## Install gRPC from source
## RDC Pre-requisites
GRPC_ARCHIVE=grpc-1.61.0.tar.gz
mkdir /tmp/grpc
mkdir /usr/grpc
cd /tmp
git clone --recurse-submodules -b v1.61.0 https://github.com/grpc/grpc
cd grpc
mkdir -p build
cd build
cmake -DgRPC_INSTALL=ON -DBUILD_SHARED_LIBS=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr/grpc -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=14 ..
make -j $(nproc) install
rm -rf /tmp/grpc
## rocBLAS Pre-requisites
## Download prebuilt AMD multithreaded (2.0)
## Reference : https://github.com/ROCmSoftwarePlatform/rocBLAS/blob/develop/install.sh#L403
mkdir -p /tmp/blis
cd /tmp/blis
wget -O - https://github.com/amd/blis/releases/download/2.0/aocl-blis-mt-ubuntu-2.0.tar.gz | tar xfz -
mv amd-blis-mt /usr/blis
cd /
rm -rf /tmp/blis
## rocBLAS Pre-requisites(SWDEV-404612)
## Download aocl-linux-aocc-4.0_1_amd64
mkdir -p /tmp/aocl
cd /tmp/aocl
wget -nv https://download.amd.com/developer/eula/aocl/aocl-4-0/aocl-linux-aocc-4.0_1_amd64.deb
apt install ./aocl-linux-aocc-4.0_1_amd64.deb
rm -rf /tmp/aocl
## hipBLAS Pre-requisites
## lapack(3.9.1v)
## Reference https://github.com/ROCmSoftwarePlatform/rocSOLVER/blob/develop/install.sh#L174
lapack_version=3.9.1
lapack_srcdir=lapack-$lapack_version
lapack_blddir=lapack-$lapack_version-bld
mkdir -p /tmp/lapack
cd /tmp/lapack
rm -rf "$lapack_srcdir" "$lapack_blddir"
wget -O - https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v3.9.1.tar.gz | tar xzf -
cmake -H$lapack_srcdir -B$lapack_blddir -DCMAKE_BUILD_TYPE=Release -DCMAKE_Fortran_FLAGS=-fno-optimize-sibling-calls -DBUILD_TESTING=OFF -DCBLAS=ON -DLAPACKE=OFF
make -j$(nproc) -C "$lapack_blddir"
make -C "$lapack_blddir" install
cd $lapack_blddir
cp -r ./include/* /usr/local/include/
cp -r ./lib/* /usr/local/lib
cd /
rm -rf /tmp/lapack
## rocSOLVER Pre-requisites
## FMT(7.1.3v)
## Reference https://github.com/ROCmSoftwarePlatform/rocSOLVER/blob/develop/install.sh#L152
fmt_version=7.1.3
fmt_srcdir=fmt-$fmt_version
fmt_blddir=fmt-$fmt_version-bld
mkdir -p /tmp/fmt
cd /tmp/fmt
rm -rf "$fmt_srcdir" "$fmt_blddir"
wget -O - https://github.com/fmtlib/fmt/archive/refs/tags/7.1.3.tar.gz | tar xzf -
cmake -H$fmt_srcdir -B$fmt_blddir -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_EXTENSIONS=OFF -DCMAKE_CXX_STANDARD_REQUIRED=ON -DFMT_DOC=OFF -DFMT_TEST=OFF
make -j$(nproc) -C "$fmt_blddir"
make -C "$fmt_blddir" install
# Build and install libjpeg-turbo
mkdir -p /tmp/libjpeg-turbo
cd /tmp/libjpeg-turbo
wget -nv https://github.com/rrawther/libjpeg-turbo/archive/refs/heads/2.0.6.2.zip -O libjpeg-turbo-2.0.6.2.zip
unzip libjpeg-turbo-2.0.6.2.zip
cd libjpeg-turbo-2.0.6.2
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_STATIC=FALSE -DCMAKE_INSTALL_DEFAULT_LIBDIR=lib ..
make -j$(nproc) install
rm -rf /tmp/libjpeg-turbo
# Get released ninja from source
mkdir -p /tmp/ninja
cd /tmp/ninja
wget -nv https://codeload.github.com/Kitware/ninja/zip/refs/tags/v1.11.1.g95dee.kitware.jobserver-1 -O ninja.zip
unzip ninja.zip
cd ninja-1.11.1.g95dee.kitware.jobserver-1
./configure.py --bootstrap
cp ninja /usr/local/bin/
rm -rf /tmp/ninja
# Install pre-built FFmpeg and dependencies
# See docker/build-deps for instructions on how to build these packages
wget -qO- https://www.ffmpeg.org/releases/ffmpeg-4.4.2.tar.gz | tar -xzv -C /usr/local
cp /tmp/local-pin-600 /etc/apt/preferences.d
command -v lbzip2
ln -sf $(command -v lbzip2) /usr/local/bin/compressor || ln -sf $(command -v bzip2) /usr/local/bin/compressor
# Install Google Benchmark
mkdir -p /tmp/Gbenchmark
cd /tmp/Gbenchmark
wget -qO- https://github.com/google/benchmark/archive/refs/tags/v1.6.1.tar.gz | tar xz
cmake -Sbenchmark-1.6.1 -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_CXX_STANDARD=14
make -j -C build
cd /tmp/Gbenchmark/build
make install
# Build boost-1.82.0 from source for RPP
# Installing in a non-standard location since the test packages of hipFFT and rocFFT pick up the version of
# the installed Boost library and declare a package dependency on that specific version of Boost.
# For example, if this was installed in the standard location it would declare a dependency on libboost-dev(el)1.82.0
# which is not available as a package in any distro.
# Once this is fixed, we can remove the Boost package from the requirements list and install this
# in the standard location
mkdir -p /tmp/boost-1.82.0
cd /tmp/boost-1.82.0
wget -nv https://sourceforge.net/projects/boost/files/boost/1.82.0/boost_1_82_0.tar.bz2 -O ./boost_1_82_0.tar.bz2
tar -xf boost_1_82_0.tar.bz2 --use-compress-program="/usr/local/bin/compressor"
cd boost_1_82_0
./bootstrap.sh --prefix=${RPP_DEPS_LOCATION} --with-python=python3
./b2 stage -j$(nproc) threading=multi link=shared cxxflags="-std=c++11"
./b2 install threading=multi link=shared --with-system --with-filesystem
./b2 stage -j$(nproc) threading=multi link=static cxxflags="-std=c++11 -fpic" cflags="-fpic"
./b2 install threading=multi link=static --with-system --with-filesystem
rm -rf /tmp/boost-1.82.0

View File

@@ -0,0 +1,3 @@
Package: *
Pin: origin ""
Pin-Priority: 600

View File

@@ -0,0 +1,139 @@
# List of packages needed for stage1 build
apt-utils
aria2
autoconf
automake
bc
bison
bridge-utils
build-essential
bzip2
check
chrpath
cifs-utils
cpio
curl
devscripts
dos2unix
doxygen
fakeroot
flex
freeglut3-dev
g++
g++-multilib
# gawk is needed for aomp
gawk
gcc
gcc-multilib
gfortran
git-lfs
gnupg
googletest-tools
graphviz
grpc-proto
kernel-wedge
# kmod for kernel build
kmod
lbzip2
# less is needed by repo
less
libass-dev
libatlas-base-dev
libbabeltrace-ctf-dev
libbabeltrace-dev
libboost-all-dev
libboost-dev
libboost-filesystem-dev
libboost-program-options-dev
libboost-system-dev
libbz2-dev
libc++-dev
libc++1
libc++abi-dev
libc++abi1
libc6-dev-i386
libcap-dev
libcurl4-openssl-dev
libdrm-dev
libdw-dev
libdw1
libdwarf-dev
libelf-dev
libelf1
libexpat1-dev
libfftw3-dev
libfile-find-rule-perl
libgflags-dev
libglew-dev
libgmp-dev
libgtk2.0-dev
libhdf5-serial-dev
libjpeg-dev
libleveldb-dev
liblmdb-dev
liblzma-dev
libmpfr-dev
libmpich-dev
libmsgpack-dev
libncurses5-dev
libnuma-dev
libomp-dev
libopenblas-base
libopenblas-dev
libpci-dev
libpci3
libpciaccess-dev
libpciaccess0
libprotobuf-dev
libpython2.7-dev
libpython3-dev
libreadline-dev
libsnappy-dev
libssl-dev
libsuitesparse-dev
libsystemd-dev
libtinfo-dev
libtool
liburi-encode-perl
libva-dev
libvirt-clients
libvirt-daemon-system
libyaml-cpp-dev
llvm
llvm-dev
llvm-runtime
mesa-common-dev
mpich
ocaml
ocaml-findlib
patchelf
pigz
pkg-config
protobuf-compiler
python-is-python3
python3-dev
python3-pip
python3-pip-whl
python3-venv
python3-yaml
python3-yaml
python3.8-dev
re2c
redis-tools
# hipclang needs rpm
rpm
rsync
ssh
# This makes life more pleasent inside the container
strace
sudo
systemtap-sdt-dev
texinfo
texlive
texlive-extra-utils
texlive-plain-generic
texlive-xetex
unzip
vim
wget
xsltproc

191
rocm-build/envsetup.sh Executable file
View File

@@ -0,0 +1,191 @@
#!/bin/bash
set_WORK_ROOT(){
[ -n "$WORK_ROOT" ] && return 0
export WORK_ROOT=$PWD
while :; do
[ -d "$WORK_ROOT/.repo/manifests" ] && return 0
WORK_ROOT=$WORK_ROOT/..
( cd -P "$WORK_ROOT" && [ "$PWD" != "/" ] ) || break
done
echo "Unable to find a .repo/manifests directory above '$PWD'" >&2
unset WORK_ROOT # No point in saying we have one when we don't
return 1
}
set_WORK_ROOT || exit 2
if [ "$DASH_JAY" == "" ]; then
if [ -x "$(command -v nproc)" ]; then
export DASH_JAY="-j $(nproc)"
else
export DASH_JAY="-j 4"
fi
fi
export JOB_NAME=release
export JOB_DESIGNATOR=
echo "JOB_DESIGNATOR=${JOB_DESIGNATOR}"
export SLES_BUILD_ID_PREFIX
echo "SLES_BUILD_ID_PREFIX=${SLES_BUILD_ID_PREFIX}"
if [ -z "${BUILD_ID}" ]; then
export BUILD_ID=9999
fi
if [ -n "${JOB_NAME}" ]; then
export ROCM_BUILD_ID=${JOB_NAME/compute-/}-${BUILD_ID}
fi
source /etc/os-release
#re-export the variables with less generic names
export DISTRO_NAME=$ID
export DISTRO_RELEASE=$VERSION_ID
export DISTRO_ID=$ID-$VERSION_ID
case "${DISTRO_NAME}" in
("ubuntu") export CPACKGEN=DEB PACKAGEEXT=deb PKGTYPE=deb ROCM_PKGTYPE=DEB ;;
("centos") export CPACKGEN=RPM PACKAGEEXT=rpm PKGTYPE=rpm ;;
("sles") export CPACKGEN=RPM PACKAGEEXT=rpm PKGTYPE=rpm ;;
("rhel") export CPACKGEN=RPM PACKAGEEXT=rpm PKGTYPE=rpm ;;
("mariner") export CPACKGEN=RPM PACKAGEEXT=rpm PKGTYPE=rpm ;;
esac
# set up package file name variables for CPACK_GENERATOR
# rpm packages name are set with jenkins job designator and build no
# deb package is appendeded with OS version as well
export CPACK_DEBIAN_PACKAGE_RELEASE="${JOB_DESIGNATOR}${SLES_BUILD_ID_PREFIX}${BUILD_ID}~$VERSION_ID"
export CPACK_RPM_PACKAGE_RELEASE="${JOB_DESIGNATOR}${SLES_BUILD_ID_PREFIX}${BUILD_ID}"
OUT_DIR="${OUT_DIR:=$WORK_ROOT/out/$DISTRO_ID/$DISTRO_RELEASE}"
export OUT_DIR
export RT_TMP=$OUT_DIR/tmp/rt
#source transform, for things like ocl_lc
export SRC_TF_ROOT=$OUT_DIR/srctf
# Read ROCm Version and calculate ROCm libpatch version from rocm_version.txt
# Using logic from calculateRocmPatchVersion() in common.gvy
get_rocm_libpatch_version() {
rocm_version=$1
if [[ "${rocm_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
libpatch_version=${rocm_version//\./0}
echo "${libpatch_version}"
else
echo "Invalid ROCm Version: ${rocm_version}"
exit 10
fi
}
# Read the default ROCm version from rocm_version.txt if the ROCM_VERSION
# variable is either not set, empty or only contains spaces.
if [ -f "${WORK_ROOT}/build/rocm_version.txt" ] && [ -z $ROCM_VERSION ]; then
ROCM_VERSION="$(cat ${WORK_ROOT}/build/rocm_version.txt)"
fi
: ${ROCM_VERSION:="6.1.0"}
ROCM_LIBPATCH_VERSION=$(get_rocm_libpatch_version $ROCM_VERSION)
echo "ROCM_VERSION=${ROCM_VERSION}"
echo "ROCM_LIBPATCH_VERSION=${ROCM_LIBPATCH_VERSION}"
export ROCM_VERSION ROCM_LIBPATCH_VERSION
export ROCM_INSTALL_PATH="/opt/rocm-${ROCM_VERSION}-${BUILD_ID}"
# check if the job = release
if [[ "${JOB_NAME}" == *rel* ]]; then
export ROCM_INSTALL_PATH="/opt/rocm-${ROCM_VERSION}"
fi
# Setting the ROCM_INSTALL_PATH id to Last Know Good build ID, PSDB incremental built packages will install into /opt/rocm-<parent build ID>
if [ -n "${LKG_BUILD_ID}" ]; then
export ROCM_INSTALL_PATH="/opt/rocm-${ROCM_VERSION}-${LKG_BUILD_ID}"
fi
echo "Setting ROCM_INSTALL_PATH=${ROCM_INSTALL_PATH}"
export ROCM_PATH="$ROCM_INSTALL_PATH"
export ROCM_LIBPATH=""
export DEVTOOLSET_LIBPATH="/opt/rh/devtoolset-7/root/usr/lib64;/opt/rh/devtoolset-7/root/usr/lib"
# Source directories
# TODO: We should have autodiscoverable makefiles
export DIST_NO_DEBUG=yes
export OPENCL_MAINLINE=1
export HSA_SOURCE_ROOT=$WORK_ROOT/ROCR-Runtime
export HSA_OPENSOURCE_ROOT=$HSA_SOURCE_ROOT/src
export ROCRTST_ROOT=$HSA_SOURCE_ROOT/rocrtst
export HSA_CORE_ROOT=$HSA_OPENSOURCE_ROOT
export HSA_IMAGE_ROOT=$HSA_OPENSOURCE_ROOT/hsa-ext-image
export HSA_FINALIZE_ROOT=$HSA_OPENSOURCE_ROOT/hsa-ext-finalize
export HSA_TOOLS_ROOT=$HSA_OPENSOURCE_ROOT/hsa-runtime-tools
export OCL_RT_SRC_TF_ROOT=$SRC_TF_ROOT/ocl_lc
export SCRIPT_ROOT=$WORK_ROOT/build
export THUNK_ROOT=$WORK_ROOT/ROCT-Thunk-Interface
if [ -d "$HSA_OPENSOURCE_ROOT/ROCT-Thunk-Interface" ]; then
export THUNK_ROOT=$HSA_OPENSOURCE_ROOT/ROCT-Thunk-Interface
fi
export AQLPROFILE_ROOT=$WORK_ROOT/hsa/aqlprofile
export ROCPROFILER_ROOT=$WORK_ROOT/rocprofiler
export ROCTRACER_ROOT=$WORK_ROOT/roctracer
export ROCPROFILER_REGISTER_ROOT=$WORK_ROOT/rocprofiler-register
export RDC_ROOT=$WORK_ROOT/rdc
export RDCTST_ROOT=$RDC_ROOT/tests/rdc_tests
export UTILS_ROOT=$WORK_ROOT/rocm-utils
export KFDTEST_ROOT=$THUNK_ROOT/tests/kfdtest
if [ -d "$HSA_OPENSOURCE_ROOT/tests/kfdtest" ]; then
export KFDTEST_ROOT=$HSA_OPENSOURCE_ROOT/tests/kfdtest
fi
export HIPIFY_ROOT=$WORK_ROOT/HIPIFY
export AMD_SMI_LIB_ROOT=$WORK_ROOT/amdsmi
export ROCM_SMI_LIB_ROOT=$WORK_ROOT/rocm_smi_lib
export RSMITST_ROOT=$ROCM_SMI_LIB_ROOT/tests/rocm_smi_test
export LLVM_PROJECT_ROOT=$WORK_ROOT/llvm-project
export LLVM_ROOT=$LLVM_PROJECT_ROOT/llvm
export CLANG_ROOT=$LLVM_PROJECT_ROOT/clang
export LLD_ROOT=$LLVM_PROJECT_ROOT/lld
export HIPCC_ROOT=$LLVM_PROJECT_ROOT/amd/hipcc
export DEVICELIBS_ROOT=$LLVM_PROJECT_ROOT/amd/device-libs
export ROCM_CORE_ROOT=$WORK_ROOT/rocm-core
export ROCM_CMAKE_ROOT=$WORK_ROOT/rocm-cmake
export ROCM_BANDWIDTH_TEST_ROOT=$WORK_ROOT/rocm_bandwidth_test
export ROCMINFO_ROOT=$WORK_ROOT/rocminfo
export CLANG_OCL_ROOT=$WORK_ROOT/clang-ocl
export ROCR_DEBUG_AGENT_ROOT=$WORK_ROOT/rocr_debug_agent
export COMGR_ROOT=$LLVM_PROJECT_ROOT/amd/comgr
export COMGR_LIB_PATH=$OUT_DIR/build/amd_comgr
export RCCL_ROOT=$WORK_ROOT/rccl
export ROCM_DBGAPI_ROOT=$WORK_ROOT/ROCdbgapi
export ROCM_GDB_ROOT=$WORK_ROOT/ROCgdb
export HIP_ON_ROCclr_ROOT=$WORK_ROOT/HIP
export HIPAMD_ROOT=$WORK_ROOT/hipamd
export HIP_CATCH_TESTS_ROOT=$WORK_ROOT/hip-tests
export CLR_ROOT=$WORK_ROOT/clr
export AOMP_REPOS=$WORK_ROOT/openmp-extras
export HIPOTHER_ROOT=$WORK_ROOT/hipother
# For libraries $ORIGIN
# For binaries $ORIGIN/../lib
export ROCM_LIB_RPATH='$ORIGIN'
export ROCM_EXE_RPATH='$ORIGIN/../lib'
# For ASAN Libraries since the asan lib path is lib/asan/
export ROCM_ASAN_LIB_RPATH='$ORIGIN:$ORIGIN/..'
export ROCM_ASAN_EXE_RPATH="\$ORIGIN/../lib/asan:\$ORIGIN/../lib"
export PATH=$PATH:$SCRIPT_ROOT
# From setup_env.sh
export LIBS_WORK_DIR=$WORK_ROOT
export BUILD_ARTIFACTS=$OUT_DIR/$PACKAGEEXT
export HIPCC_COMPILE_FLAGS_APPEND="-O3 -Wno-format-nonliteral -parallel-jobs=4"
export HIPCC_LINK_FLAGS_APPEND="-O3 -parallel-jobs=4"
export PATH="${ROCM_PATH}/lib/llvm/bin:${PATH}"
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export PROC=${PROC:-"$(nproc)"}
export RELEASE_FLAG=${RELEASE_FLAG:-"-r"}
export SUDO=sudo
export PATH=/usr/local/bin:${PATH}:${HOME}/.local/bin
export CCACHE_DIR=${HOME}/.ccache

82
rocm-build/post_inst_pkg.sh Executable file
View File

@@ -0,0 +1,82 @@
#!/bin/bash
set -x
UNTAR_COMPONENT_NAME=$1
copy_pkg_files_to_rocm() {
local comp_folder=$1
local comp_pkg_name=$2
cd "${OUT_DIR}/${PKGTYPE}/${comp_folder}"|| exit 2
if [ "${PKGTYPE}" = 'deb' ]; then
dpkg-deb -x ${comp_pkg_name}_*.deb pkg/
else
mkdir pkg && pushd pkg/ || exit 2
if [[ "${comp_pkg_name}" != *-dev* ]]; then
rpm2cpio ../${comp_pkg_name}-*.rpm | cpio -idmv
else
rpm2cpio ../${comp_pkg_name}el-*.rpm | cpio -idmv
fi
popd || exit 2
fi
ls ./pkg -alt
${SUDO} cp -r ./pkg${ROCM_PATH}/* "${ROCM_PATH}" || exit 2
rm -rf pkg/
}
get_os_name() {
local os_name
os_name=$(grep -oP '^NAME="\K.*(?=")' < /etc/os-release)
echo "${os_name,,}"
}
set_pkg_type() {
local os_name
os_name=$(grep -oP '^NAME="\K.*(?=")' < /etc/os-release)
[ "${os_name,,}" = ubuntu ] && echo "deb" || echo "rpm"
}
setup_rocm_compilers_hash_file() {
local clang_version
clang_version="$("${ROCM_PATH}/llvm/bin/clang" --version | head -n 1)"
printf '%s: %s\n' 'clang version' "${clang_version}" | tee "${OUT_DIR}/rocm_compilers_hash_file"
}
PKGTYPE=$(set_pkg_type)
case $UNTAR_COMPONENT_NAME in
(lightning)
if [ "${CCACHE_ENABLED}" == "true" ] ; then
setup_rocm_compilers_hash_file
fi
mkdir -p ${ROCM_PATH}/bin
printf '%s\n' > ${ROCM_PATH}/bin/target.lst gfx900 gfx906 gfx908 gfx803 gfx1030
if [ -e "${ROCM_PATH}/lib/llvm/bin/rocm.cfg" ]; then
sed -i '/-frtlib-add-rpath/d' ${ROCM_PATH}/lib/llvm/bin/rocm.cfg
elif [ -e "${ROCM_PATH}/llvm/bin/rocm.cfg" ]; then
sed -i '/-frtlib-add-rpath/d' ${ROCM_PATH}/llvm/bin/rocm.cfg
fi
;;
(hipify_clang)
copy_pkg_files_to_rocm hipify hipify-clang
;;
(hip_on_rocclr)
rm -f ${ROCM_PATH}/bin/hipcc.bat
;;
(openmp_extras)
copy_pkg_files_to_rocm openmp-extras openmp-extras-runtime
copy_pkg_files_to_rocm openmp-extras openmp-extras-dev
;;
(rocblas)
copy_pkg_files_to_rocm rocblas rocblas-dev
;;
(*)
echo "post processing is not required for ${UNTAR_COMPONENT_NAME}"
;;
esac

71
rocm-build/rocm-6.1.0.xml Normal file
View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="rocm-org" fetch="https://github.com/ROCm/" />
<default revision="refs/tags/rocm-6.1.0"
remote="rocm-org"
sync-c="true"
sync-j="4" />
<!--list of projects for ROCm-->
<project name="ROCm" revision="roc-6.1.x" />
<project name="ROCK-Kernel-Driver" />
<project name="ROCT-Thunk-Interface" />
<project name="ROCR-Runtime" />
<project name="amdsmi" />
<project name="rocm_smi_lib" />
<project name="rocm-core" />
<project name="rocm-cmake" />
<project name="rocminfo" />
<project name="rocm_bandwidth_test" />
<project name="rocprofiler" />
<project name="rocprofiler-register" />
<project name="roctracer" />
<project name="clang-ocl" />
<project name="rdc" />
<!--HIP Projects-->
<project name="HIP" />
<project name="hip-tests" />
<project name="HIP-Examples" />
<project name="clr" />
<project name="hipother" />
<project name="HIPIFY" />
<!-- The following projects are all associated with the AMDGPU LLVM compiler -->
<project name="llvm-project" />
<project name="half" />
<!-- gdb projects -->
<project name="ROCgdb" />
<project name="ROCdbgapi" />
<project name="rocr_debug_agent" />
<!-- ROCm Libraries -->
<project groups="mathlibs" name="rocBLAS" />
<project groups="mathlibs" name="Tensile" />
<project groups="mathlibs" name="hipTensor" />
<project groups="mathlibs" name="hipBLAS" />
<project groups="mathlibs" name="hipBLASLt" />
<project groups="mathlibs" name="rocFFT" />
<project groups="mathlibs" name="hipFFT" />
<project groups="mathlibs" name="rocRAND" />
<project groups="mathlibs" name="hipRAND" />
<project groups="mathlibs" name="rocSPARSE" />
<project groups="mathlibs" name="hipSPARSELt" />
<project groups="mathlibs" name="rocSOLVER" />
<project groups="mathlibs" name="hipSOLVER" />
<project groups="mathlibs" name="hipSPARSE" />
<project groups="mathlibs" name="rocALUTION" />
<project groups="mathlibs" name="rocThrust" />
<project groups="mathlibs" name="hipCUB" />
<project groups="mathlibs" name="rocPRIM" />
<project groups="mathlibs" name="rocWMMA" />
<project groups="mathlibs" name="rccl" />
<project groups="mathlibs" name="MIOpen" />
<project groups="mathlibs" name="MIVisionX" />
<project groups="mathlibs" name="ROCmValidationSuite" />
<project groups="mathlibs" name="composable_kernel" />
<project groups="mathlibs" name="hipfort" />
<project groups="mathlibs" name="rocDecode" />
<project groups="mathlibs" name="AMDMIGraphX" />
<project groups="mathlibs" name="rpp" />
<!-- Projects for OpenMP-Extras -->
<project name="aomp" path="openmp-extras/aomp" />
<project name="aomp-extras" path="openmp-extras/aomp-extras" />
<project name="flang" path="openmp-extras/flang" />
</manifest>

71
rocm-build/rocm-6.1.1.xml Normal file
View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="rocm-org" fetch="https://github.com/ROCm/" />
<default revision="refs/tags/rocm-6.1.1"
remote="rocm-org"
sync-c="true"
sync-j="4" />
<!--list of projects for ROCm-->
<project name="ROCm" revision="roc-6.1.x" />
<project name="ROCK-Kernel-Driver" />
<project name="ROCT-Thunk-Interface" />
<project name="ROCR-Runtime" />
<project name="amdsmi" />
<project name="rocm_smi_lib" />
<project name="rocm-core" />
<project name="rocm-cmake" />
<project name="rocminfo" />
<project name="rocm_bandwidth_test" />
<project name="rocprofiler" />
<project name="rocprofiler-register" />
<project name="roctracer" />
<project name="clang-ocl" />
<project name="rdc" />
<!--HIP Projects-->
<project name="HIP" />
<project name="hip-tests" />
<project name="HIP-Examples" />
<project name="clr" />
<project name="hipother" />
<project name="HIPIFY" />
<!-- The following projects are all associated with the AMDGPU LLVM compiler -->
<project name="llvm-project" />
<project name="half" />
<!-- gdb projects -->
<project name="ROCgdb" />
<project name="ROCdbgapi" />
<project name="rocr_debug_agent" />
<!-- ROCm Libraries -->
<project groups="mathlibs" name="rocBLAS" />
<project groups="mathlibs" name="Tensile" />
<project groups="mathlibs" name="hipTensor" />
<project groups="mathlibs" name="hipBLAS" />
<project groups="mathlibs" name="hipBLASLt" />
<project groups="mathlibs" name="rocFFT" />
<project groups="mathlibs" name="hipFFT" />
<project groups="mathlibs" name="rocRAND" />
<project groups="mathlibs" name="hipRAND" />
<project groups="mathlibs" name="rocSPARSE" />
<project groups="mathlibs" name="hipSPARSELt" />
<project groups="mathlibs" name="rocSOLVER" />
<project groups="mathlibs" name="hipSOLVER" />
<project groups="mathlibs" name="hipSPARSE" />
<project groups="mathlibs" name="rocALUTION" />
<project groups="mathlibs" name="rocThrust" />
<project groups="mathlibs" name="hipCUB" />
<project groups="mathlibs" name="rocPRIM" />
<project groups="mathlibs" name="rocWMMA" />
<project groups="mathlibs" name="rccl" />
<project groups="mathlibs" name="MIOpen" />
<project groups="mathlibs" name="MIVisionX" />
<project groups="mathlibs" name="ROCmValidationSuite" />
<project groups="mathlibs" name="composable_kernel" />
<project groups="mathlibs" name="hipfort" />
<project groups="mathlibs" name="rocDecode" />
<project groups="mathlibs" name="AMDMIGraphX" />
<project groups="mathlibs" name="rpp" />
<!-- Projects for OpenMP-Extras -->
<project name="aomp" path="openmp-extras/aomp" />
<project name="aomp-extras" path="openmp-extras/aomp-extras" />
<project name="flang" path="openmp-extras/flang" />
</manifest>

71
rocm-build/rocm-6.1.2.xml Normal file
View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="rocm-org" fetch="https://github.com/ROCm/" />
<default revision="refs/tags/rocm-6.1.2"
remote="rocm-org"
sync-c="true"
sync-j="4" />
<!--list of projects for ROCm-->
<project name="ROCm" revision="bb-test-rocm-build" />
<project name="ROCK-Kernel-Driver" />
<project name="ROCT-Thunk-Interface" />
<project name="ROCR-Runtime" />
<project name="amdsmi" />
<project name="rocm_smi_lib" />
<project name="rocm-core" />
<project name="rocm-cmake" />
<project name="rocminfo" />
<project name="rocm_bandwidth_test" />
<project name="rocprofiler" />
<project name="rocprofiler-register" />
<project name="roctracer" />
<project name="clang-ocl" />
<project name="rdc" />
<!--HIP Projects-->
<project name="HIP" />
<project name="hip-tests" />
<project name="HIP-Examples" />
<project name="clr" />
<project name="hipother" />
<project name="HIPIFY" />
<!-- The following projects are all associated with the AMDGPU LLVM compiler -->
<project name="llvm-project" />
<project name="half" />
<!-- gdb projects -->
<project name="ROCgdb" />
<project name="ROCdbgapi" />
<project name="rocr_debug_agent" />
<!-- ROCm Libraries -->
<project groups="mathlibs" name="rocBLAS" />
<project groups="mathlibs" name="Tensile" />
<project groups="mathlibs" name="hipTensor" />
<project groups="mathlibs" name="hipBLAS" />
<project groups="mathlibs" name="hipBLASLt" />
<project groups="mathlibs" name="rocFFT" />
<project groups="mathlibs" name="hipFFT" />
<project groups="mathlibs" name="rocRAND" />
<project groups="mathlibs" name="hipRAND" />
<project groups="mathlibs" name="rocSPARSE" />
<project groups="mathlibs" name="hipSPARSELt" />
<project groups="mathlibs" name="rocSOLVER" />
<project groups="mathlibs" name="hipSOLVER" />
<project groups="mathlibs" name="hipSPARSE" />
<project groups="mathlibs" name="rocALUTION" />
<project groups="mathlibs" name="rocThrust" />
<project groups="mathlibs" name="hipCUB" />
<project groups="mathlibs" name="rocPRIM" />
<project groups="mathlibs" name="rocWMMA" />
<project groups="mathlibs" name="rccl" />
<project groups="mathlibs" name="MIOpen" />
<project groups="mathlibs" name="MIVisionX" />
<project groups="mathlibs" name="ROCmValidationSuite" />
<project groups="mathlibs" name="composable_kernel" />
<project groups="mathlibs" name="hipfort" />
<project groups="mathlibs" name="rocDecode" />
<project groups="mathlibs" name="AMDMIGraphX" />
<project groups="mathlibs" name="rpp" />
<!-- Projects for OpenMP-Extras -->
<project name="aomp" path="openmp-extras/aomp" />
<project name="aomp-extras" path="openmp-extras/aomp-extras" />
<project name="flang" path="openmp-extras/flang" />
</manifest>

32
rocm-build/upload_packages.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
set -x
BUILD_COMPONENT="$1"
PACKAGEEXT=${PACKAGEEXT:-$2}
COMP_DIR=$(./${INFRA_REPO}/build/build_${BUILD_COMPONENT}.sh -o ${PACKAGEEXT})
TARGET_ARTI_URL=${TARGET_ARTI_URL:-$3}
[ -z "$JFROG_TOKEN" ] && echo "JFrog token is not set, skip uploading..." && exit 0
[ -z "$TARGET_ARTI_URL" ] && echo "Target URL is not set, skip uploading..." && exit 0
[ -z "$COMP_DIR" ] && echo "No packages in ${BUILD_COMPONENT}" && exit 0
[ ! -d "$COMP_DIR" ] && echo "NO ${COMP_DIR} folder..." && exit 0
PKG_NAME_LIST=( "${COMP_DIR}"/* )
for pkg in "${PKG_NAME_LIST[@]}"; do
if [[ "${ENABLE_ADDRESS_SANITIZER}" != "true" ]] || [[ "${pkg##*/}" =~ "-asan" ]]; then
echo "Uploading $pkg ..."
if ! curl -f -H "X-JFrog-Art-Api:${JFROG_TOKEN}" \
-X PUT "${TARGET_ARTI_URL}/$(basename ${pkg})" \
-T "${COMP_DIR}/$(basename ${pkg})"; then
echo "Unable to upload $pkg ..." >&2 && exit 1
fi
echo "$pkg uploaded..."
fi
done