From d0260284397431526ea0d04f06ae064ac564621d Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Wed, 24 Mar 2021 08:43:44 +0100 Subject: [PATCH] Streamline build system --- Makefile | 16 +++++++++++----- README.md | 7 ++++--- config.mk | 7 +++++++ include_CLANG.mk | 7 ++----- include_GCC.mk | 10 +++------- include_ICC.mk | 7 ++----- src/includes/parameter.h | 3 --- 7 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 config.mk diff --git a/Makefile b/Makefile index a3c7d85..90e3ce1 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,28 @@ -TAG = GCC - #CONFIGURE BUILD SYSTEM TARGET = MDBench-$(TAG) BUILD_DIR = ./$(TAG) SRC_DIR = ./src MAKE_DIR = ./ -FLAGS = -DAOS Q ?= @ #DO NOT EDIT BELOW +include $(MAKE_DIR)/config.mk include $(MAKE_DIR)/include_$(TAG).mk INCLUDES += -I./src/includes +ifeq ($(strip $(DATA_LAYOUT)),AOS) +DEFINES += -DAOS +endif +ifeq ($(strip $(DATA_TYPE)),SP) +DEFINES += -DPRECISION=1 +else +DEFINES += -DPRECISION=2 +endif + VPATH = $(SRC_DIR) ASM = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.s,$(wildcard $(SRC_DIR)/*.c)) OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o,$(wildcard $(SRC_DIR)/*.c)) -CPPFLAGS := $(CPPFLAGS) $(DEFINES) $(INCLUDES) ${FLAGS} - +CPPFLAGS := $(CPPFLAGS) $(DEFINES) $(OPTIONS) $(INCLUDES) ${TARGET}: $(BUILD_DIR) $(OBJ) @echo "===> LINKING $(TARGET)" diff --git a/README.md b/README.md index ba47bcb..94e2875 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,10 @@ A simple, sequential C implementation of the [Mantevo miniMD](https://github.co ## Build -1. Open the `Makefile` and edit the `TAG` value according to the tool chain used. Currently supported is GCC, CLANG (LLVM), and ICC (Intel). -2. Open and adapt the compiler flags in `.mk`, e.g. in `include_ICC.mk` for the Intel tool chain. -3. Build the binary calling `make`. +1. Open `config.mk` and edit the `TAG` value according to the tool chain used. Currently supported is GCC, CLANG (LLVM), and ICC (Intel). +2. Change `DATA_LAYOUT` and `DATA_TYPE` if desired in config.mk. +3. Open and adapt the compiler flags in `.mk`, e.g. in `include_ICC.mk` for the Intel tool chain. +4. Build the binary calling `make`. You can clean intermediate build results with `make clean`, and all build results with `make distclean`. You have to call `make clean` before `make` if you changed the build settings. diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..30c95c7 --- /dev/null +++ b/config.mk @@ -0,0 +1,7 @@ +# Supported: GCC, CLANG, ICC +TAG ?= GCC +DATA_TYPE ?= SP#SP or DP +DATA_LAYOUT ?= AOS#AOS or SOA + +#Feature options +OPTIONS += -DALIGNMENT=64 diff --git a/include_CLANG.mk b/include_CLANG.mk index 93c499c..59fa579 100644 --- a/include_CLANG.mk +++ b/include_CLANG.mk @@ -1,5 +1,4 @@ CC = cc -CXX = gcc LINKER = $(CC) ANSI_CFLAGS = -ansi @@ -9,9 +8,7 @@ ANSI_CFLAGS += -Wextra CFLAGS = -Ofast $(ANSI_CFLAGS) -g #-Xpreprocessor -fopenmp -g ASFLAGS = -masm=intel -CXXFLAGS = $(CFLAGS) -FCFLAGS = LFLAGS = -DEFINES = -D_GNU_SOURCE -DALIGNMENT=64 -DPRECISION=2 +DEFINES = -D_GNU_SOURCE INCLUDES = -LIBS = #-lomp +LIBS = -lm #-lomp diff --git a/include_GCC.mk b/include_GCC.mk index 0054f40..9dd536a 100644 --- a/include_GCC.mk +++ b/include_GCC.mk @@ -1,7 +1,5 @@ CC = gcc -CXX = g++ -FC = gfortran -LINKER = $(CXX) +LINKER = $(CC) ANSI_CFLAGS = -ansi ANSI_CFLAGS += -std=c99 @@ -10,10 +8,8 @@ ANSI_CFLAGS += -Wextra CFLAGS = -O0 -g -std=c99 -fargument-noalias # CFLAGS = -O3 -march=znver1 -ffast-math -funroll-loops -fopenmp -CXXFLAGS = $(CFLAGS) ASFLAGS = -masm=intel -FCFLAGS = LFLAGS = -DEFINES = -D_GNU_SOURCE -DALIGNMENT=64 -DPRECISION=2 +DEFINES = -D_GNU_SOURCE INCLUDES = -LIBS = +LIBS = -lm diff --git a/include_ICC.mk b/include_ICC.mk index 25207af..ddb61ac 100644 --- a/include_ICC.mk +++ b/include_ICC.mk @@ -1,5 +1,4 @@ CC = icc -CXX = icpc LINKER = $(CC) OPENMP = #-qopenmp @@ -11,10 +10,8 @@ PROFILE = #-profile-functions -g -pg #OPTS = -fast -no-vec $(PROFILE) OPTS = -fast -xHost $(PROFILE) CFLAGS = $(PROFILE) -restrict $(OPENMP) $(OPTS) -CXXFLAGS = $(CFLAGS) ASFLAGS = -masm=intel -FCFLAGS = LFLAGS = $(PROFILE) $(OPTS) $(OPENMP) -DEFINES = -D_GNU_SOURCE -DALIGNMENT=64 # -DLIKWID_PERFMON -DPRECISION=1 +DEFINES = -D_GNU_SOURCE # -DALIGNMENT=64 -DLIKWID_PERFMON -DPRECISION=1 INCLUDES = #$(LIKWID_INC) -LIBS = #$(LIKWID_LIB) -llikwid +LIBS = -lm #$(LIKWID_LIB) -llikwid diff --git a/src/includes/parameter.h b/src/includes/parameter.h index 87da5f8..4f6f914 100644 --- a/src/includes/parameter.h +++ b/src/includes/parameter.h @@ -23,9 +23,6 @@ #ifndef __PARAMETER_H_ #define __PARAMETER_H_ -#ifndef PRECISION -#define PRECISION 2 -#endif #if PRECISION == 1 #define MD_FLOAT float #else