-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (41 loc) · 1.41 KB
/
Makefile
File metadata and controls
51 lines (41 loc) · 1.41 KB
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
#Flags
CXX = g++
FLAGS = -g -O3 -m64 -Wall -shared -std=c++17 -fPIC -fopenmp -pthread
PYBINCLUDE = $(shell python3-config --includes) $(shell python3 -m pybind11 --includes)
FLAGS_DEP = -MMD -MP
DIRS = $(shell find $(shell pwd)/cpp/* -type d)
CXXINCLUDE := $(patsubst %,-I %,$(DIRS))
#PATH
MODULE_SHARE_OBJS_RLT_DIR = cpp
MODULE_SHARE_OBJS_ABS_DIR = $(shell pwd)/$(MODULE_SHARE_OBJS_RLT_DIR)
PYTHONPATH := $(MODULE_SHARE_OBJS_ABS_DIR):$(PYTHONPATH)
export PYTHONPATH
#Includes
CPP_FILE = $(wildcard $(MODULE_SHARE_OBJS_RLT_DIR)/*/*.cpp)
MODULE_SHARE_OBJS = $(MODULE_SHARE_OBJS_RLT_DIR)/_cgpy$(shell python3-config --extension-suffix)
TARGET = $(CPP_FILE:.cpp=.o)
#dependency
DEPS = $(TARGET:.o=.d)
-include $(DEPS)
#Makefile
.PHONY: all demo test clean
default: all
all: $(MODULE_SHARE_OBJS)
$(MODULE_SHARE_OBJS): $(TARGET)
$(CXX) $(FLAGS) $^ -o $@
$(TARGET): %.o : %.cpp
$(CXX) $(FLAGS) $(FLAGS_DEP) $(PYBINCLUDE) $(CXXINCLUDE) -c $< -o $@
demo: $(MODULE_SHARE_OBJS)
mkdir -p demo/results
python3 demo/demo_matrix.py | tee demo/results/matrix_performance.txt
python3 demo/demo_cg_method.py | tee demo/results/cg_method_performance.txt
test: $(MODULE_SHARE_OBJS)
python3 -m pytest -v tests/test_matrix.py
python3 -m pytest -v tests/test_cg_method.py
clean:
rm -rf *.so cpp/*.so cpp/*/*.so
rm -rf cpp/*/*.o
rm -rf */__pycache__ cpp/*/__pycache__
rm -rf .pytest_cache */.pytest_cache
rm -rf demo/results
rm -rf cpp/*/*.d