Made the build environment a bit more intelligent. Easily switchable by using 'source smvars.sh {intel|llvm|gnu}'.

This commit is contained in:
Francois Coppens 2021-04-01 13:49:53 +02:00
parent 545fe71547
commit 0014513b1a
5 changed files with 78 additions and 43 deletions

3
.gitignore vendored
View File

@ -1,7 +1,8 @@
*.o *.o
*.mod *.mod
*.dbg
.vscode .vscode
Slater* Slater*
Updates* Updates*
datasets/datasets.* datasets/dataset.*
bin/ bin/

View File

@ -1,19 +1,37 @@
## Compilers ## Compilers, compiler flags & external libs
ARCH = ifeq ($(ENV),INTEL)
CXX = clang++-7 CXX = icpc
FC = flang-7 FC = ifort
H5CXX = h5c++ ARCH = -xCORE-AVX2
OPT = -O0
## Compiler flags DEBUG = -debug full
CXXFLAGS = -O0 else ifeq ($(ENV),LLVM)
CXX = clang++
FC = flang
ARCH =
OPT = -O0
DEBUG = -g
else ifeq ($(ENV),GNU)
CXX = g++
FC = gfortran
ARCH = -mavx
OPT = -O0
DEBUG = -g
else
$(error No valid compiler environment set in $$ENV. First run: $$ source smvars.sh {intel | llvm | gnu})
endif
CXXFLAGS = $(OPT) $(ARCH) $(DEBUG)
FFLAGS = $(CXXFLAGS) FFLAGS = $(CXXFLAGS)
H5CXX = h5c++
H5CXXFLAGS = $(CXXFLAGS) -fPIC H5CXXFLAGS = $(CXXFLAGS) -fPIC
FLIBS = -lstdc++ FLIBS = -lstdc++
## Includes and dependencies
INCLUDE = -I $(INC_DIR)/ INCLUDE = -I $(INC_DIR)/
DEPS_CXX = $(OBJ_DIR)/SM_MaponiA3.o $(OBJ_DIR)/SM_Standard.o DEPS_CXX = $(OBJ_DIR)/SM_MaponiA3.o $(OBJ_DIR)/SM_Standard.o
DEPS_F = $(DEPS_CXX) $(OBJ_DIR)/SM_MaponiA3_mod.o $(OBJ_DIR)/Helpers_mod.o DEPS_F = $(DEPS_CXX) $(OBJ_DIR)/SM_MaponiA3_mod.o $(OBJ_DIR)/Helpers_mod.o
## Directory structure
SRC_DIR := src SRC_DIR := src
TST_DIR := tests TST_DIR := tests
INC_DIR := include INC_DIR := include
@ -32,7 +50,7 @@ EXEC := $(BIN_DIR)/cMaponiA3_test_3x3_3 \
all: $(EXEC) all: $(EXEC)
clean: clean:
@rm -vrf $(OBJ_DIR) @rm -vrf $(OBJ_DIR) *.dbg
distclean: clean distclean: clean
@rm -vrf $(BIN_DIR) \ @rm -vrf $(BIN_DIR) \
@ -46,7 +64,7 @@ $(BIN_DIR) $(OBJ_DIR):
### IMPLICIT BUILD RULES ### IMPLICIT BUILD RULES
## C++ objects ## C++ objects
$(OBJ_DIR)/%.o: $(TST_DIR)/%.cpp $(INC_DIR)/* | $(OBJ_DIR) $(OBJ_DIR)/%.o: $(TST_DIR)/%.cpp $(INC_DIR)/* | $(OBJ_DIR)
$(CXX) $(CXXFLAGS) $(ARCH) $(INCLUDE) -c -o $@ $< $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
## HDF5/C++ objects ## HDF5/C++ objects
$(OBJ_DIR)/%_h5.o: $(TST_DIR)/%_h5.cpp $(INC_DIR)/* | $(OBJ_DIR) $(OBJ_DIR)/%_h5.o: $(TST_DIR)/%_h5.cpp $(INC_DIR)/* | $(OBJ_DIR)
@ -54,19 +72,23 @@ $(OBJ_DIR)/%_h5.o: $(TST_DIR)/%_h5.cpp $(INC_DIR)/* | $(OBJ_DIR)
## Fortran modules ## Fortran modules
$(OBJ_DIR)/%_mod.o: $(SRC_DIR)/%_mod.f90 | $(OBJ_DIR) $(OBJ_DIR)/%_mod.o: $(SRC_DIR)/%_mod.f90 | $(OBJ_DIR)
$(FC) $(FFLAGS) $(ARCH) -J$(OBJ_DIR)/ -c -o $@ $< ifeq ($(ENV),$(filter $(ENV),LLVM GNU))
$(FC) $(FFLAGS) -J $(OBJ_DIR)/ -c -o $@ $<
else
$(FC) $(FFLAGS) -module $(OBJ_DIR)/ -c -o $@ $<
endif
## Fortran objects ## Fortran objects
$(OBJ_DIR)/%.o: $(TST_DIR)/%.f90 | $(OBJ_DIR) $(OBJ_DIR)/%.o: $(TST_DIR)/%.f90 | $(OBJ_DIR)
$(FC) $(FFLAGS) $(ARCH) -I $(OBJ_DIR)/ -c -o $@ $< $(FC) $(FFLAGS) -I $(OBJ_DIR)/ -c -o $@ $<
### EXPLICIT BUILD RULES ### EXPLICIT BUILD RULES
## special compiler flag -fPIC otherwise h5c++ builds fail ## special compiler flag -fPIC otherwise h5c++ builds fail
$(OBJ_DIR)/SM_MaponiA3.o: $(SRC_DIR)/SM_MaponiA3.cpp $(INC_DIR)/* | $(OBJ_DIR) $(OBJ_DIR)/SM_MaponiA3.o: $(SRC_DIR)/SM_MaponiA3.cpp $(INC_DIR)/* | $(OBJ_DIR)
$(CXX) $(CXXFLAGS) -fPIC $(ARCH) $(INCLUDE) -c -o $@ $< $(CXX) $(CXXFLAGS) -fPIC $(INCLUDE) -c -o $@ $<
$(OBJ_DIR)/SM_Standard.o: $(SRC_DIR)/SM_Standard.cpp $(INC_DIR)/* | $(OBJ_DIR) $(OBJ_DIR)/SM_Standard.o: $(SRC_DIR)/SM_Standard.cpp $(INC_DIR)/* | $(OBJ_DIR)
$(CXX) $(CXXFLAGS) -fPIC $(ARCH) $(INCLUDE) -c -o $@ $< $(CXX) $(CXXFLAGS) -fPIC $(INCLUDE) -c -o $@ $<
#### LINKING #### LINKING

View File

@ -1,22 +0,0 @@
#!/usr/bin/env bash
start_cycle=$1
stop_cycle=$2
if [ "$#" -ne 2 ]
then
echo "usage: ./run-tests.sh <start cycle> <stop cycle>"
exit 1
fi
if [ ! -f "bin/test_external_h5" ]
then
make bin/test_external_h5
fi
cd datasets/
for ((cycle = start_cycle; cycle < stop_cycle+1; cycle++))
do
../bin/test_external_h5 $cycle
done

40
smvars.sh Normal file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env bash
ENV=$1
PWD=$(pwd)
SRCDIR=$(dirname $BASH_SOURCE)
case $SRCDIR in
/*) SMROOT=$SRCDIR ;; ## sourced from absolute path
*) SMROOT=$PWD/$SRCDIR ;; ## sourced from relative path
esac
export SMROOT
case $ENV in
intel)
export HDF5_CXX=icpc
export HDF5_CXXLINKER=icpc
export ENV=INTEL
;;
llvm)
export HDF5_CXX=clang++
export HDF5_CXXLINKER=clang++
export ENV=LLVM
;;
gnu)
export HDF5_CXX=g++
export HDF5_CXXLINKER=g++
export ENV=GNU
;;
*)
echo "Unknown environment descriptor given."
echo "Usage: source smvars.sh {intel | llvm | gnu}"
return 1
;;
esac
if [ -z "$SMVARS" ]
then
export PATH=$SMROOT/bin:$PATH
export SMVARS=true
fi

View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
export HDF5_CXX=icpc
export HDF5_CXXLINKER=icpc
export PATH=$PWD/bin:$PATH