From 9f9ab9c0002ee2233a4e86697b515ff0fa2669a8 Mon Sep 17 00:00:00 2001 From: Kent Knox Date: Thu, 24 Mar 2016 16:12:57 -0500 Subject: [PATCH] Updated hcc dockerfiles hcc-hsail has a new github address hcc-isa includes new instructions to compile in amdphdrs roc-setup updated with new command line options for removing images and dry-runs --- hcc-hsail/hcc-hsail-dockerfile.template | 4 +- hcc-isa/hcc-isa-dockerfile.template | 13 ++++ roc-setup.sh | 79 +++++++++++++++++++++---- 3 files changed, 84 insertions(+), 12 deletions(-) diff --git a/hcc-hsail/hcc-hsail-dockerfile.template b/hcc-hsail/hcc-hsail-dockerfile.template index b41992a..0207b80 100644 --- a/hcc-hsail/hcc-hsail-dockerfile.template +++ b/hcc-hsail/hcc-hsail-dockerfile.template @@ -51,7 +51,7 @@ ENV PATH ${PATH}:${HCC_INSTALL_PATH}/bin # Build hcc, install to /usr/local RUN mkdir -p ${HCC_BUILD_PATH} && \ cd ${HCC_BUILD_PATH} && \ - git clone --depth=1 --branch=~~branch~~ https://bitbucket.org/multicoreware/hcc.git ./ && \ + git clone --depth=1 --branch=~~branch~~ https://github.com/RadeonOpenCompute/hcc.git ./ && \ mkdir -p build && \ cd build && \ cmake \ @@ -66,3 +66,5 @@ RUN mkdir -p ${HCC_BUILD_PATH} && \ cd ~ && rm -rf ${HCC_BUILD_PATH} && \ echo "${HCC_INSTALL_PATH}/lib" >> /etc/ld.so.conf.d/hcc.conf && \ ldconfig + +# VOLUME [${HCC_INSTALL_PATH}] diff --git a/hcc-isa/hcc-isa-dockerfile.template b/hcc-isa/hcc-isa-dockerfile.template index fa05f01..aa39af0 100644 --- a/hcc-isa/hcc-isa-dockerfile.template +++ b/hcc-isa/hcc-isa-dockerfile.template @@ -55,6 +55,16 @@ RUN mkdir -p ${HCC_BUILD_PATH} && \ -DCMAKE_BUILD_TYPE=~~config~~ \ -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" .. && \ make -j $(nproc) install && \ + + cd ../../llvm-amdgpu-assembler-extra/ && \ + mkdir -p build && \ + cd build && \ + cmake \ + -DCMAKE_INSTALL_PREFIX=${HCC_INSTALL_PATH} \ + -DCMAKE_BUILD_TYPE=~~config~~ \ + -DLLVM_DIR="${HCC_BUILD_PATH}/llvm/build" .. && \ + make -j $(nproc) install && \ + cd ../../hcc && \ mkdir -p build && \ cd build && \ @@ -63,9 +73,12 @@ RUN mkdir -p ${HCC_BUILD_PATH} && \ -DCMAKE_BUILD_TYPE=~~config~~ \ -DHSA_LLVM_BIN_DIR=${HCC_INSTALL_PATH}/bin \ -DHSA_AMDGPU_GPU_TARGET=fiji \ + -DAMDPHDRS_DIR=${HCC_BUILD_PATH}/llvm-amdgpu-assembler-extra/build/amdphdrs/ \ -DHSA_USE_AMDGPU_BACKEND=ON .. && \ make -j $(nproc) world && \ make install && \ rm -rf ${HCC_BUILD_PATH} && \ echo "${HCC_INSTALL_PATH}/lib" >> /etc/ld.so.conf.d/hcc-isa.conf && \ ldconfig + +# VOLUME [${HCC_INSTALL_PATH}] diff --git a/roc-setup.sh b/roc-setup.sh index be9e512..4b0e83f 100755 --- a/roc-setup.sh +++ b/roc-setup.sh @@ -3,6 +3,9 @@ # Set reasonable defaults for dockerfile builds # Default: --master, --release +# ################################################# +# Initialization of command line parameters +# ################################################# # Build dockerfiles from more stable master branches; exclusive with --develop build_master=1 @@ -15,16 +18,32 @@ build_release=1 # Build debug binaries; this leaves build tree intact for greater debugging; exclusive with --release build_debug= +# Build debug binaries; this leaves build tree intact for greater debugging; exclusive with --release +remove_images= + +# Build debug binaries; this leaves build tree intact for greater debugging; exclusive with --release +dry_run= + +# ################################################# +# helper functions +# ################################################# function display_help() { echo "Building ROC docker images from templates" echo "Usage: ./roc-setup [--master | --develop] [--release | --debug]" + echo "Default flags: --master --release" + echo "" echo "--master) Build dockerfiles from stable master branches; exclusive with --develop" echo "--develop) Build dockerfiles from integration branches; exclusive with --master" echo "--release) Build release containers; minimizes size of docker images; exclusive with --debug" echo "--debug) Build debug containers; symbols generated and build tree intact for debugging; exclusive with --release" + echo "--remove_images) Based on the other flags passed, remove the docker images instead of building them" + echo "--dry_run) Print out what would happen with the script, without executing commands" } +# ################################################# +# Start of main +# ################################################# while :; do case $1 in --master) @@ -43,6 +62,12 @@ while :; do build_release= build_debug=1 ;; + --remove_images) + remove_images=1 + ;; + --dry_run) + dry_run=1 + ;; -h|--help) display_help exit @@ -100,22 +125,54 @@ rocr_docker_build="${rocr_docker_build} | sed s/~~config~~/${build_config}/g -" hcc_hsail_docker_build="${hcc_hsail_docker_build} | sed s/~~config~~/${build_config}/g -" hcc_isa_docker_build="${hcc_isa_docker_build} | sed s/~~config~~/${build_config}/g -" -# Uncomment below to debug individual dockerfile templates; generated dockerfile is printed to screen +# Uncomment below to print dockerfiles with template substitutions; debugging #eval ${rock_docker_build} #eval ${roct_docker_build} #eval ${rocr_docker_build} #eval ${hcc_hsail_docker_build} #eval ${hcc_isa_docker_build} -rock_docker_build="${rock_docker_build} | docker build -t ${rock_name} -" -roct_docker_build="${roct_docker_build} | docker build -t ${roct_name} -" -rocr_docker_build="${rocr_docker_build} | docker build -t ${rocr_name} -" -hcc_hsail_docker_build="${hcc_hsail_docker_build} | docker build -t ${hcc_hsail_name} -" -hcc_isa_docker_build="${hcc_isa_docker_build} | docker build -t ${hcc_isa_name} -" +# Build or remove docker images based on passed in option +if [ -n "${remove_images}" ]; then + rock_docker_build="docker rmi ${rock_name}" + roct_docker_build="docker rmi ${roct_name}" + rocr_docker_build="docker rmi ${rocr_name}" + hcc_hsail_docker_build="docker rmi ${hcc_hsail_name}" + hcc_isa_docker_build="docker rmi ${hcc_isa_name}" +else + rock_docker_build="${rock_docker_build} | docker build -t ${rock_name} -" + roct_docker_build="${roct_docker_build} | docker build -t ${roct_name} -" + rocr_docker_build="${rocr_docker_build} | docker build -t ${rocr_name} -" + hcc_hsail_docker_build="${hcc_hsail_docker_build} | docker build -t ${hcc_hsail_name} -" + hcc_isa_docker_build="${hcc_isa_docker_build} | docker build -t ${hcc_isa_name} -" +fi # These statements below generate the actual docker images -eval ${rock_docker_build} -eval ${roct_docker_build} -eval ${rocr_docker_build} -eval ${hcc_hsail_docker_build} -eval ${hcc_isa_docker_build} +if [ -n "${dry_run}" ]; then + echo ${rock_docker_build} + echo ${roct_docker_build} + echo ${rocr_docker_build} + echo ${hcc_hsail_docker_build} + echo ${hcc_isa_docker_build} +else + echo "# #################################################" + echo "# Building ROCK container" + echo "# #################################################" + eval ${rock_docker_build} + echo "# #################################################" + echo "# Building ROCT container" + echo "# #################################################" + eval ${roct_docker_build} + echo "# #################################################" + echo "# Building ROCR container" + echo "# #################################################" + eval ${rocr_docker_build} + echo "# #################################################" + echo "# Building HCC-HSAIL container" + echo "# #################################################" + eval ${hcc_hsail_docker_build} + echo "# #################################################" + echo "# Building HCC-ISA container" + echo "# #################################################" + eval ${hcc_isa_docker_build} +fi