Spaces:
Running
Running
Upload Makefile
Browse files
Makefile
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# choose your compiler, e.g. gcc/clang
|
2 |
+
# example override to clang: make run CC=clang
|
3 |
+
CC = gcc
|
4 |
+
|
5 |
+
# the most basic way of building that is most likely to work on most systems
|
6 |
+
.PHONY: run
|
7 |
+
run: run.c
|
8 |
+
$(CC) -O3 -o run run.c -lm
|
9 |
+
$(CC) -O3 -o runq runq.c -lm
|
10 |
+
|
11 |
+
# useful for a debug build, can then e.g. analyze with valgrind, example:
|
12 |
+
# $ valgrind --leak-check=full ./run out/model.bin -n 3
|
13 |
+
rundebug: run.c
|
14 |
+
$(CC) -g -o run run.c -lm
|
15 |
+
$(CC) -g -o runq runq.c -lm
|
16 |
+
|
17 |
+
# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
|
18 |
+
# https://simonbyrne.github.io/notes/fastmath/
|
19 |
+
# -Ofast enables all -O3 optimizations.
|
20 |
+
# Disregards strict standards compliance.
|
21 |
+
# It also enables optimizations that are not valid for all standard-compliant programs.
|
22 |
+
# It turns on -ffast-math, -fallow-store-data-races and the Fortran-specific
|
23 |
+
# -fstack-arrays, unless -fmax-stack-var-size is specified, and -fno-protect-parens.
|
24 |
+
# It turns off -fsemantic-interposition.
|
25 |
+
# In our specific application this is *probably* okay to use
|
26 |
+
.PHONY: runfast
|
27 |
+
runfast: run.c
|
28 |
+
$(CC) -Ofast -o run run.c -lm
|
29 |
+
$(CC) -Ofast -o runq runq.c -lm
|
30 |
+
|
31 |
+
# additionally compiles with OpenMP, allowing multithreaded runs
|
32 |
+
# make sure to also enable multiple threads when running, e.g.:
|
33 |
+
# OMP_NUM_THREADS=4 ./run out/model.bin
|
34 |
+
.PHONY: runomp
|
35 |
+
runomp: run.c
|
36 |
+
$(CC) -Ofast -fopenmp -march=native run.c -lm -o run
|
37 |
+
$(CC) -Ofast -fopenmp -march=native runq.c -lm -o runq
|
38 |
+
|
39 |
+
.PHONY: win64
|
40 |
+
win64:
|
41 |
+
x86_64-w64-mingw32-gcc -Ofast -D_WIN32 -o run.exe -I. run.c win.c
|
42 |
+
x86_64-w64-mingw32-gcc -Ofast -D_WIN32 -o runq.exe -I. runq.c win.c
|
43 |
+
|
44 |
+
# compiles with gnu99 standard flags for amazon linux, coreos, etc. compatibility
|
45 |
+
.PHONY: rungnu
|
46 |
+
rungnu:
|
47 |
+
$(CC) -Ofast -std=gnu11 -o run run.c -lm
|
48 |
+
$(CC) -Ofast -std=gnu11 -o runq runq.c -lm
|
49 |
+
|
50 |
+
.PHONY: runompgnu
|
51 |
+
runompgnu:
|
52 |
+
$(CC) -Ofast -fopenmp -std=gnu11 run.c -lm -o run
|
53 |
+
$(CC) -Ofast -fopenmp -std=gnu11 runq.c -lm -o runq
|
54 |
+
|
55 |
+
# run all tests
|
56 |
+
.PHONY: test
|
57 |
+
test:
|
58 |
+
pytest
|
59 |
+
|
60 |
+
# run only tests for run.c C implementation (is a bit faster if only C code changed)
|
61 |
+
.PHONY: testc
|
62 |
+
testc:
|
63 |
+
pytest -k runc
|
64 |
+
|
65 |
+
# run the C tests, without touching pytest / python
|
66 |
+
# to increase verbosity level run e.g. as `make testcc VERBOSITY=1`
|
67 |
+
VERBOSITY ?= 0
|
68 |
+
.PHONY: testcc
|
69 |
+
testcc:
|
70 |
+
$(CC) -DVERBOSITY=$(VERBOSITY) -O3 -o testc test.c -lm
|
71 |
+
./testc
|
72 |
+
|
73 |
+
.PHONY: clean
|
74 |
+
clean:
|
75 |
+
rm -f run
|
76 |
+
rm -f runq
|