Skip to content

Commit

Permalink
Enable toolchain build for target CPU
Browse files Browse the repository at this point in the history
- toolchain flag --target-cpu=<cpu> added to facilitate cross-compilation
- toolchain flag --generic removed, --target-cpu=generic can be used instead
- the default toolchain build is --target-cpu=native as before (host CPU)
- Docker and arch files updated correspondingly
  • Loading branch information
mkrack committed Oct 1, 2022
1 parent a1070fe commit 270e00f
Show file tree
Hide file tree
Showing 38 changed files with 68 additions and 54 deletions.
7 changes: 5 additions & 2 deletions arch/Linux-gnu-aarch64-static.ssmp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
exit 1; \
fi; \
this_file=${BASH_SOURCE##*/}; \
./install_cp2k_toolchain.sh --mpi-mode=no --no-arch-files --with-gcc=system --with-cmake=system; \
cd tools/toolchain; \
[[ -z "${target_cpu}" ]] && target_cpu="native"; \
./install_cp2k_toolchain.sh --mpi-mode=no --no-arch-files --target-cpu=${target_cpu} --with-gcc=system --with-cmake=system; \
source ./install/setup; \
cd ../..; \
echo; \
Expand All @@ -28,6 +30,7 @@

# Set options
DO_CHECKS := no
TARGET_CPU := native
USE_FFTW := 3.3.10
USE_LIBINT := 2.6.0
USE_LIBVORI := 220621
Expand All @@ -44,7 +47,7 @@ FC := gfortran
LD := gfortran
AR := ar -r

CFLAGS := -O2 -fopenmp -fopenmp-simd -ftree-vectorize -funroll-loops -g -mtune=native
CFLAGS := -O2 -fopenmp -fopenmp-simd -ftree-vectorize -funroll-loops -g -mtune=$(TARGET_CPU)

DFLAGS += -D__MAX_CONTR=$(strip $(MAX_CONTR))

Expand Down
7 changes: 5 additions & 2 deletions arch/Linux-gnu-aarch64.psmp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
fi; \
this_file=${BASH_SOURCE##*/}; \
cd tools/toolchain; \
./install_cp2k_toolchain.sh --install-all --no-arch-files --with-gcc --with-mpich; \
[[ -z "${mpi_implementation}" ]] && mpi_implementation="mpich"; \
[[ -z "${target_cpu}" ]] && target_cpu="native"; \
./install_cp2k_toolchain.sh --install-all --no-arch-files --target-cpu=${target_cpu} --with-gcc --with-${mpi_implementation}; \
source ./install/setup; \
cd ../..; \
echo; \
Expand All @@ -38,6 +40,7 @@
# Set options
DO_CHECKS := no
SHARED := no
TARGET_CPU := native
USE_COSMA := 2.6.2
USE_ELPA := 2021.11.002
USE_FFTW := 3.3.10
Expand Down Expand Up @@ -69,7 +72,7 @@ FC := mpif90
LD := mpif90
AR := ar -r

CFLAGS := -O2 -fopenmp -fopenmp-simd -ftree-vectorize -funroll-loops -g -mtune=native
CFLAGS := -O2 -fopenmp -fopenmp-simd -ftree-vectorize -funroll-loops -g -mtune=$(TARGET_CPU)

DFLAGS := -D__parallel
DFLAGS += -D__SCALAPACK
Expand Down
24 changes: 6 additions & 18 deletions arch/Linux-gnu-x86_64-static.ssmp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# LIBXC 5.2.3, OpenBLAS 0.3.21, SPGLIB 1.16.2
#
# Usage: Source this arch file and then run make as instructed.
# Add "generic" as argument to compile for a generic x86_64 target.
#
# Author: Matthias Krack (30.09.2022)
#
Expand All @@ -18,27 +17,20 @@
fi; \
this_file=${BASH_SOURCE##*/}; \
cd tools/toolchain; \
if [[ "${1}" == "generic" ]]; then \
./install_cp2k_toolchain.sh --generic --mpi-mode=no --no-arch-files --with-gcc=install; \
else \
./install_cp2k_toolchain.sh --mpi-mode=no --no-arch-files --with-gcc=install; \
fi; \
[[ -z "${target_cpu}" ]] && target_cpu="native"; \
./install_cp2k_toolchain.sh --mpi-mode=no --no-arch-files --target-cpu=${target_cpu} --with-gcc; \
source ./install/setup; \
cd ../..; \
echo; \
echo "Check the output above for error messages and consistency!"; \
echo "If everything is OK, you can build a CP2K production binary with"; \
if [[ "${1}" == "generic" ]]; then \
echo " make -j ARCH=${this_file%.*} VERSION=${this_file##*.} GENERIC=yes"; \
else \
echo " make -j ARCH=${this_file%.*} VERSION=${this_file##*.}"; \
fi; \
echo "Further checks are performed, if DO_CHECKS=yes is added."; \
echo " make -j ARCH=${this_file%.*} VERSION=${this_file##*.}"; \
echo "Further checks are performed, if DO_CHECKS=yes is added, but this disables static linking."; \
return

# Set options
DO_CHECKS := no
GENERIC := no
TARGET_CPU := native
USE_FFTW := 3.3.10
USE_LIBINT := 2.6.0
USE_LIBVORI := 220621
Expand All @@ -55,11 +47,7 @@ FC := gfortran
LD := gfortran
AR := ar -r

ifeq ($(GENERIC), yes)
CFLAGS := -O2 -fopenmp -fopenmp-simd -ftree-vectorize -funroll-loops -g -mtune=generic
else
CFLAGS := -O2 -fopenmp -fopenmp-simd -ftree-vectorize -funroll-loops -g -mtune=native
endif
CFLAGS := -O2 -fopenmp -fopenmp-simd -ftree-vectorize -funroll-loops -g -mtune=$(TARGET_CPU)

DFLAGS += -D__MAX_CONTR=$(strip $(MAX_CONTR))

Expand Down
12 changes: 7 additions & 5 deletions arch/Linux-gnu-x86_64.psmp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# Usage: Source this arch file and then run make as instructed.
# A full toolchain installation is performed as default.
# Optionally, GNU compiler and MPICH version can be specified as arguments.
# Optionally, GNU compiler and MPI implementation can be specified as arguments.
# Replace or adapt the "module add" commands below if needed.
#
# Author: Matthias Krack (30.09.2022)
Expand All @@ -24,18 +24,19 @@
this_file=${BASH_SOURCE##*/}; \
cd tools/toolchain; \
[[ -z "${mpi_implementation}" ]] && mpi_implementation="mpich"; \
[[ -z "${target_cpu}" ]] && target_cpu="native"; \
if [[ -n "${1}" ]]; then \
module add ${1}; \
if [[ -n "${2}" ]]; then \
module add ${2}; \
module list; \
./install_cp2k_toolchain.sh --install-all --no-arch-files --with-gcc=system --with-${mpi_implementation}=system; \
./install_cp2k_toolchain.sh --install-all --no-arch-files --target-cpu=${target_cpu} --with-gcc=system --with-${mpi_implementation}=system; \
else \
module list; \
./install_cp2k_toolchain.sh --install-all --no-arch-files --with-gcc=system --with-${mpi_implementation}; \
./install_cp2k_toolchain.sh --install-all --no-arch-files --target-cpu=${target_cpu} --with-gcc=system --with-${mpi_implementation}; \
fi; \
else \
./install_cp2k_toolchain.sh --install-all --no-arch-files --with-gcc --with-${mpi_implementation}; \
./install_cp2k_toolchain.sh --install-all --no-arch-files --target-cpu=${target_cpu} --with-gcc --with-${mpi_implementation}; \
fi; \
source ./install/setup; \
cd ../..; \
Expand All @@ -54,6 +55,7 @@
# Set options
DO_CHECKS := no
SHARED := no
TARGET_CPU := native
USE_COSMA := 2.6.2
USE_ELPA := 2021.11.002
USE_FFTW := 3.3.10
Expand Down Expand Up @@ -85,7 +87,7 @@ FC := mpif90
LD := mpif90
AR := ar -r

CFLAGS := -O2 -fopenmp -fopenmp-simd -ftree-vectorize -funroll-loops -g -mtune=native
CFLAGS := -O2 -fopenmp -fopenmp-simd -ftree-vectorize -funroll-loops -g -mtune=$(TARGET_CPU)

DFLAGS := -D__parallel
DFLAGS += -D__SCALAPACK
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.prod_generic_pdbg
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=generic \
--with-gcc=system \
--generic \
--dry-run

# Dry-run leaves behind config files for the followup install scripts.
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.prod_generic_psmp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=generic \
--with-gcc=system \
--generic \
--dry-run

# Dry-run leaves behind config files for the followup install scripts.
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.prod_generic_sdbg
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=generic \
--with-gcc=system \
--generic \
--dry-run

# Dry-run leaves behind config files for the followup install scripts.
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.prod_generic_ssmp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=generic \
--with-gcc=system \
--generic \
--dry-run

# Dry-run leaves behind config files for the followup install scripts.
Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.prod_pdbg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.prod_psmp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.prod_sdbg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.prod_ssmp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_aiida
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_asan-psmp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_asan-ssmp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_ase
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_conventions
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_coverage-pdbg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_coverage-sdbg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_generic_pdbg
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=generic \
--with-gcc=system \
--generic \
--dry-run

# Dry-run leaves behind config files for the followup install scripts.
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_generic_psmp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=generic \
--with-gcc=system \
--generic \
--dry-run

# Dry-run leaves behind config files for the followup install scripts.
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_generic_sdbg
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=generic \
--with-gcc=system \
--generic \
--dry-run

# Dry-run leaves behind config files for the followup install scripts.
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/Dockerfile.test_generic_ssmp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=generic \
--with-gcc=system \
--generic \
--dry-run

# Dry-run leaves behind config files for the followup install scripts.
Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_gromacs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_i-pi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_manual
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_minimal
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_openmpi-psmp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=openmpi \
--target-cpu=native \
--with-gcc=install \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_pdbg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_performance
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_psmp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down
1 change: 1 addition & 0 deletions tools/docker/Dockerfile.test_sdbg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--install-all \
--mpi-mode=mpich \
--target-cpu=native \
--with-gcc=system \
--dry-run

Expand Down

0 comments on commit 270e00f

Please sign in to comment.