-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (51 loc) · 1.55 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
OBJDIR := build
SOURCEDIR := src
INCLUDEDIR := include
TEXDIR := report
BENCHDIR := perf/data
HOST := $(shell hostname)
CC := gcc
CFLAGS += -I$(INCLUDEDIR) -Wall -Wextra -O2 -lm
TEXFLAGS := -output-directory=$(TEXDIR) -interaction=nonstopmode -shell-escape
ifneq ($(HOST),boron)
CFLAGS += -lrt -std=gnu99
endif
ifneq ($(debug),)
CFLAGS += -DDEBUG
endif
objs := common grav
OBJECTS := $(objs:%=$(OBJDIR)/\%-%.o)
.PHONY: singlethreaded multithreaded report bench clean cleanbench cleanall
all: singlethreaded multithreaded
#reproducibility
ifneq ($(seed),)
CFLAGS += -DRAND_SEED=$(seed)
else
bench: CFLAGS += -DRAND_SEED=42
endif
bench: clean perf/bench.sh perf/data
$(MAKE) all
report: $(TEXDIR)/report.pdf
objs: $(OBJECTS) $(OBJDIR)/multi-quadratic.o $(OBJDIR)/single-quadratic.o $(OBJDIR)/single-barneshut.o $(OBJDIR)/multi-barneshut.o
$(TEXDIR)/%.pdf: $(TEXDIR)/%.tex
lualatex $(TEXFLAGS) $<
perf/data:
mkdir $@
singlethreaded: CFLAGS += -Wno-unknown-pragmas
singlethreaded: single-quadratic single-barneshut
multithreaded: CFLAGS += -fopenmp
multithreaded: multi-quadratic multi-barneshut
cleanall: clean cleanbench
rm -rf {single,multi}-{barneshut,quadratic}
clean:
rm -rf $(OBJDIR)/*
cleanbench:
rm -rf $(BENCHDIR)/$(HOST)-*
%-quadratic: $(OBJDIR)/%-quadratic.o $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^
%-barneshut: $(OBJDIR)/%-barneshut.o $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^
$(OBJDIR)/single-%.o: $(SOURCEDIR)/%.c $(INCLUDEDIR)/%.h
$(CC) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/multi-%.o: $(SOURCEDIR)/%.c $(INCLUDEDIR)/%.h
$(CC) $(CFLAGS) -c -o $@ $<