From a0cdf692cd55050f0fbe9cd4a119774c4495a998 Mon Sep 17 00:00:00 2001 From: alazzaro Date: Tue, 14 Sep 2021 01:16:13 -0500 Subject: [PATCH] Change HIP flags for DBCSR to use OFFLOAD_FLAGS --- INSTALL.md | 18 +++++++++--------- exts/Makefile.inc | 2 ++ exts/build_dbcsr/Makefile | 8 -------- exts/build_dbcsr/README.md | 3 --- tools/toolchain/scripts/arch_base.tmpl | 1 + 5 files changed, 12 insertions(+), 20 deletions(-) delete mode 100644 exts/build_dbcsr/README.md diff --git a/INSTALL.md b/INSTALL.md index 5fe5a32103..f09700245d 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -180,13 +180,14 @@ the FFTW3 threading library libfftw3_threads (or libfftw3_omp) is required. - Specify OFFLOAD_CC (e.g. `OFFLOAD_CC = nvcc`) and OFFLOAD_FLAGS (e.g. `OFFLOAD_FLAGS = -O3 -g -w --std=c++11`) variables. + Remember to include the support for the C++11 standard. - Use the `-D__DBCSR_ACC` and `OFFLOAD_TARGET=cuda` to enable accelerator support for matrix multiplications. - Add `-lstdc++ -lcudart -lnvrtc -lcuda -lcublas` to LIBS. - Specify the GPU type (e.g. `GPUVER = P100`), possible values are K20X, K40, K80, P100, V100. -- Specify the C++ compiler (e.g. `CXX = g++`). Remember to set the flags to - support C++11 standard. +- Specify the C++ compiler (e.g. `CXX = g++`) and the CXXFLAGS to support + the C++11 standard. - Use `-D__PW_CUDA` for CUDA support for PW (gather/scatter/fft) calculations. - CUFFT 7.0 has a known bug and is therefore disabled by default. NVIDIA's webpage list a patch (an upgraded version cufft i.e. >= 7.0.35) - @@ -329,12 +330,12 @@ The code for the grid backend was developed and tested on Mi100 but should work out of the box on Nvidia hardware as well. - USE `-D__GRID_HIP` to enable AMD GPU support for collocate and integrate - runtines. + rountines. - Add `GPUVER=Mi50, Mi60, Mi100` -- Add 'OFFLOAD_CC = hipcc' +- Add `OFFLOAD_CC = hipcc` - Add `-lamdhip64` to the `LIBS` variable - Add `OFFLOAD_FLAGS ='-fopenmp -m64 -pthread -fPIC -D__GRID_HIP -O2 - --offload-arch=gfx908 --rocm-path=$(ROCM_PATH)`' where 'ROCM_PATH' is the path + --offload-arch=gfx908 --rocm-path=$(ROCM_PATH)'` where `ROCM_PATH` is the path where the rocm sdk resides. Architectures Mi100 (gfx908), Mi50 (gfx906) - the hip backend for the grid library supports nvidia hardware as well. It uses the same code and can be used to validate the backend in case of access to @@ -342,11 +343,10 @@ out of the box on Nvidia hardware as well. and set the `OFFLOAD_FLAGS` with right `nvcc` parameters (see the cuda section of this document). The environment variable `HIP_PLATFORM` should be set to `HIP_PLATFORM=nvidia` to indicate to hipcc to use the nvcc compiler instead. +- Specify the C++ compiler (e.g. `CXX = g++`). Remember to set the + CXXFLAGS flags to support C++11 standard. - When the HIP backend is enabled for DBCSR using `-D__DBCSR_ACC`, then add - `-D__HIP_PLATFORM_AMD__` to `CXXFLAGS` and `OFFLOAD_TARGET=hip` - in the CP2K arch file. - DBCSR will then be built with `CXX` and `CXXFLAGS` and avoid linking with - multiple conflicting OpenMP runtimes. + `-D__HIP_PLATFORM_AMD__` to `CXXFLAGS` and `OFFLOAD_TARGET=hip`. - Use `-D__OFFLOAD_PROFILING` to turn on the AMD ROC TX and Tracer libray. It requires to link `-lroctx64 -lroctracer64`. diff --git a/exts/Makefile.inc b/exts/Makefile.inc index 4fd00540cf..e93ce01799 100644 --- a/exts/Makefile.inc +++ b/exts/Makefile.inc @@ -24,6 +24,8 @@ DBCSR_ACCFLAGS := $(OFFLOAD_FLAGS) else ifeq (hip,$(DBCSR_USE_ACCEL)) DBCSR_ACC := $(CXX) DBCSR_ACCFLAGS := $(CXXFLAGS) +else +$(error "Invalid OFFLOAD_TARGET=$(OFFLOAD_TARGET)") endif endif diff --git a/exts/build_dbcsr/Makefile b/exts/build_dbcsr/Makefile index 6582e98ba2..e6832e0905 100644 --- a/exts/build_dbcsr/Makefile +++ b/exts/build_dbcsr/Makefile @@ -8,15 +8,8 @@ # For this reason, this Makefile must be compatible with the CP2K # compilation and tested within CP2K. # -# You can compile DBCSR by running from the DBCSR main directory with: -# -# > make -f .cp2k/Makefile ARCH= -# -# where we provide an ARCH file as described in the CP2K installation. -# # The ARCH file can set the variables: # -# CXX => C++ compiler, e.g. g++ or mpicxx # CC => C compiler, e.g. gcc or mpicc # FC => Fortran compiler, e.g. gfortran or mpifort # LD => Linker, e.g. gfortran or mpifort @@ -117,7 +110,6 @@ endif else ifeq (hip,$(USE_ACCEL)) override ACCFLAGS += -D__HIP FCFLAGS += -D__HIP -CXXFLAGS += -D__HIP # OpenCL backend else ifeq (opencl,$(USE_ACCEL)) CFLAGS += -D__OPENCL diff --git a/exts/build_dbcsr/README.md b/exts/build_dbcsr/README.md deleted file mode 100644 index f70b6fe5bb..0000000000 --- a/exts/build_dbcsr/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# This directory is used for the inclusion of the DBCSR library in CP2K - -It is not supported by DBCSR development diff --git a/tools/toolchain/scripts/arch_base.tmpl b/tools/toolchain/scripts/arch_base.tmpl index 9cc5927c7c..99994cd61a 100644 --- a/tools/toolchain/scripts/arch_base.tmpl +++ b/tools/toolchain/scripts/arch_base.tmpl @@ -11,6 +11,7 @@ WFLAGS = ${WFLAGS} FCDEBFLAGS = ${FCDEBFLAGS} CFLAGS = ${CFLAGS} FCFLAGS = ${FCFLAGS} +CXXFLAGS = ${CXXFLAGS} # LDFLAGS = ${LDFLAGS} LIBS = ${LIBS}