-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
77 lines (62 loc) · 1.91 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
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
SHELL := /bin/bash
ifeq ($(COORDINATOR),mpi)
CC = mpicc
else
CC = gcc
endif
CFLAGS = -std=c99 -g -c -Wall -O1
CFLAGS_OPTIMIZE = -fopenmp -mavx -mavx2 -mfma
LDFLAGS = -fopenmp
# Default
default: | ensure_compute ensure_coordinator
default: convolve_$(COORDINATOR)_$(COMPUTE)
# Utils
.PHONY: check-hashes ensure_compute ensure_coordinator ensure_input
check-hashes:
@bash tools/run_python.sh tools/check_hashes.py
ensure_compute:
ifeq ($(COMPUTE),)
@echo "COMPUTE must be set"
@exit 1
endif
ensure_coordinator:
ifeq ($(COORDINATOR),)
@echo "COORDINATOR must be set"
@exit 1
endif
ensure_test:
ifeq ($(TEST),)
@echo "TEST must be set"
@exit 1
endif
# Task specific targets
.PHONY: task_1 task_2 task_3
task_1: | ensure_test
make run COORDINATOR=naive COMPUTE=naive TEST=$(TEST)
task_2: | ensure_test
make run COORDINATOR=naive COMPUTE=optimized TEST=$(TEST)
task_3: | ensure_test
make run COORDINATOR=mpi COMPUTE=optimized_mpi TEST=$(TEST)
# C targets
src/coordinator_$(COORDINATOR).o: src/coordinator_$(COORDINATOR).c
$(CC) $(CFLAGS) -c $< -o $@
src/compute_$(COMPUTE).o: src/compute_$(COMPUTE).c
$(CC) $(CFLAGS) $(CFLAGS_OPTIMIZE) -c $< -o $@
convolve_$(COORDINATOR)_$(COMPUTE): | check-hashes
convolve_$(COORDINATOR)_$(COMPUTE): src/compute_$(COMPUTE).o src/coordinator_$(COORDINATOR).o src/io.o
$(CC) $(LDFLAGS) $^ -o $@
run: | ensure_compute ensure_coordinator ensure_test
run: convolve_$(COORDINATOR)_$(COMPUTE)
@bash tools/run_python.sh tools/create_tests.py $(shell basename $(TEST))
@rm -f $(TEST)/*/out.bin
ifeq ($(COORDINATOR),mpi)
@bash tools/run_test.sh mpirun ./convolve_$(COORDINATOR)_$(COMPUTE) $(TEST)/input.txt
else
@bash tools/run_test.sh ./convolve_$(COORDINATOR)_$(COMPUTE) $(TEST)/input.txt
endif
@bash tools/check_output.sh $(TEST)
@if [ -f $(TEST)/gifs.json ]; then bash tools/run_python.sh tools/results_to_gif.py $(TEST); fi
# Clean
clean:
rm -f src/coordinator_*.o src/compute_*.o
rm -f convolve_*