-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
140 lines (107 loc) · 3.47 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
# -----------------------------------------------------------------------------
# Setup...
# -----------------------------------------------------------------------------
# Main executables...
EXC = formod obs2spec brightness climatology jsec2time limb nadir planck time2jsec memoryinfo hash
# Library directories...
LIBDIR =
LIBDIR += -L ../lib/build/lib64
LIBDIR += -L ../lib/build/lib
# Include directories...
INCDIR =
INCDIR += -I ../lib/build/include
# Linking...
STATIC = 1
# Profiling...
#PROF = 1
# -----------------------------------------------------------------------------
# Set flags for GNU compiler...
# -----------------------------------------------------------------------------
# Compilers...
CC = gcc
CU = nvcc
# Check whether a CUDA compiler is available...
ENABLEGPU = $(shell command -v $(CU) 2> /dev/null)
# For reproducability compile the git key (hash) into the code
GITKEY = $(shell git log | head -1 | sed -e 's/commit //g')
# Feature flags...
CFEAFLAGS =
CFEAFLAGS += -fopenmp
CFEAFLAGS += -fno-common
CFEAFLAGS += -fshort-enums
CFEAFLAGS += -fno-omit-frame-pointer
# CFEAFLAGS += -fno-finite-math-only
# CFEAFLAGS += -D DIRECTORY_WITH_GAS_NAME
CFEAFLAGS += -D SHOW_GIT_KEY=$(GITKEY)
# Compiler optimization flags...
COPTFLAGS=
COPTFLAGS += -O3
# COPTFLAGS += -Ofast
# COPTFLAGS += -g
# COPTFLAGS += -pg
# COPTFLAGS += -mtune=power8
# COPTFLAGS += -mcpu=power8
# COPTFLAGS += -DGPUDEBUG
CUOPTFLAGS += -D USE_UNIFIED_MEMORY_FOR_TABLES
# Compiler flags...
CFLAGS = -std=gnu99 $(INCDIR) -DHAVE_INLINE -DGSL_DISABLE_DEPRACTED $(COPTFLAGS) $(CERRFLAGS) $(CFEAFLAGS) -pedantic -Winline -Wall -W -Wconversion -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wfatal-errors -Wno-deprecated-declarations
# CUDA Compiler optimization flags...
# CUOPTFLAGS += -gencode arch=compute_60,code=sm_60 $(INCDIR) ## sm_60 for P100
CUOPTFLAGS += -gencode arch=compute_70,code=sm_70 $(INCDIR) ## sm_70 for V100
CUOPTFLAGS += -gencode arch=compute_80,code=sm_80 $(INCDIR) ## sm_80 for A100
# CUDA Compiler flags...
CUFLAGS =
CUFLAGS += --std=c++11
CUFLAGS += --use_fast_math $(CUOPTFLAGS) $(patsubst %,-Xcompiler %,$(FLAGS))
CUFLAGS += -Xptxas -v
# CUFLAGS += -DRETURN_AFTER_INIT
# CUFLAGS += -DGPUDEBUG
# Linker flags...
LDFLAGS = $(LIBDIR) -lgsl -lgslcblas -lm -lstdc++
# Objects...
OBJECTS = jurassic.o CPUdrivers.o
ifeq ($(strip $(ENABLEGPU)),)
# Linking...
ifdef STATIC
CFLAGS += -static
endif
else
OBJECTS += GPUdrivers.o
CFEAFLAGS += -DhasGPU
LDFLAGS += -lcudart
LIBDIR += -L $(CUDA_PATH)/lib64
endif
# Dependencies...
DEP = jurassic.d CPUdrivers.d GPUdrivers.d $(EXEC:%=%.d)
# -----------------------------------------------------------------------------
# Targets...
# -----------------------------------------------------------------------------
all: $(EXC)
.PHONY: allclean clean
clean:
rm -f *.o *~ *.d
allclean: clean
rm -f $(EXC)
bak:
tar chzf jurassic-gpu_`date +"%y%m%d%H%M"`.tgz Makefile *.c *.h
indent:
indent -br -brf -brs -bfda -ce -cdw -lp -npcs -npsl *.c *.h
$(EXC): %: %.c $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
# Generic rules for all object files...
%.o:%.c %.d Makefile
$(CC) $(CFLAGS) -c $<
ifeq ($(strip $(ENABLEGPU)),)
@echo "Warning: No CUDA compiler found!"
else
%.o:%.cu %.d Makefile
$(CU) $(CUFLAGS) -c $<
endif
# Dependency rules for correct building in case of changed .h files...
%.d:%.c Makefile
$(CC) $(CFLAGS) -MM $< -MF $@
%.d:%.cu Makefile
$(CC) $(CFLAGS) -MM $< -MF $@
-include $(DEP)
show:
@echo "ENABLEGPU=" $(ENABLEGPU)