-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (47 loc) · 1.75 KB
/
Copy pathMakefile
File metadata and controls
66 lines (47 loc) · 1.75 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
CUDA_INSTALL_PATH ?= /usr/local/cuda
CXX := g++
NVCC := /usr/local/cuda/bin/nvcc
INCLUDES := -I./src -I$(CUDA_INSTALL_PATH)/include
LIBS := -lcuda
NVCCOPTIONS := -arch sm_20 -ptx
COMMONFLAGS += $(INCLUDES)
CXXFLAGS += -std=c++11 -Wall -Wshadow $(COMMONFLAGS)
NVCCFLAGS += $(COMMONFLAGS) $(NVCCOPTIONS)
CXX_SOURCES := $(wildcard src/*.cpp)
CUDA_SOURCES := $(wildcard src/*.cu)
CXX_OBJECTS := $(patsubst src/%.cpp,obj/%.o,$(CXX_SOURCES))
CUDA_OBJECTS := $(patsubst src/%.cu,obj/%.ptx,$(CUDA_SOURCES))
TESTS := $(wildcard test/data/*.in)
PTESTS := $(wildcard benchmark/data/*.in)
.DEFAULT_GOAL := run
.PHONY: install run test clean $(TESTS) $(PTESTS)
.SECONDARY:
install:
mkdir bin obj tmp
obj/%.o: src/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
obj/%.ptx: src/%.cu
$(NVCC) $(NVCCFLAGS) $< -o $@
bin/%: test/%.cpp $(CXX_OBJECTS) $(CUDA_OBJECTS)
$(CXX) -fPIC $(CXXFLAGS) -o $@ $< $(CXX_OBJECTS) $(LIBS)
test: $(TESTS)
$(TESTS): bin/generator bin/run_cpu bin/run_gpu bin/verify
@echo "Running test" $@
./bin/generator < $@ > tmp/input
cat tmp/input > tmp/output
./bin/run_cpu < tmp/input >> tmp/output
./bin/run_gpu < tmp/input >> tmp/output
./bin/verify < tmp/output
benchmark: $(PTESTS)
$(PTESTS): bin/generator bin/run_cpu bin/run_gpu
@echo "Running test" $@
@./bin/generator < $@ > tmp/input
@timeout 5s time -f "CPU: Elapsed real time: %es" ./bin/run_cpu < tmp/input > /dev/null || echo "CPU: Process exceeded 5s time limit"
@timeout 10s time -f "GPU: Elapsed real time: %es" ./bin/run_gpu < tmp/input > /dev/null || echo "GPU: Process exceeded 10s time limit"
run: bin/generator bin/run_gpu
./bin/generator < test/data/0.2.Z2.in > tmp/input
./bin/run_gpu < tmp/input > tmp/output
cat tmp/input
cat tmp/output
clean:
rm -rf bin/* obj/*.o obj/*.ptx tmp/*