Spaces:
Sleeping
Sleeping
Upload Makefile
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576# choose your compiler, e.g. gcc/clang# example override to clang: make run CC=clangCC = gcc
# the most basic way of building that is most likely to work on most systems.PHONY: runrun: run.c $(CC) -O3 -o run run.c -lm $(CC) -O3 -o runq runq.c -lm
# useful for a debug build, can then e.g. analyze with valgrind, example:# $ valgrind --leak-check=full ./run out/model.bin -n 3rundebug: run.c $(CC) -g -o run run.c -lm $(CC) -g -o runq runq.c -lm
# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html# https://simonbyrne.github.io/notes/fastmath/# -Ofast enables all -O3 optimizations.# Disregards strict standards compliance.# It also enables optimizations that are not valid for all standard-compliant programs.# It turns on -ffast-math, -fallow-store-data-races and the Fortran-specific# -fstack-arrays, unless -fmax-stack-var-size is specified, and -fno-protect-parens.# It turns off -fsemantic-interposition.# In our specific application this is *probably* okay to use.PHONY: runfastrunfast: run.c $(CC) -Ofast -o run run.c -lm $(CC) -Ofast -o runq runq.c -lm
# additionally compiles with OpenMP, allowing multithreaded runs# make sure to also enable multiple threads when running, e.g.:# OMP_NUM_THREADS=4 ./run out/model.bin.PHONY: runomprunomp: run.c $(CC) -Ofast -fopenmp -march=native run.c -lm -o run $(CC) -Ofast -fopenmp -march=native runq.c -lm -o runq
.PHONY: win64win64: x86_64-w64-mingw32-gcc -Ofast -D_WIN32 -o run.exe -I. run.c win.c x86_64-w64-mingw32-gcc -Ofast -D_WIN32 -o runq.exe -I. runq.c win.c
# compiles with gnu99 standard flags for amazon linux, coreos, etc. compatibility.PHONY: rungnurungnu: $(CC) -Ofast -std=gnu11 -o run run.c -lm $(CC) -Ofast -std=gnu11 -o runq runq.c -lm
.PHONY: runompgnurunompgnu: $(CC) -Ofast -fopenmp -std=gnu11 run.c -lm -o run $(CC) -Ofast -fopenmp -std=gnu11 runq.c -lm -o runq
# run all tests.PHONY: testtest: pytest
# run only tests for run.c C implementation (is a bit faster if only C code changed).PHONY: testctestc: pytest -k runc
# run the C tests, without touching pytest / python# to increase verbosity level run e.g. as `make testcc VERBOSITY=1`VERBOSITY ?= 0.PHONY: testcctestcc: $(CC) -DVERBOSITY=$(VERBOSITY) -O3 -o testc test.c -lm ./testc
.PHONY: cleanclean: rm -f run rm -f runqMakefileAdded+76