-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
161 lines (131 loc) · 4.39 KB
/
Makefile
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
## compilation for different platforms and
## compilers
ARCHS = knl hsw skl nec
ARCH ?= hsw
COMPILERs = icc gnu ncc
COMPILER ?= gnu
$(if $(filter $(COMPILERs),$(COMPILER)),,$(error COMPILER must be one of $(COMPILERs)))
$(if $(filter $(ARCHS),$(ARCH)),,$(error ARCH must be one of $(ARCHS)))
COMPILER_is_$(COMPILER) := yes
ARCH_is_$(ARCH) := yes
## for openmp
-omp := $(if $(COMPILER_is_icc), -qopenmp, -fopenmp)
## for intel avx
-avx := $(if $(COMPILER_is_icc), $(if $(ARCH_is_knl), -xMIC-AVX512, $(if $(ARCH_is_skl), -xCORE-AVX512, -xCORE-AVX2) ),)
-rpt := $(if $(COMPILER_is_icc), -qopt-report=5, $(if $(COMPILER_is_ncc), , -ftree-vectorize -fopt-info-vec-missed))
## for nec mpi version
-nccflag := $(if $(COMPILER_is_ncc), -DNEC,)
-nccdep := $(if $(COMPILER_is_ncc), -M,)
## for knl MCDRAM
-knlflag := $(if $(ARCH_is_knl), -DSC_MEMKIND -I./memkind/include -L./memkind/lib -lmemkind, )
-mkl := $(if $(COMPILER_is_icc), -I/opt/intel/mkl/include, )
-mklld := $(if $(COMPILER_is_icc), -L/opt/intel/mkl/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core,)
## for intel prefetch
-prefetch := $(if $(COMPILER_is_icc), -qopt-prefetch=3,)
# -mpiheader := -I/opt/intel/compilers_and_libraries_2019.0.117/linux/mpi/intel64/include
## include the proprogation blocking codes
# VPATH=./radix
## ----------- start of compilation -----------
# output binary
BIN := sc-$(ARCH)-$(COMPILER).bin
# source files
SRCS := \
$(wildcard *.cpp)
# $(wildcard ./radix/*.cpp) \
#$(wildcard ./radix/commons/*.cpp) \
#$(wildcard ./SpBLAS/*.cpp) \
#$(wildcard ./SpDM3/*.cpp) \
#$(wildcard ./SpMP/*.cpp) \
#$(wildcard ./SpMP/reordering/*.cpp) \
#$(wildcard ./SpMP/synk/*.cpp)
# files included in the tarball generated by 'make dist' (e.g. add LICENSE file)
DISTFILES := $(BIN)
# filename of the tar archive generated by 'make dist'
DISTOUTPUT := $(BIN).tar.gz
# intermediate directory for generated object files
OBJDIR := .o
# intermediate directory for generated dependency files
DEPDIR := .d
# object files, auto generated from source files
OBJS := $(patsubst %,$(OBJDIR)/%.o,$(basename $(SRCS)))
# dependency files, auto generated from source files
DEPS := $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS)))
# compilers (at least gcc and clang) don't create the subdirectories automatically
$(shell mkdir -p $(dir $(OBJS)) >/dev/null)
$(shell mkdir -p $(dir $(DEPS)) >/dev/null)
# C compiler
CC := $(if $(COMPILER_is_ncc), ncc, $(if $(COMPILER_is_icc), icc, gcc))
# C++ compiler
CXX := $(if $(COMPILER_is_ncc), nc++, $(if $(COMPILER_is_icc), icpc, g++))
# linker
LD := $(if $(COMPILER_is_ncc), nc++, $(if $(COMPILER_is_icc), icpc, g++))
# tar
TAR := tar
# C flags
CFLAGS := -std=c11 $(-nccflag) $(-omp) $(-avx) $(-rpt) $(-mkl) -O3
# C++ flags
CXXFLAGS := -std=c++11 $(-nccflag) $(-omp) $(-avx) $(-rpt) $(-mkl) $(-prefetch) -O3
# C/C++ flags
CPPFLAGS := -g -Wall -Wextra -pedantic -DVTUNE -DVERBOSE -DUSE_BLAS
# CPPFLAGS := -g -Wall -pedantic -DVERBOSE
# linker flags
LDFLAGS := $(-omp) $(-mklld)
# flags required for dependency generation; passed to compilers
DEPFLAGS = $(-nccdep) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Td
# compile C source files
COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) -c -o $@
# compile C++ source files
#COMPILE.cc = $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -o $@
COMPILE.cc = $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@
# link object files to binary
LINK.o = $(LD) $(LDFLAGS) $(LDLIBS) -o $@
# precompile step
PRECOMPILE =
# postcompile step
POSTCOMPILE = mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
all: $(BIN)
dist: $(DISTFILES)
$(TAR) -cvzf $(DISTOUTPUT) $^
.PHONY: clean
clean:
$(RM) -r $(OBJDIR) $(DEPDIR)
.PHONY: distclean
distclean: clean
$(RM) $(BIN) $(DISTOUTPUT)
.PHONY: install
install:
@echo no install tasks configured
.PHONY: uninstall
uninstall:
@echo no uninstall tasks configured
.PHONY: check
check:
@echo no tests configured
.PHONY: help
help:
@echo available targets: all dist clean distclean install uninstall check
$(BIN): $(OBJS)
$(LINK.o) $^
$(OBJDIR)/%.o: %.c
$(OBJDIR)/%.o: %.c $(DEPDIR)/%.d
$(PRECOMPILE)
$(COMPILE.c) $<
$(POSTCOMPILE)
$(OBJDIR)/%.o: %.cpp
$(OBJDIR)/%.o: %.cpp $(DEPDIR)/%.d
$(PRECOMPILE)
$(COMPILE.cc) $<
$(POSTCOMPILE)
$(OBJDIR)/%.o: %.cc
$(OBJDIR)/%.o: %.cc $(DEPDIR)/%.d
$(PRECOMPILE)
$(COMPILE.cc) $<
$(POSTCOMPILE)
$(OBJDIR)/%.o: %.cxx
$(OBJDIR)/%.o: %.cxx $(DEPDIR)/%.d
$(PRECOMPILE)
$(COMPILE.cc) $<
$(POSTCOMPILE)
.PRECIOUS = $(DEPDIR)/%.d
$(DEPDIR)/%.d: ;
-include $(DEPS)