From b12f6b300017bfb6fa6c1127329349ac987f9b43 Mon Sep 17 00:00:00 2001 From: Matthias Krack Date: Wed, 16 Oct 2024 14:48:04 +0200 Subject: [PATCH] =?UTF-8?q?Add=20toolchain=20flag=20--with-amd=20to=20faci?= =?UTF-8?q?litate=20builds=20with=20the=20AMD=20AOCC=20=E2=80=A6=20(#3725)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arch/Linux-amd-x86_64.ssmp | 175 ++++++++++++++++++ tools/toolchain/install_cp2k_toolchain.sh | 29 ++- .../toolchain/scripts/generate_arch_files.sh | 34 ++-- tools/toolchain/scripts/stage0/install_amd.sh | 90 +++++++++ .../scripts/stage0/install_stage0.sh | 1 + .../scripts/stage0/setup_buildtools.sh | 7 +- 6 files changed, 316 insertions(+), 20 deletions(-) create mode 100644 arch/Linux-amd-x86_64.ssmp create mode 100755 tools/toolchain/scripts/stage0/install_amd.sh diff --git a/arch/Linux-amd-x86_64.ssmp b/arch/Linux-amd-x86_64.ssmp new file mode 100644 index 0000000000..b6f951a3b7 --- /dev/null +++ b/arch/Linux-amd-x86_64.ssmp @@ -0,0 +1,175 @@ +#!/bin/bash +# +# CP2K AMD arch file for a serial x86_64 binary +# +# Tested with: AMD AOCC 5.0.0 +# +# Usage: Source this arch file and then run make as instructed. +# +# Last update: 15.10.2024 +# +# \ + if [[ "${0}" == "${BASH_SOURCE}" ]]; then \ + echo "ERROR: Script ${0##*/} must be sourced"; \ + echo "Usage: source ${0##*/}"; \ + exit 1; \ + fi; \ + this_file=${BASH_SOURCE##*/}; \ + cd tools/toolchain; \ + rm -rf build; \ + [[ -z "${target_cpu}" ]] && target_cpu="native"; \ + ./install_cp2k_toolchain.sh -j${maxtasks} --mpi-mode=no --no-arch-files --target-cpu=${target_cpu} --with-amd --with-dftd4=no; \ + source ./install/setup; \ + cd ../..; \ + echo; \ + echo "Check the output above for error messages and consistency!"; \ + echo; \ + echo "If everything is OK, you can build a CP2K production binary with"; \ + echo " make -j ARCH=${this_file%.*} VERSION=${this_file##*.} TARGET_CPU=${target_cpu}"; \ + echo "Further checks are performed, if DO_CHECKS=yes is added."; \ + echo; \ + return + +# Set options +DO_CHECKS := no +TARGET_CPU := native + +# Retrieve package versions +AMD_VER := $(shell clang -dumpversion) +#USE_DFTD4 := $(DFTD4_VER) +USE_FFTW := $(FFTW_VER) +USE_LIBGRPP := $(LIBGRPP_VER) +USE_LIBINT := $(LIBINT_VER) +USE_LIBVORI := $(LIBVORI_VER) +USE_LIBXC := $(LIBXC_VER) +USE_LIBXSMM := $(LIBXSMM_VER) +USE_OPENBLAS := $(OPENBLAS_VER) +USE_SPGLIB := $(SPGLIB_VER) + +LMAX := 5 +MAX_CONTR := 4 + +CC := clang +CXX := clang++ +FC := flang +LD := flang +AR := ar -r + +ifeq ($(TARGET_CPU), generic) + CFLAGS := -O2 -fPIC -fopenmp -g -mtune=$(TARGET_CPU) +else + CFLAGS := -O2 -fPIC -fopenmp -g -march=$(TARGET_CPU) -mtune=$(TARGET_CPU) +endif +CFLAGS += -mllvm -enable-newgvn=true + +DFLAGS += -D__MAX_CONTR=$(strip $(MAX_CONTR)) + +INSTALL_PATH := $(PWD)/tools/toolchain/install + +# Settings for regression testing +ifeq ($(DO_CHECKS), yes) + DFLAGS += -D__CHECK_DIAG +endif + +ifneq ($(USE_LIBVORI),) + USE_LIBVORI := $(strip $(USE_LIBVORI)) + LIBVORI_LIB := $(INSTALL_PATH)/libvori-$(USE_LIBVORI)/lib + DFLAGS += -D__LIBVORI + LIBS += $(LIBVORI_LIB)/libvori.a +endif + +ifneq ($(USE_LIBXC),) + USE_LIBXC := $(strip $(USE_LIBXC)) + LIBXC_INC := $(INSTALL_PATH)/libxc-$(USE_LIBXC)/include + LIBXC_LIB := $(INSTALL_PATH)/libxc-$(USE_LIBXC)/lib + CFLAGS += -I$(LIBXC_INC) + DFLAGS += -D__LIBXC + LIBS += $(LIBXC_LIB)/libxcf03.a + LIBS += $(LIBXC_LIB)/libxc.a +endif + +ifneq ($(USE_DFTD4),) + USE_DFTD4 := $(strip $(USE_DFTD4)) + DFTD4_INC := $(INSTALL_PATH)/dftd4-$(USE_DFTD4)/include + DFTD4_LIB := $(INSTALL_PATH)/dftd4-$(USE_DFTD4)/lib64 + CFLAGS += -I$(DFTD4_INC)/dftd4/AMD-$(AMD_VER) + DFLAGS += -D__DFTD4 + LIBS += $(DFTD4_LIB)/libdftd4.a + LIBS += $(DFTD4_LIB)/libmstore.a + LIBS += $(DFTD4_LIB)/libmulticharge.a + LIBS += $(DFTD4_LIB)/libmctc-lib.a +endif + +ifneq ($(USE_LIBGRPP),) + USE_LIBGRPP := $(strip $(USE_LIBGRPP)) + LIBGRPP_INC := $(INSTALL_PATH)/libgrpp-main-$(USE_LIBGRPP)/include + LIBGRPP_LIB := $(INSTALL_PATH)/libgrpp-main-$(USE_LIBGRPP)/lib + CFLAGS += -I$(LIBGRPP_INC) + DFLAGS += -D__LIBGRPP + LIBS += $(LIBGRPP_LIB)/liblibgrpp.a +endif + +ifneq ($(USE_LIBINT),) + USE_LIBINT := $(strip $(USE_LIBINT)) + LMAX := $(strip $(LMAX)) + LIBINT_INC := $(INSTALL_PATH)/libint-v$(USE_LIBINT)-cp2k-lmax-$(LMAX)/include + LIBINT_LIB := $(INSTALL_PATH)/libint-v$(USE_LIBINT)-cp2k-lmax-$(LMAX)/lib + CFLAGS += -I$(LIBINT_INC) + DFLAGS += -D__LIBINT + LIBS += $(LIBINT_LIB)/libint2.a +endif + +ifneq ($(USE_SPGLIB),) + USE_SPGLIB := $(strip $(USE_SPGLIB)) + SPGLIB_INC := $(INSTALL_PATH)/spglib-$(USE_SPGLIB)/include + SPGLIB_LIB := $(INSTALL_PATH)/spglib-$(USE_SPGLIB)/lib + CFLAGS += -I$(SPGLIB_INC) + DFLAGS += -D__SPGLIB + LIBS += $(SPGLIB_LIB)/libsymspg.a +endif + +ifneq ($(USE_LIBXSMM),) + USE_LIBXSMM := $(strip $(USE_LIBXSMM)) + LIBXSMM_INC := $(INSTALL_PATH)/libxsmm-$(USE_LIBXSMM)/include + LIBXSMM_LIB := $(INSTALL_PATH)/libxsmm-$(USE_LIBXSMM)/lib + CFLAGS += -I$(LIBXSMM_INC) + DFLAGS += -D__LIBXSMM + ifeq ($(SHARED), yes) + LIBS += -Wl,-rpath=$(LIBXSMM_LIB) -L$(LIBXSMM_LIB) -lxsmmf -lxsmmext -lxsmm + else + LIBS += $(LIBXSMM_LIB)/libxsmmf.a + LIBS += $(LIBXSMM_LIB)/libxsmmext.a + LIBS += $(LIBXSMM_LIB)/libxsmm.a + endif +endif + +ifneq ($(USE_FFTW),) + USE_FFTW := $(strip $(USE_FFTW)) + FFTW_INC := $(INSTALL_PATH)/fftw-$(USE_FFTW)/include + FFTW_LIB := $(INSTALL_PATH)/fftw-$(USE_FFTW)/lib + CFLAGS += -I$(FFTW_INC) + DFLAGS += -D__FFTW3 + LIBS += $(FFTW_LIB)/libfftw3_omp.a + LIBS += $(FFTW_LIB)/libfftw3.a +endif + +ifneq ($(USE_OPENBLAS),) + USE_OPENBLAS := $(strip $(USE_OPENBLAS)) + OPENBLAS_INC := $(INSTALL_PATH)/openblas-$(USE_OPENBLAS)/include + OPENBLAS_LIB := $(INSTALL_PATH)/openblas-$(USE_OPENBLAS)/lib + CFLAGS += -I$(OPENBLAS_INC) + LIBS += $(OPENBLAS_LIB)/libopenblas.a +endif + +CFLAGS += $(DFLAGS) $(CFLAGS_DEBUG) + +FCFLAGS := $(CFLAGS) $(FCFLAGS_DEBUG) $(WFLAGS) +FCFLAGS += -ffree-form +FCFLAGS += -Mbackslash + +LDFLAGS += $(FCFLAGS) +LDFLAGS_C := -fno-fortran-main + +LIBS += -Wl,--whole-archive -lpthread -ldl -Wl,--no-whole-archive -lstdc++ + +# End diff --git a/tools/toolchain/install_cp2k_toolchain.sh b/tools/toolchain/install_cp2k_toolchain.sh index 0ad36b44e9..77f223dee2 100755 --- a/tools/toolchain/install_cp2k_toolchain.sh +++ b/tools/toolchain/install_cp2k_toolchain.sh @@ -146,12 +146,14 @@ The --with-PKG options follow the rules: --with-PKG The option keyword alone will be equivalent to --with-PKG=install - --with-gcc The GCC compiler to use to compile CP2K. + --with-gcc Use the GNU compiler to build CP2K. Default = system - --with-intel Use the Intel compiler to compile CP2K. + --with-intel Use the Intel compiler to build CP2K. Default = system --with-ifx Use the new Intel Fortran compiler ifx instead of ifort to compile CP2K. Default = no + --with-amd Use the AMD compiler to build CP2K. + Default = system --with-cmake Cmake utilities Default = install --with-ninja Ninja utilities @@ -269,7 +271,7 @@ EOF # PACKAGE LIST: register all new dependent tools and libs here. Order # is important, the first in the list gets installed first # ------------------------------------------------------------------------ -tool_list="gcc intel cmake ninja" +tool_list="gcc intel amd cmake ninja" mpi_list="mpich openmpi intelmpi" math_list="mkl acml openblas" lib_list="fftw libint libxc libgrpp libxsmm cosma scalapack elpa cusolvermp plumed \ @@ -344,6 +346,7 @@ if (command -v mpiexec > /dev/null 2>&1); then elif (mpiexec --version 2>&1 | grep -s -q "Intel"); then echo "MPI is detected and it appears to be Intel MPI" with_gcc="__DONTUSE__" + with_amd="__DONTUSE__" with_intel="__SYSTEM__" with_intelmpi="__SYSTEM__" export MPI_MODE="intelmpi" @@ -387,6 +390,7 @@ if [ "${CRAY_LD_LIBRARY_PATH}" ]; then export MPI_MODE="mpich" # set default value for some installers appropriate for CLE with_gcc="__DONTUSE__" + with_amd="__DONTUSE__" with_intel="__DONTUSE__" with_fftw="__SYSTEM__" with_scalapack="__DONTUSE__" @@ -424,7 +428,9 @@ while [ $# -ge 1 ]; do --install-all) # set all package to the default installation status for ii in ${package_list}; do - if [ "${ii}" != "intel" ] && [ "${ii}" != "intelmpi" ]; then + if [ "${ii}" != "intel" ] && + [ "${ii}" != "intelmpi" ] && + [ "${ii}" != "amd" ]; then eval with_${ii}="__INSTALL__" fi done @@ -572,6 +578,9 @@ while [ $# -ge 1 ]; do export MPI_MODE=intelmpi fi ;; + --with-amd*) + with_amd=$(read_with "${1}" "__SYSTEM__") + ;; --with-ifx*) with_ifx=$(read_with "${1}" "yes") ;; @@ -702,9 +711,17 @@ export ENABLE_CRAY="${enable_cray}" # ------------------------------------------------------------------------ # Compiler conflicts if [ "${with_intel}" != "__DONTUSE__" ] && [ "${with_gcc}" = "__INSTALL__" ]; then - echo "You have chosen to use the Intel compiler, therefore the installation of the GCC compiler will be skipped." + echo "You have chosen to use the Intel compiler, therefore the installation of the GNU compiler will be skipped." with_gcc="__SYSTEM__" fi +if [ "${with_amd}" != "__DONTUSE__" ] && [ "${with_gcc}" = "__INSTALL__" ]; then + echo "You have chosen to use the AMD compiler, therefore the installation of the GNU compiler will be skipped." + with_gcc="__SYSTEM__" +fi +if [ "${with_amd}" != "__DONTUSE__" ] && [ "${with_intel}" != "__DONTUSE__" ]; then + report_error "You have chosen to use the AMD and the Intel compiler. Select only one compiler." + exit 1 +fi # MPI library conflicts if [ "${MPI_MODE}" = "no" ]; then if [ "${with_scalapack}" != "__DONTUSE__" ]; then @@ -738,7 +755,7 @@ if [ "${MPI_MODE}" = "no" ]; then else # if gcc is installed, then mpi needs to be installed too if [ "${with_gcc}" = "__INSTALL__" ]; then - echo "You have chosen to install the GCC compiler, therefore MPI libraries have to be installed too" + echo "You have chosen to install the GNU compiler, therefore MPI libraries have to be installed too" case ${MPI_MODE} in mpich) with_mpich="__INSTALL__" diff --git a/tools/toolchain/scripts/generate_arch_files.sh b/tools/toolchain/scripts/generate_arch_files.sh index b48c526f1d..fbb91c57c3 100755 --- a/tools/toolchain/scripts/generate_arch_files.sh +++ b/tools/toolchain/scripts/generate_arch_files.sh @@ -43,6 +43,14 @@ if [ "${with_intel}" != "__DONTUSE__" ]; then fi OPT_FLAGS="-O2 -funroll-loops" LDFLAGS_C="-nofor-main" +elif [ "${with_amd}" != "__DONTUSE__" ]; then + if [ "${TARGET_CPU}" = "generic" ]; then + BASEFLAGS="-fPIC -fopenmp -g -mtune=${TARGET_CPU}" + else + BASEFLAGS="-fPIC -fopenmp -g -march=${TARGET_CPU} -mtune=${TARGET_CPU}" + fi + OPT_FLAGS="-O2 -mllvm -enable-newgvn=true" + LDFLAGS_C="-fno-fortran-main" else if [ "${TARGET_CPU}" = "generic" ]; then BASEFLAGS="-fno-omit-frame-pointer -fopenmp -g -mtune=${TARGET_CPU} IF_ASAN(-fsanitize=address|)" @@ -56,12 +64,12 @@ fi NOOPT_FLAGS="-O1" # those flags that do not influence code generation are used always, the others if debug -if [ "${with_intel}" != "__DONTUSE__" ]; then - FCDEB_FLAGS="" - FCDEB_FLAGS_DEBUG="" -else +if [ "${with_intel}" == "__DONTUSE__" ] && [ "${with_amd}" == "__DONTUSE__" ]; then FCDEB_FLAGS="-fbacktrace -ffree-form -fimplicit-none -std=f2008" FCDEB_FLAGS_DEBUG="-fsanitize=leak -fcheck=all,no-array-temps -ffpe-trap=invalid,zero,overflow -finit-derived -finit-real=snan -finit-integer=-42 -Werror=realloc-lhs -finline-matmul-limit=0" +else + FCDEB_FLAGS="" + FCDEB_FLAGS_DEBUG="" fi # code coverage generation flags @@ -86,7 +94,7 @@ IEEE_EXCEPTIONS_DFLAGS="-D__HAS_IEEE_EXCEPTIONS" # check all of the above flags, filter out incompatible flags for the # current version of gcc in use -if [ "${with_intel}" == "__DONTUSE__" ]; then +if [ "${with_intel}" == "__DONTUSE__" ] && [ "${with_amd}" == "__DONTUSE__" ]; then OPT_FLAGS=$(allowed_gfortran_flags $OPT_FLAGS) NOOPT_FLAGS=$(allowed_gfortran_flags $NOOPT_FLAGS) FCDEB_FLAGS=$(allowed_gfortran_flags $FCDEB_FLAGS) @@ -117,7 +125,7 @@ G_CFLAGS="$BASEFLAGS" G_CFLAGS="$G_CFLAGS IF_COVERAGE($COVERAGE_FLAGS|IF_DEBUG($NOOPT_FLAGS|$OPT_FLAGS))" G_CFLAGS="$G_CFLAGS IF_DEBUG(|$PROFOPT_FLAGS)" G_CFLAGS="$G_CFLAGS $CP_CFLAGS" -if [ "${with_intel}" == "__DONTUSE__" ]; then +if [ "${with_intel}" == "__DONTUSE__" ] && [ "${with_amd}" == "__DONTUSE__" ]; then # FCFLAGS, for gfortran FCFLAGS="$G_CFLAGS \$(FCDEBFLAGS) \$(WFLAGS) \$(DFLAGS)" FCFLAGS+=" IF_MPI($(allowed_gfortran_flags "-fallow-argument-mismatch")|)" @@ -128,9 +136,7 @@ fi # TODO: Remove -Wno-vla-parameter after upgrade to gcc 11.3. # https://gcc.gnu.org/bugzilla//show_bug.cgi?id=101289 -if [ "${with_intel}" == "__DONTUSE__" ]; then - CFLAGS="$G_CFLAGS -std=c11 -Wall -Wextra -Werror -Wno-vla-parameter -Wno-deprecated-declarations \$(DFLAGS)" -else +if [ "${with_intel}" != "__DONTUSE__" ]; then if [ "${with_ifx}" == "no" ]; then CC_arch+=" IF_MPI(-cc=${I_MPI_CC}|)" CXX_arch+=" IF_MPI(-cxx=${I_MPI_CXX}|)" @@ -143,6 +149,10 @@ else # Suppress warnings and add include path to omp_lib.mod explicitly. # No clue why the Intel oneAPI setup script does not include that path (bug?) FCFLAGS="${FCFLAGS} -diag-disable=10448 -I/opt/intel/oneapi/2024.1/opt/compiler/include/intel64" +elif [ "${with_amd}" != "__DONTUSE__" ]; then + CFLAGS="$G_CFLAGS -std=c11 -Wall \$(DFLAGS)" +else + CFLAGS="$G_CFLAGS -std=c11 -Wall -Wextra -Werror -Wno-vla-parameter -Wno-deprecated-declarations \$(DFLAGS)" fi # Linker flags @@ -155,7 +165,7 @@ LDFLAGS="IF_STATIC(${STATIC_FLAGS}|) \$(FCFLAGS) ${CP_LDFLAGS}" # add standard libs LIBS="${CP_LIBS} -lstdc++" -if [ "${with_intel}" == "__DONTUSE__" ]; then +if [ "${with_intel}" == "__DONTUSE__" ] && [ "${with_amd}" == "__DONTUSE__" ]; then CXXFLAGS+=" --std=c++14 \$(DFLAGS) -Wno-deprecated-declarations" else CXXFLAGS+=" --std=c++14 \$(DFLAGS)" @@ -410,7 +420,7 @@ EOF rm -f ${INSTALLDIR}/arch/local* # normal production arch files -if [ "${with_intel}" != "__DONTUSE__" ]; then +if [ "${with_intel}" != "__DONTUSE__" ] || [ "${with_amd}" != "__DONTUSE__" ]; then gen_arch_file "local.ssmp" gen_arch_file "local.sdbg" DEBUG else @@ -423,7 +433,7 @@ fi arch_vers="ssmp sdbg" if [ "$MPI_MODE" != no ]; then - if [ "${with_intel}" != "__DONTUSE__" ]; then + if [ "${with_intel}" != "__DONTUSE__" ] || [ "${with_amd}" != "__DONTUSE__" ]; then gen_arch_file "local.psmp" MPI gen_arch_file "local.pdbg" MPI DEBUG else diff --git a/tools/toolchain/scripts/stage0/install_amd.sh b/tools/toolchain/scripts/stage0/install_amd.sh new file mode 100755 index 0000000000..84fa7d9cd3 --- /dev/null +++ b/tools/toolchain/scripts/stage0/install_amd.sh @@ -0,0 +1,90 @@ +#!/bin/bash -e + +# TODO: Review and if possible fix shellcheck errors. +# shellcheck disable=all + +[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=${0} +SCRIPT_DIR="$(cd "$(dirname "${SCRIPT_NAME}")/.." && pwd -P)" + +source "${SCRIPT_DIR}"/common_vars.sh +source "${SCRIPT_DIR}"/tool_kit.sh +source "${SCRIPT_DIR}"/signal_trap.sh +source "${INSTALLDIR}"/toolchain.conf +source "${INSTALLDIR}"/toolchain.env + +[ -f "${BUILDDIR}/setup_amd" ] && rm "${BUILDDIR}/setup_amd" + +AMD_CFLAGS="" +AMD_LDFLAGS="" +AMD_LIBS="" +mkdir -p "${BUILDDIR}" +cd "${BUILDDIR}" + +case "${with_amd}" in + __INSTALL__) + echo "==================== Installing the AMD compiler ======================" + echo "__INSTALL__ is not supported; please install the AMD compiler manually" + exit 1 + ;; + __SYSTEM__) + echo "==================== Finding AMD compiler from system paths ====================" + check_command clang "amd" && CC="$(realpath $(command -v clang))" || exit 1 + check_command clang++ "amd" && CXX="$(realpath $(command -v clang++))" || exit 1 + check_command flang "amd" && FC="$(realpath $(command -v flang))" || exit 1 + F90="${FC}" + F77="${FC}" + ;; + __DONTUSE__) + # Nothing to do + ;; + *) + echo "==================== Linking AMD compiler to user paths ====================" + pkg_install_dir="${with_amd}" + check_dir "${pkg_install_dir}/bin" + check_dir "${pkg_install_dir}/lib" + check_dir "${pkg_install_dir}/include" + check_command ${pkg_install_dir}/bin/clang "amd" && CC="${pkg_install_dir}/bin/clang" || exit 1 + check_command ${pkg_install_dir}/bin/clang++ "amd" && CXX="${pkg_install_dir}/bin/clang++" || exit 1 + check_command ${pkg_install_dir}/bin/flang "amd" && FC="${pkg_install_dir}/bin/flang" || exit 1 + F90="${FC}" + F77="${FC}" + AMD_CFLAGS="-I'${pkg_install_dir}/include'" + AMD_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath,'${pkg_install_dir}/lib'" + ;; +esac +if [ "${with_amd}" != "__DONTUSE__" ]; then + echo "CC is ${CC}" + [ $(realpath $(command -v clang) | grep -e aocc-compiler) ] || echo "Check the AMD C compiler path" + echo "CXX is ${CXX}" + [ $(realpath $(command -v clang++) | grep -e aocc-compiler) ] || echo "Check the AMD C++ compiler path" + echo "FC is ${FC}" + [ $(realpath $(command -v flang) | grep -e aocc-compiler) ] || echo "Check the AMD Fortran compiler path" + cat << EOF > "${BUILDDIR}/setup_amd" +export CC="${CC}" +export CXX="${CXX}" +export FC="${FC}" +export F90="${F90}" +export F77="${F77}" +EOF + if [ "${with_amd}" != "__SYSTEM__" ]; then + cat << EOF >> "${BUILDDIR}/setup_amd" +prepend_path PATH "${pkg_install_dir}/bin" +prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" +prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" +prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" +prepend_path CPATH "${pkg_install_dir}/include" +EOF + fi + cat << EOF >> "${BUILDDIR}/setup_amd" +export AMD_CFLAGS="${AMD_CFLAGS}" +export AMD_LDFLAGS="${AMD_LDFLAGS}" +export AMD_LIBS="${AMD_LIBS}" +EOF + cat "${BUILDDIR}/setup_amd" >> ${SETUPFILE} +fi + +load "${BUILDDIR}/setup_amd" +write_toolchain_env "${INSTALLDIR}" + +cd "${ROOTDIR}" +report_timing "amd" diff --git a/tools/toolchain/scripts/stage0/install_stage0.sh b/tools/toolchain/scripts/stage0/install_stage0.sh index 57e5438a9f..332ca920c8 100755 --- a/tools/toolchain/scripts/stage0/install_stage0.sh +++ b/tools/toolchain/scripts/stage0/install_stage0.sh @@ -5,6 +5,7 @@ ./scripts/stage0/install_gcc.sh ./scripts/stage0/install_intel.sh +./scripts/stage0/install_amd.sh ./scripts/stage0/setup_buildtools.sh ./scripts/stage0/install_cmake.sh ./scripts/stage0/install_ninja.sh diff --git a/tools/toolchain/scripts/stage0/setup_buildtools.sh b/tools/toolchain/scripts/stage0/setup_buildtools.sh index 0d502ff29b..3b2456af4e 100755 --- a/tools/toolchain/scripts/stage0/setup_buildtools.sh +++ b/tools/toolchain/scripts/stage0/setup_buildtools.sh @@ -29,6 +29,9 @@ if [ "${with_intel}" != "__DONTUSE__" ]; then CFLAGS="${CFLAGS} -mtune=${TARGET_CPU}" fi FFLAGS="${CFLAGS}" +elif [ "${with_amd}" != "__DONTUSE__" ]; then + CFLAGS="-O2 -fPIC -fopenmp -g -mtune=${TARGET_CPU}" + FFLAGS="${CFLAGS}" else CFLAGS="-O2 -fPIC -fno-omit-frame-pointer -fopenmp -g -mtune=${TARGET_CPU} ${TSANFLAGS}" FFLAGS="${CFLAGS} -fbacktrace" @@ -38,7 +41,7 @@ F77FLAGS="${FFLAGS}" F90FLAGS="${FFLAGS}" FCFLAGS="${FFLAGS}" -if [ "${with_intel}" == "__DONTUSE__" ]; then +if [ "${with_intel}" == "__DONTUSE__" ] && [ "${with_amd}" == "__DONTUSE__" ]; then export CFLAGS="$(allowed_gcc_flags ${CFLAGS})" export FFLAGS="$(allowed_gfortran_flags ${FFLAGS})" export F77FLAGS="$(allowed_gfortran_flags ${F77FLAGS})" @@ -46,7 +49,7 @@ if [ "${with_intel}" == "__DONTUSE__" ]; then export FCFLAGS="$(allowed_gfortran_flags ${FCFLAGS})" export CXXFLAGS="$(allowed_gxx_flags ${CXXFLAGS})" else - # TODO Check functions for allowed Intel compiler flags + # TODO Check functions for allowed Intel or AMD compiler flags export CFLAGS export FFLAGS export F77FLAGS