-
Notifications
You must be signed in to change notification settings - Fork 0
/
Darwin-gnu-arm64.ssmp
194 lines (173 loc) · 6.57 KB
/
Darwin-gnu-arm64.ssmp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/bin/bash
#
# CP2K Darwin arch file for a serial arm64 binary
# (https://www.cp2k.org/howto:compile_on_macos)
#
# Tested with: GNU 14.2.0 on an Apple M1 (macOS 15.1 Sequoia)
#
# Usage: Source this arch file and then run make as instructed.
# Ensure the links in /opt/homebrew/bin to the gcc version.
#
# Last update: 03.11.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"; \
if $(command -v brew >/dev/null 2>&1); then \
brew install cmake; \
brew install coreutils; \
brew install fftw; \
brew install gcc; \
brew install libxc; \
brew install openblas; \
brew install pkg-config; \
brew install wget; \
else \
echo "ERROR: Homebrew installation not found"; \
echo ' Run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'; \
cd ../..; \
return 1; \
fi; \
./install_cp2k_toolchain.sh -j${maxtasks} --mpi-mode=no --no-arch-files --target-cpu=${target_cpu} \
--with-cmake=$(brew --prefix cmake) --with-fftw=$(brew --prefix fftw) --with-gcc=system \
--with-libxc=$(brew --prefix libxc) --with-ninja=no --with-openblas=$(brew --prefix openblas); \
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; \
echo "The Accelerate framework is used instead of OpenBLAS with"; \
echo " make -j ARCH=${this_file%.*} VERSION=${this_file##*.} TARGET_CPU=${target_cpu} USE_OPENBLAS="; \
echo; \
echo "Run always the following command before using the CP2K binary"; \
echo " source ${PWD}/tools/toolchain/install/setup"; \
echo; \
return
# Set options
DO_CHECKS := no
TARGET_CPU := native
# Retrieve package versions
USE_LIBGRPP := $(LIBGRPP_VER)
USE_LIBINT := $(LIBINT_VER)
USE_LIBVORI := $(LIBVORI_VER)
USE_LIBXSMM := $(LIBXSMM_VER)
USE_OPENBLAS := $(OPENBLAS_VER)
USE_SPGLIB := $(SPGLIB_VER)
LMAX := 5
MAX_CONTR := 4
CC := gcc
CXX := g++
FC := gfortran
LD := gfortran
AR := ar -r -s
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
INSTALL_PATH := $(PWD)/tools/toolchain/install
# Settings for regression testing
ifeq ($(DO_CHECKS), yes)
DFLAGS += -D__CHECK_DIAG
FCFLAGS_DEBUG := -fcheck=bounds,do,recursion,pointer
FCFLAGS_DEBUG += -fcheck=all,no-array-temps
# FCFLAGS_DEBUG += -ffpe-trap=invalid,overflow,zero
FCFLAGS_DEBUG += -fimplicit-none
FCFLAGS_DEBUG += -finit-derived
FCFLAGS_DEBUG += -finit-real=snan
FCFLAGS_DEBUG += -finit-integer=-42
FCFLAGS_DEBUG += -finline-matmul-limit=0
WFLAGS := -Werror=aliasing
WFLAGS += -Werror=ampersand
WFLAGS += -Werror=c-binding-type
WFLAGS += -Werror=conversion
WFLAGS += -Werror=intrinsic-shadow
WFLAGS += -Werror=intrinsics-std
WFLAGS += -Werror=line-truncation
WFLAGS += -Wrealloc-lhs
WFLAGS += -Werror=tabs
WFLAGS += -Werror=target-lifetime
WFLAGS += -Werror=underflow
WFLAGS += -Werror=unused-but-set-variable
WFLAGS += -Werror=unused-dummy-argument
WFLAGS += -Werror=unused-variable
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
LIBXC_HOME := $(shell brew --prefix libxc)
CFLAGS += -I$(LIBXC_HOME)/include
DFLAGS += -D__LIBXC
LIBS += -Wl,-rpath,$(LIBXC_HOME)/lib -L$(LIBXC_HOME)/lib -lxcf03 -lxc
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
LIBS += $(LIBXSMM_LIB)/libxsmmf.a
LIBS += $(LIBXSMM_LIB)/libxsmmext.a
LIBS += $(LIBXSMM_LIB)/libxsmm.a
endif
FFTW_HOME := $(shell brew --prefix fftw)
CFLAGS += -I$(FFTW_HOME)/include
DFLAGS += -D__FFTW3
LIBS += $(FFTW_HOME)/lib/libfftw3_omp.a
LIBS += $(FFTW_HOME)/lib/libfftw3.a
ifneq ($(USE_OPENBLAS),)
OPENBLAS_HOME := $(shell brew --prefix openblas)
CFLAGS += -I$(OPENBLAS_HOME)/include
LIBS += $(OPENBLAS_HOME)/lib/libopenblas.a
else
# Linking to the Accelerate framework instead of OpenBLAS is not the default
# because of failing tests
DFLAGS += -D__ACCELERATE
LIBS += -framework Accelerate
endif
CFLAGS += $(DFLAGS)
FCFLAGS := $(CFLAGS) $(FCFLAGS_DEBUG) $(WFLAGS)
FCFLAGS += -fallow-argument-mismatch
FCFLAGS += -fbacktrace
FCFLAGS += -ffree-form
FCFLAGS += -ffree-line-length-none
FCFLAGS += -fno-omit-frame-pointer
FCFLAGS += -std=f2008
LDFLAGS := $(FCFLAGS)
LIBS += -ldl -lstdc++
# End