forked from chrischoy/pytorch_knn_cuda
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
39 lines (30 loc) · 876 Bytes
/
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
# Unix commands.
PYTHON := python
NVCC_COMPILE := nvcc -c -o
RM_RF := rm -rf
# Library compilation rules.
NVCC_FLAGS := -x cu -Xcompiler -fPIC -shared
# File structure.
BUILD_DIR := build
INCLUDE_DIRS := src
TORCH_FFI_BUILD := build_ffi.py
KNN_KERNEL := $(BUILD_DIR)/knn_cuda_kernel.so
TORCH_FFI_TARGET := $(BUILD_DIR)/knn_pytorch/_knn_pytorch.so
INCLUDE_FLAGS := $(foreach d, $(INCLUDE_DIRS), -I$d)
DEBUB := 0
# Debugging
ifeq ($(DEBUG), 1)
COMMON_FLAGS += -DDEBUG -g -O0
NVCC_FLAGS += -G
else
COMMON_FLAGS += -DNDEBUG -O2
endif
all: $(TORCH_FFI_TARGET)
$(TORCH_FFI_TARGET): $(KNN_KERNEL) $(TORCH_FFI_BUILD)
$(PYTHON) $(TORCH_FFI_BUILD)
$(BUILD_DIR)/%.so: src/%.cu
@ mkdir -p $(BUILD_DIR)
# Separate cpp shared library that will be loaded to the extern C ffi
$(NVCC_COMPILE) $@ $? $(NVCC_FLAGS) $(INCLUDE_FLAGS)
clean:
$(RM_RF) $(BUILD_DIR) $(KNN_KERNEL)