Skip to content

Commit

Permalink
Update ARM64 arch file for Apple M1 (Ventura)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrack committed Nov 15, 2022
1 parent d600294 commit fdee58b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 28 deletions.
35 changes: 15 additions & 20 deletions arch/Darwin-aarch64.ssmp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#
# CP2K Darwin arch file for a serial aarch64 (arm64) binary
#
# Tested with: GNU 12.2.0, FFTW 3.3.10, LIBINT 2.6.0,
# Tested with: GNU 12.2.0, FFTW 3.3.10, LIBINT 2.6.0, LIBVORI 220621,
# LIBXC 6.0.0, OpenBLAS 0.3.21, SPGLIB 1.16.2
# on: Apple M1 (macOS Monterey 12.4)
# on: Apple M1 (macOS Ventura 13.0.1)
#
# Usage: Source this arch file and then run make as instructed.
#
# Author: Matthias Krack (19.10.2022)
# Author: Matthias Krack (16.11.2022)
#
# \
if [[ "${0}" == "${BASH_SOURCE}" ]]; then \
Expand All @@ -18,17 +18,15 @@
fi; \
this_file=${BASH_SOURCE##*/}; \
cd tools/toolchain; \
if $(command -v brew >&- 2>&-); then \
if $(command -v brew >/dev/null 2>&1); then \
brew install cmake; \
brew install gcc; \
brew install fftw; \
brew install openblas; \
else \
echo "ERROR: Homebrew installation not found"; \
cd ../..; \
return 1; \
fi; \
./install_cp2k_toolchain.sh -j8 --mpi-mode=no --no-arch-files --with-cmake=system --with-gcc=system --with-fftw=system --with-libvori=no --with-libxsmm=no --with-openblas=system; \
./install_cp2k_toolchain.sh -j8 --mpi-mode=no --no-arch-files --with-cmake=system --with-gcc=system --with-libxsmm=no; \
source ./install/setup; \
cd ../..; \
echo; \
Expand All @@ -41,11 +39,12 @@

# Set options
DO_CHECKS := no
USE_ACCELERATE := no
TARGET_CPU := native
USE_FFTW := 3.3.10
USE_LIBINT := 2.6.0
#USE_LIBVORI := 220621
USE_LIBVORI := 220621
USE_LIBXC := 6.0.0
USE_OPENBLAS := 0.3.21
USE_SPGLIB := 1.16.2

LMAX := 5
Expand All @@ -57,7 +56,7 @@ FC := gfortran
LD := gfortran
AR := ar -r -s

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))
DFLAGS += -D__NO_STATM_ACCESS
Expand Down Expand Up @@ -130,22 +129,18 @@ endif

ifneq ($(USE_FFTW),)
USE_FFTW := $(strip $(USE_FFTW))
FFTW_ROOT := /opt/homebrew
FFTW_INC := $(FFTW_ROOT)/include
FFTW_LIB := $(FFTW_ROOT)/lib
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

ifeq ($(USE_ACCELERATE), yes)
DFLAGS += -D__ACCELERATE
LIBS += -framework Accelerate
else
OPENBLAS_ROOT := /opt/homebrew
OPENBLAS_INC := $(OPENBLAS_ROOT)/include
OPENBLAS_LIB := $(OPENBLAS_ROOT)/lib
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
Expand Down
2 changes: 1 addition & 1 deletion tools/toolchain/install_cp2k_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ with_spla="__DONTUSE__"
with_cosma="__INSTALL__"
with_libvori="__INSTALL__"
# for MPI, we try to detect system MPI variant
if (command -v mpirun >&- 2>&-); then
if (command -v mpirun > /dev/null 2>&1); then
# check if we are dealing with openmpi, mpich or intelmpi
if (mpirun --version 2>&1 | grep -s -q "HYDRA"); then
echo "MPI is detected and it appears to be MPICH"
Expand Down
2 changes: 1 addition & 1 deletion tools/toolchain/scripts/stage1/install_mpich.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ case "${with_mpich}" in
echo "==================== Finding MPICH from system paths ===================="
check_command mpirun "mpich" && MPIRUN="$(command -v mpirun)" || exit 1
check_command mpicc "mpich" && MPICC="$(command -v mpicc)" || exit 1
if [ $(command -v mpic++ >&- 2>&-) ]; then
if [ $(command -v mpic++ > /dev/null 2>&1) ]; then
check_command mpic++ "mpich" && MPICXX="$(command -v mpic++)" || exit 1
else
check_command mpicxx "mpich" && MPICXX="$(command -v mpicxx)" || exit 1
Expand Down
12 changes: 6 additions & 6 deletions tools/toolchain/scripts/tool_kit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ reverse() (
get_nprocs() {
if [ -n "${NPROCS_OVERWRITE}" ]; then
echo ${NPROCS_OVERWRITE} | sed 's/^0*//'
elif $(command -v nproc >&- 2>&-); then
elif $(command -v nproc > /dev/null 2>&1); then
echo $(nproc --all)
else
echo 1
Expand Down Expand Up @@ -337,7 +337,7 @@ check_command() {
elif [ $# -gt 1 ]; then
local __package=${2}
fi
if $(command -v ${__command} >&- 2>&-); then
if $(command -v ${__command} > /dev/null 2>&1); then
echo "path to ${__command} is $(command -v ${__command})"
else
report_error "Cannot find ${__command}, please check if the package ${__package} is installed or in system search path"
Expand All @@ -364,7 +364,7 @@ check_install() {
elif [ $# -gt 1 ]; then
local __package=${2}
fi
if $(command -v ${__command} >&- 2>&-); then
if $(command -v ${__command} > /dev/null 2>&1); then
echo "$(basename ${__command}) is installed as $(command -v ${__command})"
else
report_error "cannot find ${__command}, please check if the package ${__package} has been installed correctly"
Expand Down Expand Up @@ -607,7 +607,7 @@ checksum() {
local __shasum_command='sha256sum'
# check if we have sha256sum command, Mac OS X does not have
# sha256sum, but has an equivalent with shasum -a 256
command -v "$__shasum_command" >&- 2>&- ||
command -v "$__shasum_command" > /dev/null 2>&1 ||
__shasum_command="shasum -a 256"
if echo "$__sha256 $__filename" | ${__shasum_command} --check; then
echo "Checksum of $__filename Ok"
Expand Down Expand Up @@ -640,7 +640,7 @@ verify_checksums() {

# check if we have sha256sum command, Mac OS X does not have
# sha256sum, but has an equivalent with shasum -a 256
command -v "$__shasum_command" >&- 2>&- ||
command -v "$__shasum_command" > /dev/null 2>&1 ||
__shasum_command="shasum -a 256"

${__shasum_command} --check "${__checksum_file}" > /dev/null 2>&1
Expand All @@ -654,7 +654,7 @@ write_checksums() {

# check if we have sha256sum command, Mac OS X does not have
# sha256sum, but has an equivalent with shasum -a 256
command -v "$__shasum_command" >&- 2>&- ||
command -v "$__shasum_command" > /dev/null 2>&1 ||
__shasum_command="shasum -a 256"

${__shasum_command} "${VERSION_FILE}" "$@" > "${__checksum_file}"
Expand Down

0 comments on commit fdee58b

Please sign in to comment.