-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
36 lines (29 loc) · 1.08 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
# Unix commands.
PYTHON := python
NVCC := /usr/local/cuda-8.0/bin/nvcc
NVCC_COMPILE := $(NVCC) -arch=sm_30 \
-gencode=arch=compute_30,code=sm_30 \
-gencode=arch=compute_50,code=sm_50 \
-gencode=arch=compute_52,code=sm_52 \
-gencode=arch=compute_60,code=sm_60 \
-gencode=arch=compute_61,code=sm_61 \
-gencode=arch=compute_61,code=compute_61 -c -o
RM_RF := rm -rf
# Library compilation rules.
NVCC_FLAGS := -x cu -Xcompiler -fPIC -shared
# File structure.
BUILD_DIR := build
INCLUDE_DIRS := include
TORCH_FFI_BUILD := build_ffi.py
MATHUTIL_KERNEL := $(BUILD_DIR)/shiftnet_cuda_kernels.so
TORCH_FFI_TARGET := $(BUILD_DIR)/shiftnet_cuda/_shiftnet_cuda.so
INCLUDE_FLAGS := $(foreach d, $(INCLUDE_DIRS), -I$d)
all: $(TORCH_FFI_TARGET)
$(TORCH_FFI_TARGET): $(MATHUTIL_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) shiftnet_cuda/__init__.py shiftnet_cuda/_shiftnet_cuda.so *.pyc