-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (57 loc) · 1.84 KB
/
Copy pathMakefile
File metadata and controls
95 lines (57 loc) · 1.84 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
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
IDIR=include
CC=gcc
CFLAGS=-I$(IDIR)
LIBS=-fopenmp
PYTHON=python3
PREPROC=src/preprocess.py
T=8
P=4
SOURCES = $(wildcard src/*.c)
OBJECTS = $(patsubst src/%.c, obj/%.o, $(SOURCES))
TARGETS = $(patsubst src/%.c, bin/%, $(SOURCES))
DEPS = $(wildcard $(IDIR)/*.h)
DATASETS = $(wildcard datasets/*.txt)
PROCESSED = $(patsubst datasets/%.txt, input/%.txt, $(DATASETS))
INPUTS = $(wildcard input/*.txt)
OUTPUT_SEQ = $(patsubst input/%.txt, output/%_seq.txt, $(INPUTS))
OUTPUT_OMP = $(patsubst input/%.txt, output/%_omp.txt, $(INPUTS))
OUTPUT_MPI = $(patsubst input/%.txt, output/%_mpi.txt, $(INPUTS))
CMP_OMP = $(patsubst output/%_omp.txt, %_omp-cmp, $(OUTPUT_OMP))
CMP_MPI = $(patsubst output/%_mpi.txt, %_mpi-cmp, $(OUTPUT_MPI))
.PHONY: all clean compiler linker preprocess
all: $(TARGETS)
clean:
@rm -rf obj/*.o bin/* output/*
compile: $(OBJECTS)
linker: $(TARGETS)
preprocess: $(PROCESSED) $(PREPROC)
obj/%.o: src/%.c $(DEPS)
@$(CC) -c $< -o $@ $(CFLAGS)
bin/%: obj/%.o
@$(CC) $< -o $@ $(LIBS)
obj/bfs_mpi.o: src/bfs_mpi.c $(DEPS)
@mpicc -c $< -o $@ $(CFLAGS)
bin/bfs_mpi: obj/bfs_mpi.o
@mpicc $< -o $@
input/%.txt: datasets/%.txt
@$(PYTHON) $(PREPROC) $< $@ 0
.PHONY: test_seq
test_seq: bin/bfs_seq $(OUTPUT_SEQ)
output/%_seq.txt: input/%.txt bin/bfs_seq
@./run.sh seq $< $@
.PHONY: test_omp
test_omp: bin/bfs_omp $(OUTPUT_OMP)
output/%_omp.txt: input/%.txt bin/bfs_omp
@./run.sh omp $< $@ $(T)
.PHONY: cmp_omp
cmp_omp: $(CMP_OMP)
%_omp-cmp: output/%_omp.txt output/%_seq.txt
@cmp --silent $^ && (echo 'omp output matches seq') || echo '---- FAIL omp ----'
.PHONY: test_mpi
test_mpi: bin/bfs_mpi $(OUTPUT_MPI)
output/%_mpi.txt: input/%.txt bin/bfs_mpi
@./run.sh mpi $< $@ $(P)
.PHONY: cmp_mpi
cmp_mpi: $(CMP_MPI)
%_mpi-cmp: output/%_mpi.txt output/%_seq.txt
@cmp --silent $^ && (echo 'mpi output matches seq') || echo '---- FAIL mpi ----'