From 16edfe6364b030375ecd217fbca1226c6365476e Mon Sep 17 00:00:00 2001 From: Andrej Karpathy Date: Mon, 24 Jul 2023 21:50:04 +0000 Subject: [PATCH] add a simple makefile --- Makefile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..768ce56 --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ + +# the most basic way of building that is most likely to work on most systems +.PHONY: run +run: run.c + gcc -O3 -o run run.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: runfast +runfast: run.c + gcc -Ofast -o run run.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: runomp +runomp: run.c + gcc -Ofast -fopenmp -march=native run.c -lm -o run + +.PHONY: clean +clean: + rm -f run