forked from escalab/GPTPU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile_gptpu
114 lines (107 loc) · 4.46 KB
/
Makefile_gptpu
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
CC = g++
CXXFLAGS = --std=c++11 -O3 -g
CFLAGS = -shared -fPIC -I/usr/include/python3.5m/ -fopenmp -lpthread
CFLAGS += -DCURRENT_DIR=\"$(shell pwd)\"
LINK = -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -L~/build -Lcnpy
LD = -lgptpu -ldl -I/opt/OpenBLAS/include -L/opt/OpenBLAS/lib -lopenblas -lpthread
SRC = $(wildcard ./src/gptpu.cc ./src/make_temp.cc ./src/offset.cc ./src/make_model.cc ./src/utils.cc ./src/fifo.cc)
OBJ = $(subst ./src, ., $(SRC:.cc=.o))
uname_m:=$(shell uname -m)
all: main libgptpu.so install demo openctpu_demo opt1 opt2 opt3 simple simple2 test_pagerank test_hotspot#demo_multi#coral
DIR = /mnt/ramdisk
TMP_DIR = /usr/local/gptpu
op=mv imv mm vs tanh relu add sub mul mean max crop ext conv black maxpool push
main:
mkdir -p ./obj ./data
$(foreach var,$(op), mkdir -p $(DIR)/$(var)_model_tflite;)
## edgetpu plugin
cp ./src/edgetpu_plugin/Mymodel_utils.cc ./edgetpu/src/cpp/examples/
cp ./src/edgetpu_plugin/Mymodel_utils.h ./edgetpu/src/cpp/examples/
cp ./src/edgetpu_plugin/dense.cc ./edgetpu/src/cpp/examples/
cp ./src/edgetpu_plugin/dense.h ./edgetpu/src/cpp/examples/
cp ./src/edgetpu_plugin/Mymultiple_tpus_performance_analysis.cc ./edgetpu/src/cpp/tools/
## edgetpu plugin
ifeq ("$(uname_m)", "x86_64")
$(MAKE) -C ./edgetpu # make dense.cc API wrapper
sudo cp ./libdense.so /usr/local/lib
sudo cp ./dense.h /usr/local/include
endif
ifeq ("$(uname_m)", "aarch64")
@echo "Moving libdense_arm.so, make sure it is the latest version. Should be generated by k8 platform using cross-compiling. Coral edgetpu is aarch64."
sudo cp ./libdense_arm.so /usr/local/lib
sudo cp ./dense.h /usr/local/include
endif
coral:
ifeq ("$(uname_m)", "x86_64") # on x86-64 platform, do cross-compiling for aarch64
$(MAKE) -C ./edgetpu CPU=aarch64
endif
libgptpu.so: $(OBJ)
ifeq ("$(uname_m)", "x86_64")
$(CC) $(CFLAGS) $(CXXFLAGS) $(OBJ) $(LINK) -ldense -o ./$@ # '$@ = libgptpu.so'
endif
ifeq ("$(uname_m)", "aarch64")
$(CC) $(CFLAGS) $(CXXFLAGS) $(OBJ) $(LINK) -ldense_arm -o ./$@ # '$@ = libgptpu.so'
endif
$(OBJ): $(SRC) # compare $(OBJ) with $(SRC) to see if any update on $(SRC). Do nothing if no updates.
$(CC) $(CFLAGS) $(CXXFLAGS) -c $^ # '$^' = compile $(SRC) together at once
install:
sudo cp ./libgptpu.so /usr/local/lib
sudo cp ./src/gptpu.h /usr/local/include
sudo mkdir -p $(TMP_DIR)/template/
$(foreach var,$(op), sudo mkdir -p $(TMP_DIR)/$(var)_model_tflite;)
sudo cp ./template/* $(TMP_DIR)/template
$(foreach var,$(op), sudo cp -r $(DIR)/$(var)_model_tflite/ $(TMP_DIR)/$(var)_model_tflite/;)
demo: demo.o
$(CC) demo.o $(LD) -o ./obj/demo
demo.o: ./src/demo.cc
$(CC) $(CXXFLAGS) -c ./src/demo.cc
openctpu_demo: openctpu.o
$(CC) openctpu.o $(LD) -o ./obj/openctpu
openctpu.o: ./src/openctpu.cc
$(CC) $(CXXFLAGS) -c ./src/openctpu.cc
opt1: opt1.o
$(CC) search_mm2conv_optimal.o $(LD) -o ./obj/search_mm2conv_optimal
opt1.o: ./src/search_mm2conv_optimal.cc
$(CC) $(CXXFLAGS) -c ./src/search_mm2conv_optimal.cc
opt2: opt2.o
$(CC) search_256mmBlk_optimal.o $(LD) -o ./obj/search_256mmBlk_optimal
opt2.o: ./src/search_256mmBlk_optimal.cc
$(CC) $(CXXFLAGS) -c ./src/search_256mmBlk_optimal.cc
opt3: opt3.o
$(CC) search_random_conv_optimal.o $(LD) -o ./obj/search_random_conv_optimal
opt3.o: ./src/search_random_conv_optimal.cc
$(CC) $(CXXFLAGS) -c ./src/search_random_conv_optimal.cc
simple: simple.o
$(CC) run_a_model.o $(LD) -o ./obj/run_a_model
simple.o:
$(CC) $(CXXFLAGS) -c ./src/run_a_model.cc
simple2: simple2.o
$(CC) run_a_model_16x8.o $(LD) -o ./obj/run_a_model_16x8
simple2.o:
$(CC) $(CXXFLAGS) -c ./src/run_a_model_16x8.cc
test_pagerank: test_pagerank.o
$(CC) run_a_pagerank.o $(LD) -o ./obj/run_a_pagerank
test_pagerank.o:
$(CC) $(CXXFLAGS) -c ./src/run_a_pagerank.cc
test_hotspot: test_hotspot.o
$(CC) run_a_hotspot.o $(LD) -o ./obj/run_a_hotspot
test_hotspot.o:
$(CC) $(CXXFLAGS) -c ./src/run_a_hotspot.cc
# === out-dated ===
#demo_multi:
# $(CC) $(CXXFLAGS) ./src/demo_multithread.cc $(LD) -o ./obj/demo_multithread
clean:
rm -f ./*.o ./obj/* ./libdense.so ./libgptpu.so ./libdense_arm.so
rm -rf ./data ./edgetpu/bazel-* ./edgetpu/build ./edgetpu/dist ./edgetpu/edgetpu/swig/*.so ./edgetpu/edgetpu/swig/edgetpu_cpp_wrapper.py
sudo rm -rf $(TMP_DIR)/*
sudo rm -rf $(DIR)/*
# clean edgetpu
ifeq ("$(uname_m)", "x86_64")
rm -rf ./edgetpu/out
endif
ifeq ("$(uname_m)", "aarch64")
mv ./edgetpu/out/aarch64/examples/dense ./
rm -rf ./edgeput/out
mkdir -p ./edgetpu/out/aarch64/examples/
mv ./dense ./edgetpu/out/aarch64/examples/
endif