1 # --------------------------------------------------------------------------
4 # Markus Wittmann, 2016-2017
5 # RRZE, University of Erlangen-Nuremberg, Germany
6 # markus.wittmann -at- fau.de or hpc -at- rrze.fau.de
9 # LSS, University of Erlangen-Nuremberg, Germany
11 # Michael Hussnaetter, 2017-2018
12 # University of Erlangen-Nuremberg, Germany
13 # michael.hussnaetter -at- fau.de
15 # This file is part of the Lattice Boltzmann Benchmark Kernels (LbmBenchKernels).
17 # LbmBenchKernels is free software: you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation, either version 3 of the License, or
20 # (at your option) any later version.
22 # LbmBenchKernels is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with LbmBenchKernels. If not, see <http://www.gnu.org/licenses/>.
30 # --------------------------------------------------------------------------
32 # Default configuration to chose.
40 # If we compile for BENCHMARK all verifcation and statistics are disabled,
41 # if not specified otherwise.
42 ifeq (on,$(BENCHMARK))
57 VTK_OUTPUT_ASCII ?= off
59 LID_DRIVEN_CAVITY ?= off
65 # Which floating point precision to use: dp (double precision) or sp (single preicision)
68 # Global settings for the Makefile
100 # Where to store objects and dependency files.
101 OBJECT_DIR = obj/$(CONFIG)-$(BUILD)$(PREC)$(TAG)
102 DEP_DIR = obj/$(CONFIG)-$(BUILD)$(PREC)$(TAG)-dep
104 # Sources to consider.
105 SOURCES_C = Main.c Memory.c Geometry.c Kernel.c \
106 Vtk.c Pinning.c Padding.c Lattice.c
108 # ------------------------------------------------------------------------
109 # NO CHANGE BELOW SHOULD BE NEEDED
110 # ------------------------------------------------------------------------
112 OBJ_C = $(foreach SOURCE,$(SOURCES_C),$(OBJECT_DIR)/$(SOURCE:%.c=%.o)) \
113 $(OBJECT_DIR)/BenchKernelD3Q19Common_PullSoA.o \
114 $(OBJECT_DIR)/BenchKernelD3Q19Common_PullAoS.o \
115 $(OBJECT_DIR)/BenchKernelD3Q19Common_PushSoA.o \
116 $(OBJECT_DIR)/BenchKernelD3Q19Common_PushAoS.o \
117 $(OBJECT_DIR)/BenchKernelD3Q19_PullSoA.o \
118 $(OBJECT_DIR)/BenchKernelD3Q19_PullAoS.o \
119 $(OBJECT_DIR)/BenchKernelD3Q19_PushSoA.o \
120 $(OBJECT_DIR)/BenchKernelD3Q19_PushAoS.o \
121 $(OBJECT_DIR)/BenchKernelD3Q19List_PushSoA.o \
122 $(OBJECT_DIR)/BenchKernelD3Q19ListCommon_PushSoA.o \
123 $(OBJECT_DIR)/BenchKernelD3Q19List_PushAoS.o \
124 $(OBJECT_DIR)/BenchKernelD3Q19ListCommon_PushAoS.o \
125 $(OBJECT_DIR)/BenchKernelD3Q19List_PullSoA.o \
126 $(OBJECT_DIR)/BenchKernelD3Q19ListCommon_PullSoA.o \
127 $(OBJECT_DIR)/BenchKernelD3Q19List_PullAoS.o \
128 $(OBJECT_DIR)/BenchKernelD3Q19ListCommon_PullAoS.o \
129 $(OBJECT_DIR)/BenchKernelD3Q19ListAa_PushSoA.o \
130 $(OBJECT_DIR)/BenchKernelD3Q19ListAaCommon_PushSoA.o \
131 $(OBJECT_DIR)/BenchKernelD3Q19ListAa_PushAoS.o \
132 $(OBJECT_DIR)/BenchKernelD3Q19ListAaCommon_PushAoS.o \
133 $(OBJECT_DIR)/BenchKernelD3Q19ListAaRia_PushSoA.o \
134 $(OBJECT_DIR)/BenchKernelD3Q19ListAaRiaCommon_PushSoA.o \
135 $(OBJECT_DIR)/BenchKernelD3Q19ListAaPv_PushSoA.o \
136 $(OBJECT_DIR)/BenchKernelD3Q19ListAaPvCommon_PushSoA.o \
137 $(OBJECT_DIR)/BenchKernelD3Q19ListPullSplitNt_PullSoA.o \
138 $(OBJECT_DIR)/BenchKernelD3Q19ListPullSplitNtCommon_PullSoA.o \
139 $(OBJECT_DIR)/BenchKernelD3Q19Aa_AaAoS.o \
140 $(OBJECT_DIR)/BenchKernelD3Q19AaCommon_AaAoS.o \
141 $(OBJECT_DIR)/BenchKernelD3Q19Aa_AaSoA.o \
142 $(OBJECT_DIR)/BenchKernelD3Q19AaCommon_AaSoA.o \
143 $(OBJECT_DIR)/BenchKernelD3Q19AaVec_AaSoA.o \
144 $(OBJECT_DIR)/BenchKernelD3Q19AaVecCommon_AaSoA.o \
145 $(OBJECT_DIR)/BenchKernelD3Q19AaVecSl_AaSoA.o \
146 $(OBJECT_DIR)/BenchKernelD3Q19AaVecSlCommon_AaSoA.o
148 # Kernels which are using AVX-512 intrinsics.
149 OBJ_C_ISA_AVX_512 = \
150 $(OBJECT_DIR)/BenchKernelD3Q19ListAaPvGatherAoSoA_PushAoSoA.o \
151 $(OBJECT_DIR)/BenchKernelD3Q19ListAaPvGatherAoSoACommon_PushAoSoA.o \
152 $(OBJECT_DIR)/BenchKernelD3Q19ListAaPvGather_PushSoA.o \
153 $(OBJECT_DIR)/BenchKernelD3Q19ListAaPvGatherCommon_PushSoA.o \
154 $(OBJECT_DIR)/BenchKernelD3Q19ListAaPvGatherHybrid_PushSoA.o \
155 $(OBJECT_DIR)/BenchKernelD3Q19ListAaPvGatherHybridCommon_PushSoA.o
159 include ./config.$(CONFIG).mk
162 # Colorize command lines.
164 COLOR_GRAY =\033[1;30m
165 COLOR_LIGHT_GRAY =\033[0;37m
166 COLOR_CYAN =\033[0;36m
167 COLOR_LIGHT_CYAN =\033[1;36m
168 COLOR_MAGENTA =\033[0;35m
169 COLOR_DARK_MAGENTA=\033[1;35m
171 COLOR_RED =\033[0;31m
172 COLOR_DARK_RED =\033[1;31m
173 COLOR_GREEN =\033[0;32m
174 COLOR_DARK_GREEEN =\033[1;32m
189 # Dependencies which are not source files, that require
190 # rebuilding the application.
191 REBUILD_DEPS = $(filter-out %.d,$(MAKEFILE_LIST)) $(OBJECT_DIR)/.target $(DEP_DIR)/.target
195 # Verify computed flow field
196 ifeq (on,$(VERIFICATION))
197 PP_FLAGS += $(D)VERIFICATION
200 ifeq (on,$(VTK_OUTPUT))
201 PP_FLAGS += $(D)VTK_OUTPUT
204 ifeq (on,$(STATISTICS))
205 PP_FLAGS += $(D)STATISTICS
208 ifeq (on,$(VTK_OUTPUT_ASCII))
209 PP_FLAGS += $(D)VTK_OUTPUT_ASCII
212 ifeq (on,$(LID_DRIVEN_CAVITY))
213 PP_FLAGS += $(D)LID_DRIVEN_CAVITY
217 PP_FLAGS += $(D)VECTOR_AVX512
221 PP_FLAGS += $(D)VECTOR_AVX
225 PP_FLAGS += $(D)VECTOR_SSE
228 # Required for posix_memalign
229 PP_FLAGS += $(D)_POSIX_C_SOURCE=200112L
232 PP_FLAGS += $(LIKWID_INC) $(D)HAVE_LIKWID
233 LD_LIBS += $(LIKWID_LIB) -llikwid
236 ifeq (HBM,$(ADJ_LIST_MEM_TYPE))
237 #MEMKIND is required for this!
239 C_FLAGS += -DALLOC_ADJ_LIST_IN_HBM=1
241 C_FLAGS += -DALLOC_ADJ_LIST_IN_HBM=0
244 ifeq (HBM,$(PDF_MEM_TYPE))
245 #MEMKIND is required for this!
247 C_FLAGS += -DALLOC_PDF_IN_HBM=1
249 C_FLAGS += -DALLOC_PDF_IN_HBM=0
252 ifeq (on, $(MEMKIND))
253 C_FLAGS += -DHAVE_MEMKIND
254 LD_FLAGS += -lmemkind
258 SOFTWARE_PREFETCH_LOOKAHEAD_L2 ?= 0
259 SOFTWARE_PREFETCH_LOOKAHEAD_L1 ?= 0
260 C_FLAGS += -DSOFTWARE_PREFETCH_LOOKAHEAD_L2=$(SOFTWARE_PREFETCH_LOOKAHEAD_L2) -DSOFTWARE_PREFETCH_LOOKAHEAD_L1=$(SOFTWARE_PREFETCH_LOOKAHEAD_L1)
263 ifeq (dp,$(PRECISION))
264 PP_FLAGS += $(D)PRECISION_DP
267 ifeq (sp,$(PRECISION))
268 PP_FLAGS += $(D)PRECISION_SP
271 $(error PRECISION is only be allowed to be sp (single precision) or dp (doble precision))
275 # Use AVX512 intrinsic kernels only when ISA=avx512 and we have double
278 ifeq (dp,$(PRECISION))
279 OBJ_C += $(OBJ_C_ISA_AVX_512)
280 PP_FLAGS += $(D)VECTOR_AVX512_GATHER
284 # ARCH can only be assigned a string without a space. The space is escaped as
285 # a comma which we have to replace here.
288 ARCH_W_COMMA := $(TARCH)
291 override TARCH := $(subst $(COMMA_), ,$(TARCH))
293 $(info $(shell echo -e "\n$(COLOR_GREEN)INFO: Automatically expanding comma in TARCH variable: TARCH=$(TARCH).$(COLOR_NO)\n"))
297 .phony: all clean clean-all
299 #$(info $(shell $(ECHO_E) "# Configuration: CONFIG=$(COLOR_CYAN)$(CONFIG)$(COLOR_NO) BUILD=$(COLOR_CYAN)$(BUILD)$(COLOR_NO) VERIFICATION=$(COLOR_CYAN)$(VERIFICATION)$(COLOR_NO) STATISTICS=$(COLOR_CYAN)$(STATISTICS)$(COLOR_NO) VTK_OUTPUT=$(COLOR_CYAN)$(VTK_OUTPUT)$(COLOR_NO) OPENMP=$(COLOR_CYAN)$(OPENMP)$(COLOR_NO) ISA=$(COLOR_CYAN)$(ISA)$(COLOR_NO) LIKWID=$(COLOR_CYAN)$(LIKWID)$(COLOR_NO) TARCH=$(COLOR_CYAN)$(TARCH)$(COLOR_NO) building $(.DEFAULT_GOAL)..."))
301 $(info $(shell $(ECHO_E) "# Configuration: CONFIG=$(COLOR_CYAN)$(CONFIG)$(COLOR_NO) BUILD=$(COLOR_CYAN)$(BUILD)$(COLOR_NO) PRECISION=$(COLOR_CYAN)$(PRECISION)$(COLOR_NO)"))
302 $(info $(shell $(ECHO_E) "# OPENMP=$(COLOR_CYAN)$(OPENMP)$(COLOR_NO) ISA=$(COLOR_CYAN)$(ISA)$(COLOR_NO) LIKWID=$(COLOR_CYAN)$(LIKWID)$(COLOR_NO)"))
303 $(info $(shell $(ECHO_E) "# VERIFICATION=$(COLOR_CYAN)$(VERIFICATION)$(COLOR_NO) STATISTICS=$(COLOR_CYAN)$(STATISTICS)$(COLOR_NO) VTK_OUTPUT=$(COLOR_CYAN)$(VTK_OUTPUT)$(COLOR_NO)"))
304 $(info $(shell $(ECHO_E) "# target=$(.DEFAULT_GOAL)"))
306 $(info # Object dir: $(OBJECT_DIR))
307 $(info # Dependency dir: $(DEP_DIR))
308 # $(info # objects: $(OBJ))
312 all: $(BIN_DIR)/lbmbenchk-$(CONFIG)-$(BUILD)$(BUILD_CONFIG)$(PREC)$(TAG)
315 # ------------------------------------------------------------------------
316 # TODO: Include dependencies, if they exist and no clean target is specified.
318 #ifeq (,$(SKIP_DEP_INCLUDE))
320 # TMP_OBJ__ = $(patsubst $(OBJECT_DIR)/%,$(DEP_DIR)/%,$(OBJ))
321 # $(warning TMP_OBJ__: $(TMP_OBJ__))
322 # $(warning OBJ: $(OBJ))
323 # $(warning DEPS: $(patsubst %.o,%.d,$(TMP_OBJ__)))
324 # $(warning $(patsubst $(OBJECT_DIR)/%.o,$(DEP_DIR)/%.d,$(OBJ)))
325 -include $(patsubst $(OBJECT_DIR)/%.o,$(DEP_DIR)/%.d,$(OBJ))
331 [ -d "$@" ] || mkdir -p "$@"
333 $(BIN_DIR)/lbmbenchk-$(CONFIG)-$(BUILD)$(BUILD_CONFIG)$(PREC)$(TAG): $(OBJ) $(REBUILD_DEPS) $(DEP_DIR)/.target | $(BIN_DIR)
334 @$(ECHO_E) "linking: $(COLOR_CYAN)$@$(COLOR_NO)"
335 $(LD) $(LD_FLAGS) -o $@ $(filter-out $(REBUILD_DEPS),$^) $(LD_LIBS)
336 @$(ECHO_E) "# Builded binary: $(COLOR_CYAN)$@$(COLOR_NO)"
337 @$(ECHO_E) "# Configuration was: CONFIG=$(COLOR_CYAN)$(CONFIG)$(COLOR_NO) BUILD=$(COLOR_CYAN)$(BUILD)$(COLOR_NO) PRECISION=$(COLOR_CYAN)$(PRECISION)$(COLOR_NO)"
338 @$(ECHO_E) "# OPENMP=$(COLOR_CYAN)$(OPENMP)$(COLOR_NO) ISA=$(COLOR_CYAN)$(ISA)$(COLOR_NO) LIKWID=$(COLOR_CYAN)$(LIKWID)$(COLOR_NO)"
339 @$(ECHO_E) "# VERIFICATION=$(COLOR_CYAN)$(VERIFICATION)$(COLOR_NO) STATISTICS=$(COLOR_CYAN)$(STATISTICS)$(COLOR_NO) VTK_OUTPUT=$(COLOR_CYAN)$(VTK_OUTPUT)$(COLOR_NO)"
340 @$(ECHO_E) "# target=$(.DEFAULT_GOAL)"
342 $(OBJECT_DIR)/%_SoA.o: %.c $(REBUILD_DEPS)
343 @$(ECHO_E) "compiling: $(COLOR_CYAN)$@$(COLOR_NO) $(COLOR_MAGENTA)DATA_LAYOUT_SOA$(COLOR_NO)"
344 $(CC) $(strip $(C_FLAGS)) $(strip $(PP_FLAGS)) $(D)DATA_LAYOUT_SOA -c $< -o $@
346 $(OBJECT_DIR)/%_PushSoA.o: %.c $(REBUILD_DEPS)
347 @$(ECHO_E) "compiling: $(COLOR_CYAN)$@$(COLOR_NO) $(COLOR_MAGENTA)DATA_LAYOUT_SOA$(COLOR_NO) $(COLOR_MAGENTA)PROP_MODEL_PUSH$(COLOR_NO)"
348 $(CC) $(strip $(C_FLAGS)) $(strip $(PP_FLAGS)) $(D)DATA_LAYOUT_SOA $(D)PROP_MODEL_PUSH -c $< -o $@
350 $(OBJECT_DIR)/%_PushAoS.o: %.c $(REBUILD_DEPS)
351 @$(ECHO_E) "compiling: $(COLOR_CYAN)$@$(COLOR_NO) $(COLOR_MAGENTA)DATA_LAYOUT_AOS$(COLOR_NO) $(COLOR_MAGENTA)PROP_MODEL_PUSH$(COLOR_NO)"
352 $(CC) $(strip $(C_FLAGS)) $(strip $(PP_FLAGS)) $(D)DATA_LAYOUT_AOS $(D)PROP_MODEL_PUSH -c $< -o $@
354 $(OBJECT_DIR)/%_PushAoSoA.o: %.c $(REBUILD_DEPS)
355 @$(ECHO_E) "compiling: $(COLOR_CYAN)$@$(COLOR_NO) $(COLOR_MAGENTA)DATA_LAYOUT_AOSOA$(COLOR_NO) $(COLOR_MAGENTA)PROP_MODEL_PUSH$(COLOR_NO)"
356 $(Q)$(CC) $(strip $(C_FLAGS)) $(strip $(PP_FLAGS)) $(D)DATA_LAYOUT_AOSOA $(D)PROP_MODEL_PUSH -c $< -o $@
358 $(OBJECT_DIR)/%_PullSoA.o: %.c $(REBUILD_DEPS)
359 @$(ECHO_E) "compiling: $(COLOR_CYAN)$@$(COLOR_NO) $(COLOR_MAGENTA)DATA_LAYOUT_SOA$(COLOR_NO) $(COLOR_MAGENTA)PROP_MODEL_PULL$(COLOR_NO)"
360 $(CC) $(strip $(C_FLAGS)) $(strip $(PP_FLAGS)) $(D)DATA_LAYOUT_SOA $(D)PROP_MODEL_PULL -c $< -o $@
362 $(OBJECT_DIR)/%_PullAoS.o: %.c $(REBUILD_DEPS)
363 @$(ECHO_E) "compiling: $(COLOR_CYAN)$@$(COLOR_NO) $(COLOR_MAGENTA)DATA_LAYOUT_AOS$(COLOR_NO) $(COLOR_MAGENTA)PROP_MODEL_PULL$(COLOR_NO)"
364 $(CC) $(strip $(C_FLAGS)) $(strip $(PP_FLAGS)) $(D)DATA_LAYOUT_AOS $(D)PROP_MODEL_PULL -c $< -o $@
366 $(OBJECT_DIR)/%_AoS.o: %.c $(REBUILD_DEPS)
367 @$(ECHO_E) "compiling: $(COLOR_CYAN)$@$(COLOR_NO) $(COLOR_MAGENTA)DATA_LAYOUT_AOS$(COLOR_NO)"
368 $(CC) $(strip $(C_FLAGS)) $(strip $(PP_FLAGS)) $(D)DATA_LAYOUT_AOS -c $< -o $@
370 $(OBJECT_DIR)/%_AaAoS.o: %.c $(REBUILD_DEPS)
371 @$(ECHO_E) "compiling: $(COLOR_CYAN)$@$(COLOR_NO) $(COLOR_MAGENTA)DATA_LAYOUT_AOS$(COLOR_NO) $(COLOR_MAGENTA)PROP_MODEL_AA$(COLOR_NO)"
372 $(CC) $(strip $(C_FLAGS)) $(strip $(PP_FLAGS)) $(D)DATA_LAYOUT_AOS $(D)PROP_MODEL_AA -c $< -o $@
374 $(OBJECT_DIR)/%_AaSoA.o: %.c $(REBUILD_DEPS)
375 @$(ECHO_E) "compiling: $(COLOR_CYAN)$@$(COLOR_NO) $(COLOR_MAGENTA)DATA_LAYOUT_SOA$(COLOR_NO) $(COLOR_MAGENTA)PROP_MODEL_AA$(COLOR_NO)"
376 $(CC) $(strip $(C_FLAGS)) $(strip $(PP_FLAGS)) $(D)DATA_LAYOUT_SOA $(D)PROP_MODEL_AA -c $< -o $@
378 $(OBJECT_DIR)/%.o: %.c $(REBUILD_DEPS)
379 @$(ECHO_E) "compiling: $(COLOR_CYAN)$@$(COLOR_NO)"
380 $(CC) $(strip $(C_FLAGS)) $(strip $(PP_FLAGS)) -c $< -o $@
383 # ------------------------------------------------------------------------
384 # Following targets in principal make only sure, that the directories
385 # are created if the do not exist already.
388 $(Q)$(MKDIR_P) $(DEP_DIR)
391 # ------------------------------------------------------------------------
392 # Current configuration.
393 MAKE_CFG = SYSTEM=$(SYSTEM) // BUILD=$(BUILD) // MAKEOVERRIDES=\"$(strip $(MAKEOVERRIDES))\" // VERIFICATION=$(VERIFICATION) // STATISTICS=$(STATISTICS) // VTK_OUTPUT=$(VTK_OUTPUT) // VTK_OUTPUT_ASCII=$(VTK_OUTPUT_ASCII) // LID_DRIVEN_CAVITY=$(LID_DRIVEN_CAVITY) // ISA=$(ISA) // LIKWID=$(LIKWID) // PRECISION=$(PRECISION)
395 # Compare current configuration to the last one so we know when to
396 # rebuild this system/target despite when sources have not changed.
397 $(OBJECT_DIR)/.target::
398 $(Q)$(MKDIR_P) $(OBJECT_DIR)
399 @ ( [ -f $(OBJECT_DIR)/.target ] && $(ECHO) $(MAKE_CFG) | $(CMP) -s $(OBJECT_DIR)/.target - ) \
400 || ( $(ECHO) $(MAKE_CFG) > $(OBJECT_DIR)/.target; $(ECHO) "# configuration variables changed, rebuilding ..." )
404 -rm $(OBJECT_DIR)/*.o $(DEP_DIR)/*.d
407 -[ -d obj ] && rm -r obj