-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
191 lines (135 loc) · 5.32 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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Building
# ==============================================================================
all: treebench_mlton.exe treebench_ocaml.exe \
treebench_rust.exe treebench.class c ghc
c: treebench_c.exe treebench_c_bumpalloc.exe treebench_c_bumpalloc_unaligned.exe \
treebench_c_cilk.exe treebench_c_bumpalloc_cilk.exe \
treebench_c_tbb.exe treebench_c_bumpalloc_tbb.exe
ghc: treebench_ghc_strict.exe treebench_ghc_lazy.exe
# Disabling for now, requires beta channel of rust:
# treebench_rust_sys_alloc.exe
# Match whichever version the docker image is using:
RESOLVER=lts-6.23
# RESOLVER=lts-7.1
GHC = stack --install-ghc --resolver=$(RESOLVER) exec ghc -- -rtsopts -threaded
CC = gcc
# clang icc
CXX = g++
# clang++ icpc
# time.h is missing features in c11/c++11:
CPPOPTS = -std=gnu++11 -lrt
COPTS = -std=gnu11 -lrt
PAROPTS = -DPARALLEL
ifeq ($(DEBUG),)
CPPOPTS += -O3 -Wno-cpp
COPTS += -O3 -Wno-cpp
else
CPPOPTS += -O0 -g -DDEBUG
COPTS += -O0 -g -DDEBUG
endif
ghc: treebench_ghc_strict.exe treebench_ghc_lazy.exe
treebench_ghc_strict.exe: treebench.hs
time $(GHC) -odir ghc_strict/ -O2 -rtsopts $^ -o $@
treebench_ghc_lazy.exe: treebench_lazy.hs
time $(GHC) -odir ghc_lazy/ -O2 -rtsopts $^ -o $@
stalin: treebench_stalin.exe
treebench_stalin.exe: treebench_stalin.sc
time stalin -On -Ob -Om -Or -Ot -d -d1 -k -copt -O3 $^
mv treebench_stalin $@
mlton: treebench_mlton.exe
treebench_mlton.exe: treebench.sml
time mlton -output $@ $^
ocaml: treebench_ocaml.exe
treebench_ocaml.exe: treebench.ml
time ocamlopt.opt $^ -o $@
fsharp: treebench_fsharp.exe
treebench_fsharp.exe: treebench.fs
time fsharpc --mlcompatibility $^ -o $@
treebench_rust.exe: treebench.rs
time rustc $^ -o $@ -O
treebench_rust_sys_alloc.exe: treebench_sys_alloc.rs
time rustc $^ -o $@ -O
treebench_c.exe: treebench.c
time $(CC) $(COPTS) $^ -o $@
treebench_c_cilk.exe: treebench.c
time $(CC) $(PAROPTS) $(COPTS) -fcilkplus -lcilkrts $^ -o $@
treebench_c_bumpalloc_cilk.exe: treebench.c
time $(CC) $(PAROPTS) $(COPTS) -fcilkplus -lcilkrts -DBUMPALLOC $^ -o $@
treebench_c_tbb.exe: treebench.c
time $(CXX) $(PAROPTS) $(CPPOPTS) -DTBB_PARALLEL $^ -o $@ -ltbb
treebench_c_bumpalloc_tbb.exe: treebench.c
time $(CXX) $(PAROPTS) $(CPPOPTS) -DTBB_PARALLEL -DBUMPALLOC $^ -o $@ -ltbb
treebench_c_bumpalloc.exe: treebench.c
time $(CC) $(COPTS) -DBUMPALLOC $^ -o $@
# this version uses 1 byte for tags
treebench_c_bumpalloc_unaligned.exe: treebench.c
time $(CC) $(COPTS) -DBUMPALLOC -DUNALIGNED $^ -o $@
treebench.class: treebench.java
time javac $^
# Running
# ==============================================================================
DEPTH = 20
DEFAULT_ITERS = 17
# Or "sum" or "build":
DEFAULT_PASS=add1
DEFAULT_ARGS= $(DEFAULT_PASS) $(DEPTH) $(DEFAULT_ITERS)
run_small:
$(MAKE) DEPTH=6 DEFAULT_ITERS=10 run_all
run_small_core:
$(MAKE) DEPTH=6 DEFAULT_ITERS=10 run_core
# TODO: replace with an hsbencher harness / Criterion:
run_all: all run_core
./treebench_mlton.exe $(DEFAULT_ARGS)
./treebench_ocaml.exe $(DEFAULT_ARGS)
./treebench_rust.exe $(DEFAULT_ARGS)
$(MAKE) run_chez
$(MAKE) run_java
# the main ones we are interested in benchmarking:
run_core: run_c run_ghc
$(MAKE) run_racket
# ./treebench_rust_sys_alloc.exe $(DEPTH)
run_ghc: ghc
./treebench_ghc_strict.exe seq $(DEPTH) $(DEFAULT_ITERS)
./treebench_ghc_lazy.exe $(DEFAULT_ARGS)
LAUNCHER =
run_c: export CILK_NWORKERS = 2
run_c: c
$(LAUNCHER) ./treebench_c.exe $(DEFAULT_ARGS)
$(LAUNCHER) ./treebench_c_cilk.exe $(DEFAULT_ARGS)
$(LAUNCHER) ./treebench_c_bumpalloc_cilk.exe $(DEFAULT_ARGS)
$(LAUNCHER) ./treebench_c_bumpalloc.exe $(DEFAULT_ARGS)
$(LAUNCHER) ./treebench_c_bumpalloc_unaligned.exe $(DEFAULT_ARGS)
# See FIXME in file:
# $(LAUNCHER) ./treebench_c_bumpalloc_tbb.exe $(DEFAULT_ARGS)
# $(LAUNCHER) ./treebench_c_tbb.exe $(DEFAULT_ARGS)
valgrind_c:
$(MAKE) LAUNCHER="valgrind -q" DEPTH=4 run_c
run_chez:
scheme --script treebench.ss $(DEFAULT_ARGS)
run_racket:
racket treebench.rkt $(DEFAULT_ARGS)
run_java: treebench.class
java treebench $(DEFAULT_ARGS)
# Example of how to run with Jemalloc.
# Jemalloc significantly DECREASES throughput, and then does not SCALE WELL:
# For example, on swarm, 2^20 gets 1.63X speedup from 646ms to 396ms, 1 to 18 cores.
# (This is with jemalloc version 3.5.1-2 on ubntu 14.04.)
#
# For comparison, it takes 67ms with the builtin malloc implemntation
# on 1 thread on the same machine. Adding Cilk with 5 layers of
# parallel recursion actually slows it down to 84ms somehow on 1 core.
# That's the best time. The time on >1 core is worse. (Well, it does
# narrowly catch back up at 12 cores.)
run_jemalloc:
# I see a
time CILK_NWORKERS=8 LD_PRELOAD=libjemalloc.so ./treebench_c_parallel.exe add1 20 10
# One especially weird thing is that the SEQUENTIAL version shows a
# slowdown with scaling Cilk workers:
# time CILK_NWORKERS=8 LD_PRELOAD=libjemalloc.so ./treebench_c.exe add1 20 10
# ================================================================================
docker:
docker build -t bintree-bench .
clean:
rm -f *.exe *.o *.hi treebench treebench_lazy *.cmi *.cmo *.cmx
.PHONY: all clean ghc c ghc buildtree stack_build ocaml mlton fsharp
.PHONY: run_chez run_java run_all run_small run_small_core run_c run_ghc