-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.cluster
130 lines (96 loc) · 2.92 KB
/
Makefile.cluster
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
TARGET_EXEC ?= rbm
TARGET_UNITTEST ?= unittest
BUILD_DIR ?= build
SRC_DIRS ?= src
TEST_DIR ?= test
INC_DIRS ?= include
MAT_BACKEND ?= MKL
# PFAPACK
INC_DIRS += deps/pfapack/c_interface
PFAPACK = $(BUILD_DIR)/pfapack/libpfapack.a
PFAPACKC = $(BUILD_DIR)/pfapack/libcpfapack.a
# MINRES QLP
INC_DIRS += deps/minresqlp
INC_DIRS += $(HOME)/googletest/googletest/include/
MINRESQLP = $(BUILD_DIR)/minresqlp/libminresqlp.a
DESTDIR ?= $(HOME)/.local/bin/
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -type f)
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
TEST_SRCS := $(shell find $(TEST_DIR) -name *.cpp -type f)
TEST_OBJS := $(TEST_SRCS:%=$(BUILD_DIR)/%.o)
TEST_OBJS += $(filter-out $(BUILD_DIR)/src/main.cpp.o,$(OBJS))
# INDCLUDE DIRS
INC_DIRS += $(HOME)/eigen3/
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CPPFLAGS += $(INC_FLAGS) $(MKL_INC) -MMD -MP -Wall -std=c++14 -O3 -march=native
CPPFLAGS += -DITERATIVE_USE_MKL
IPO = -ipo
CPPFLAGS += $(IPO)
LDFLAGS += $(IPO)
OMP = -fopenmp
# USE MPI
MPI = $(shell mpiCC -show | cut -d' ' -f2-)
# HANDLE DIFFERENT MATH BACKENDS
ifeq ($(MAT_BACKEND),BLAS)
CPPFLAGS += -DEIGEN_USE_BLAS
$(info using BLAS)
else ifeq ($(MAT_BACKEND),MKL)
CPPFLAGS += -DEIGEN_USE_MKL_ALL
$(info using MKL)
else
$(info using EIGEN)
endif
LDFLAGS += -lboost_program_options
ifeq ($(CC),gcc)
LDFLAGS += -lgfortran
else ifeq ($(CC),icc)
CPPFLAGS += -diag-disable 858
LDFLAGS += -lifcore -lifcoremt
endif
LDFLAGS += $(MKL_LIB)
TEST_LDFLAGS = libgtest.a libgtest_main.a
TEST_LDFLAGS := $(addprefix $(HOME)/googletest/build/lib/,$(TEST_LDFLAGS))
install: all
cp $(BUILD_DIR)/$(TARGET_EXEC) $(DESTDIR)/$(TARGET_EXEC)
cp tools/* $(DESTDIR)/
all: $(BUILD_DIR)/$(TARGET_EXEC)
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) $(PFAPACKC) $(PFAPACK) $(MINRESQLP)
@echo "[ LD ] $@"
@$(CXX) $(OMP) $(MPI) $^ $(LDFLAGS) -o $@
$(BUILD_DIR)/$(TARGET_UNITTEST): $(TEST_OBJS) $(PFAPACKC) $(PFAPACK) $(MINRESQLP)
@echo "[ LD ] $@"
@$(CXX) $(OMP) $(MPI) $^ $(LDFLAGS) $(TEST_LDFLAGS) -o $@
# c++ source
$(BUILD_DIR)/%.cpp.o: %.cpp
@$(MKDIR_P) $(dir $@)
@echo "[ $(notdir $(CXX)) ] $<"
@$(CXX) $(OMP) $(MPI) $(CPPFLAGS) -c $< -o $@
.PHONY: install all clean
test: $(BUILD_DIR)/$(TARGET_UNITTEST)
@$(BUILD_DIR)/$(TARGET_UNITTEST)
clean:
$(RM) -r $(BUILD_DIR)
$(PFAPACK):
cd deps/pfapack/fortran/ && make
@mkdir -p $(BUILD_DIR)/pfapack
cp deps/pfapack/fortran/libpfapack.a $(PFAPACK)
$(PFAPACKC):
cd deps/pfapack/c_interface && make
@mkdir -p $(BUILD_DIR)/pfapack
cp deps/pfapack/c_interface/libcpfapack.a $(PFAPACKC)
$(MINRESQLP):
cd deps/minresqlp/ && make
@mkdir -p $(BUILD_DIR)/minresqlp
cp deps/minresqlp/build/$(notdir $(MINRESQLP)) $(MINRESQLP)
build_pfapack: $(PFAPACK) $(PFAPACKC)
build_minresqlp: $(MINRESQLP)
clean_pfapack:
cd deps/pfapack/fortran/ && make clean
cd deps/pfapack/c_interface && make clean
rm -r build/pfapack
clean_minresqlp:
cd deps/minresqlp/ && make clean
rm -r build/minresqlp
-include $(DEPS)
MKDIR_P ?= mkdir -p