-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
112 lines (83 loc) · 3.91 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
CUDA_HOME ?= /opt/cuda
CU=$(CUDA_HOME)/bin/nvcc
CC=clang++
LIBS=-lcublas
CPP_SOURCE=./src/cpp
HPP_SOURCE=./src/cpp/include
CUDA_SOURCE=./src/cuda
TEST_SOURCE=./test
INCLUDE_DIR=-I./src/cuda/include -I./src/cpp/include -I./src/cuda/
BUILD=./build
BIN=./bin
MAIN_SOURCE=./benchmark
STD=c++17
FLAGS=-gencode=arch=compute_89,code=sm_89
OPTI=-O3
DEBUG=--debug -g -G -O0
PTXAS_FLAGS=--ptxas-options=-v --expt-relaxed-constexpr -lineinfo
Wno=-Xcudafe "--diag_suppress=declared_but_not_referenced" -Wno-deprecated-gpu-targets
$(BUILD)/%.o: $(CPP_SOURCE)/%.cpp
$(CC) -std=$(STD) $(OPTI) $(INCLUDE_DIR) -c $< -o $@
$(BUILD)/%.o: $(HPP_SOURCE)/%.hpp
$(CC) -std=$(STD) $(OPTI) $(INCLUDE_DIR) -c $< -o $@
$(BUILD)/%.o: $(TEST_SOURCE)/%.cpp
$(CC) -std=$(STD) $(OPTI) $(INCLUDE_DIR) -c $< -o $@
$(BUILD)/%.o: $(TEST_SOURCE)/%.cu
$(CU) -std=$(STD) $(OPTI) $(INCLUDE_DIR) -c $< -o $@ $(FLAGS) $(Wno) $(PTXAS_FLAGS)
$(BUILD)/%.o: $(CUDA_SOURCE)/%.cu
$(CU) -std=$(STD) $(OPTI) $(INCLUDE_DIR) -c $< -o $@ $(FLAGS) $(Wno) $(PTXAS_FLAGS)
$(BUILD)/%.o: $(MAIN_SOURCE)/%.cu $(DEP)
$(CU) -std=$(STD) $(OPTI) $(INCLUDE_DIR) -c $< -o $@ $(FLAGS) $(Wno) $(PTXAS_FLAGS)
$(BUILD)/%-d.o: $(CPP_SOURCE)/%.cpp
$(CC) -std=$(STD) $(DEBUG) $(INCLUDE_DIR) -c $< -o $@
$(BUILD)/%-d.o: $(HPP_SOURCE)/%.hpp
$(CC) -std=$(STD) $(DEBUG) $(INCLUDE_DIR) -c $< -o $@
$(BUILD)/%-d.o: $(TEST_SOURCE)/%.cpp
$(CC) -std=$(STD) $(DEBUG) $(INCLUDE_DIR) -c $< -o $@
$(BUILD)/%-d.o: $(TEST_SOURCE)/%.cu
$(CU) -std=$(STD) $(DEBUG) $(INCLUDE_DIR) -c $< -o $@ $(FLAGS) $(Wno) $(PTXAS_FLAGS)
$(BUILD)/%-d.o: $(CUDA_SOURCE)/%.cu
$(CU) -std=$(STD) $(DEBUG) $(INCLUDE_DIR) -c $< -o $@ $(FLAGS) $(Wno) $(PTXAS_FLAGS)
$(BUILD)/%-d.o: $(MAIN_SOURCE)/%.cu $(DEP)
$(CU) -std=$(STD) $(DEBUG) $(INCLUDE_DIR) -c $< -o $@ $(FLAGS) $(Wno) $(PTXAS_FLAGS)
benchmark_%: $(BUILD)/benchmark.o $(BUILD)/%_gemm.o
mkdir -p $(BIN)
$(CU) $^ -std=$(STD) $(OPTI) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
# sh ${SCRIPT_SOURCE}/[email protected]
sb_%: $(BUILD)/single-benchmark.o $(BUILD)/%_gemm.o
mkdir -p $(BIN)
$(CU) $^ -std=$(STD) $(OPTI) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
# sh ${SCRIPT_SOURCE}/[email protected]
i8benchmark: $(BUILD)/i8-benchmark.o $(BUILD)/i8_gemm.o
mkdir -p $(BIN)
$(CU) $^ -std=$(STD) $(OPTI) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
# sh ${SCRIPT_SOURCE}/[email protected]
test_%: $(BUILD)/test.o $(BUILD)/%_gemm.o
$(CU) $^ -std=$(STD) -o $(BIN)/$@ -g $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
test_%-d: $(BUILD)/test-d.o $(BUILD)/%_gemm-d.o
$(CU) $^ -std=$(STD) $(DEBUG) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
i8gemm-test: $(BUILD)/i8gemm-test.o $(BUILD)/i8_gemm.o
$(CU) $^ -std=$(STD) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
i8gemm-test-d: $(BUILD)/i8gemm-test-d.o $(BUILD)/i8_gemm-d.o
$(CU) $^ -std=$(STD) -o $(BIN)/$@ -g $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
i8: $(BUILD)/i8.o $(BUILD)/i8gemm.o
$(CU) $^ -std=$(STD) $(OPTI) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
i8-d: $(BUILD)/i8-d.o $(BUILD)/i8gemm-d.o
$(CU) $^ -std=$(STD) $(DEBUG) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
i8_%: $(BUILD)/i8.o $(BUILD)/i8%_gemm.o
mkdir -p $(BIN)
$(CU) $^ -std=$(STD) $(OPTI) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
# sh ${SCRIPT_SOURCE}/[email protected]
i8-test: $(BUILD)/i8-test.o $(BUILD)/i8gemm.o
$(CU) $^ -std=$(STD) $(OPTI) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
i8-test-d: $(BUILD)/i8-test-d.o $(BUILD)/i8gemm-d.o
$(CU) $^ -std=$(STD) $(DEBUG) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
i8-test_%: $(BUILD)/i8-test.o $(BUILD)/i8%_gemm.o
$(CU) $^ -std=$(STD) $(OPTI) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
i8-test_%-d: $(BUILD)/i8-test-d.o $(BUILD)/i8%_gemm-d.o
$(CU) $^ -std=$(STD) $(DEBUG) -o $(BIN)/$@ $(LIBS) $(FLAGS) $(Wno) $(PTXAS_FLAGS)
mma_ptx: $(MAIN_SOURCE)/mma_ptx.cu
$(CU) -std=$(STD) $(OPTI) $(INCLUDE_DIR) $^ -o $(BIN)/$@ $(FLAGS) $(Wno) $(PTXAS_FLAGS)
.PHONY: clean
clean:
rm $(BUILD)/*