-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·135 lines (103 loc) · 3.69 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
CC = gcc
AR = ar
CPPFLAGS += -I include/
CFLAGS += -g -Wall -O2
LDFLAGS += $(LIBS) -lz -lm -lpthread
BUILD_DIR = lib
# change the tool name to what you want
BINARY = openfish
STATICLIB = $(BUILD_DIR)/libopenfish.a
OBJ = $(BUILD_DIR)/misc.o \
$(BUILD_DIR)/error.o \
$(BUILD_DIR)/decode_cpu.o \
$(BUILD_DIR)/openfish.o \
$(BUILD_DIR)/beam_search.o \
GPU_LIB =
# add more objects here if needed
VERSION = `git describe --tags`
# make asan=1 enables address sanitiser
ifdef asan
CFLAGS += -fsanitize=address -fno-omit-frame-pointer
LDFLAGS += -fsanitize=address -fno-omit-frame-pointer
endif
# make accel=1 enables the acceelerator (CUDA,OpenCL,FPGA etc if implemented)
ifdef cuda
CUDA_ROOT ?= /usr/local/cuda
CUDA_LIB ?= $(CUDA_ROOT)/lib64
CUDA_OBJ += $(BUILD_DIR)/decode_cuda.o $(BUILD_DIR)/beam_search_cuda.o $(BUILD_DIR)/scan_cuda.o
NVCC ?= $(CUDA_ROOT)/bin/nvcc
CUDA_CFLAGS += -g -O2 -lineinfo $(CUDA_ARCH) -Xcompiler -Wall
CUDA_LDFLAGS = -L$(CUDA_LIB) -lcudart_static -lrt -ldl
GPU_LIB = $(BUILD_DIR)/cuda.a
CPPFLAGS += -DHAVE_CUDA=1
else ifdef rocm
ROCM_ROOT ?= /opt/rocm
ROCM_LIB ?= $(ROCM_ROOT)/lib
HIPCC ?= $(ROCM_ROOT)/bin/hipcc
ROCM_CFLAGS += -g -Wall $(ROCM_ARCH)
ROCM_OBJ += $(BUILD_DIR)/decode_hip.o $(BUILD_DIR)/beam_search_hip.o $(BUILD_DIR)/scan_hip.o
GPU_LIB = $(BUILD_DIR)/hip_code.a
ROCM_LDFLAGS = -L$(ROCM_LIB) -lamdhip64 -lrt -ldl
CPPFLAGS += -DHAVE_ROCM=1
else
GPU_LIB = $(BUILD_DIR)/cpu_decoy.a
endif
ifdef bench
CPPFLAGS += -DBENCH=1
endif
ifdef debug
CPPFLAGS += -DDEBUG=1
endif
.PHONY: clean distclean test
$(BINARY): $(BUILD_DIR)/main.o $(STATICLIB)
$(CC) $(CFLAGS) $(BUILD_DIR)/main.o $(STATICLIB) $(LDFLAGS) $(CUDA_LDFLAGS) $(ROCM_LDFLAGS) -o $@
$(STATICLIB): $(OBJ) $(GPU_LIB)
cp $(GPU_LIB) $@
$(AR) rcs $@ $(OBJ)
$(BUILD_DIR)/main.o: src/main.c include/openfish/openfish.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(BUILD_DIR)/misc.o: src/misc.c src/misc.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(BUILD_DIR)/error.o: src/error.c include/openfish/openfish_error.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(BUILD_DIR)/signal_prep.o: src/signal_prep.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(BUILD_DIR)/decode_cpu.o: src/decode_cpu.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(BUILD_DIR)/beam_search.o: src/beam_search.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(BUILD_DIR)/openfish.o: src/openfish.c include/openfish/openfish.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
# cpu decoy
$(BUILD_DIR)/cpu_decoy.a:
rm -f $@
$(AR) -r $@
# cuda
$(BUILD_DIR)/cuda.a: $(BUILD_DIR)/cuda_code.o $(CUDA_OBJ)
$(AR) rcs $@ $^
$(BUILD_DIR)/cuda_code.o: $(CUDA_OBJ)
$(NVCC) $(CUDA_CFLAGS) -dlink $^ -o $@
$(BUILD_DIR)/decode_cuda.o: src/decode_cuda.cu
$(NVCC) -x cu $(CUDA_CFLAGS) $(CPPFLAGS) -rdc=true -c $< -o $@
$(BUILD_DIR)/beam_search_cuda.o: src/beam_search_cuda.cu
$(NVCC) -x cu $(CUDA_CFLAGS) $(CPPFLAGS) -rdc=true -c $< -o $@
$(BUILD_DIR)/scan_cuda.o: src/scan_cuda.cu
$(NVCC) -x cu $(CUDA_CFLAGS) $(CPPFLAGS) -rdc=true -c $< -o $@
# hip
$(BUILD_DIR)/hip_code.a: $(ROCM_OBJ)
$(HIPCC) $(ROCM_CFLAGS) --emit-static-lib -fPIC -fgpu-rdc --hip-link $^ -o $@
$(BUILD_DIR)/beam_search_hip.o: src/beam_search_hip.hip
$(HIPCC) -x hip $(ROCM_CFLAGS) $(CPPFLAGS) -fgpu-rdc -fPIC -c $< -o $@
$(BUILD_DIR)/scan_hip.o: src/scan_hip.hip
$(HIPCC) -x hip $(ROCM_CFLAGS) $(CPPFLAGS) -fgpu-rdc -fPIC -c $< -o $@
$(BUILD_DIR)/decode_hip.o: src/decode_hip.hip
$(HIPCC) -x hip $(ROCM_CFLAGS) $(CPPFLAGS) -fgpu-rdc -fPIC -c $< -o $@
clean:
rm -rf $(BINARY) $(BUILD_DIR)/*
# Delete all gitignored files (but not directories)
distclean: clean
git clean -f -X
rm -rf $(BINARY) $(BUILD_DIR)/* autom4te.cache
# make test with run a simple test
test: $(BINARY)
./test/test.sh