2023-05-29 21:17:07 +00:00
|
|
|
# Interface:
|
|
|
|
# make
|
|
|
|
# make build
|
|
|
|
# make format
|
|
|
|
# make run
|
|
|
|
|
|
|
|
# Compiler
|
2023-05-29 22:48:25 +00:00
|
|
|
CC=gcc
|
2023-05-29 21:17:07 +00:00
|
|
|
# CC=tcc # <= faster compilation
|
|
|
|
|
|
|
|
# Main file
|
|
|
|
SRC=samples.c
|
2023-05-29 21:50:00 +00:00
|
|
|
OUTPUT=out/samples
|
2023-05-29 21:17:07 +00:00
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
# Has no dependencies
|
2023-05-29 21:59:17 +00:00
|
|
|
MATH=-lm
|
2023-05-29 21:17:07 +00:00
|
|
|
|
|
|
|
## Flags
|
|
|
|
DEBUG= #'-g'
|
|
|
|
STANDARD=-std=c99
|
|
|
|
WARNINGS=-Wall
|
|
|
|
OPTIMIZED=-O3 #-O3 actually gives better performance than -Ofast, at least for this version
|
|
|
|
OPENMP=-fopenmp
|
2023-05-29 21:59:17 +00:00
|
|
|
|
2023-05-29 21:17:07 +00:00
|
|
|
## Formatter
|
|
|
|
STYLE_BLUEPRINT=webkit
|
|
|
|
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
|
|
|
|
|
|
|
|
## make build
|
|
|
|
build: $(SRC)
|
2023-05-29 21:59:17 +00:00
|
|
|
$(CC) $(OPTIMIZED) $(DEBUG) $(SRC) $(OPENMP) $(MATH) -o $(OUTPUT)
|
2023-05-29 21:17:07 +00:00
|
|
|
|
|
|
|
#fast: Has been removed, compilation of "build" is very fast and it outputs optimized code by default
|
|
|
|
|
|
|
|
format: $(SRC)
|
|
|
|
$(FORMATTER) $(SRC)
|
|
|
|
|
|
|
|
run: $(SRC) $(OUTPUT)
|
2023-05-29 22:48:25 +00:00
|
|
|
OMP_NUM_THREADS=1 ./$(OUTPUT)
|
2023-05-29 23:40:03 +00:00
|
|
|
|
|
|
|
multi: $(SRC) $(OUTPUT)
|
|
|
|
OMP_NUM_THREADS=1 ./$(OUTPUT) && echo
|
|
|
|
OMP_NUM_THREADS=2 ./$(OUTPUT) && echo
|
2023-05-29 22:48:25 +00:00
|
|
|
OMP_NUM_THREADS=4 ./$(OUTPUT)
|
|
|
|
|
2023-05-29 23:40:03 +00:00
|
|
|
time:
|
|
|
|
OMP_NUM_THREADS=1 /bin/time -f "Time: %es" ./$(OUTPUT) && echo
|
|
|
|
OMP_NUM_THREADS=2 /bin/time -f "Time: %es" ./$(OUTPUT) && echo
|
|
|
|
OMP_NUM_THREADS=4 /bin/time -f "Time: %es" ./$(OUTPUT) && echo
|
2023-05-29 21:17:07 +00:00
|
|
|
|
2023-05-29 21:50:00 +00:00
|
|
|
linux-install:
|
2023-05-29 21:47:52 +00:00
|
|
|
sudo apt-get install libomp-dev
|