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
|
|
|
|
2023-05-29 23:55:57 +00:00
|
|
|
SRC_ONE_THREAD=./samples-one-thread.c
|
|
|
|
OUTPUT_ONE_THREAD=out/samples-one-thread
|
|
|
|
|
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 23:55:57 +00:00
|
|
|
$(CC) $(OPTIMIZED) $(DEBUG) $(SRC_ONE_THREAD) $(OPENMP) $(MATH) -o $(OUTPUT_ONE_THREAD)
|
2023-05-29 21:17:07 +00:00
|
|
|
|
|
|
|
format: $(SRC)
|
|
|
|
$(FORMATTER) $(SRC)
|
|
|
|
|
|
|
|
run: $(SRC) $(OUTPUT)
|
2023-05-30 00:05:18 +00:00
|
|
|
OMP_NUM_THREADS=1 ./$(OUTPUT) && echo
|
2023-05-29 23:55:57 +00:00
|
|
|
./$(OUTPUT_ONE_THREAD)
|
2023-05-29 22:48:25 +00:00
|
|
|
|
2023-05-30 17:01:31 +00:00
|
|
|
multi:
|
|
|
|
OMP_NUM_THREADS=1 ./$(OUTPUT) && echo
|
|
|
|
OMP_NUM_THREADS=2 ./$(OUTPUT) && echo
|
|
|
|
OMP_NUM_THREADS=4 ./$(OUTPUT) && echo
|
2023-06-02 18:50:51 +00:00
|
|
|
OMP_NUM_THREADS=8 ./$(OUTPUT) && echo
|
|
|
|
OMP_NUM_THREADS=16 ./$(OUTPUT) && echo
|
2023-05-30 17:01:31 +00:00
|
|
|
./$(OUTPUT_ONE_THREAD) && echo
|
|
|
|
|
|
|
|
time-linux:
|
|
|
|
echo "Requires /bin/time, found on GNU/Linux systems" && echo
|
2023-05-29 23:40:03 +00:00
|
|
|
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-06-02 18:50:51 +00:00
|
|
|
OMP_NUM_THREADS=8 /bin/time -f "Time: %es" ./$(OUTPUT) && echo
|
|
|
|
OMP_NUM_THREADS=16 /bin/time -f "Time: %es" ./$(OUTPUT) && echo
|
2023-05-29 23:55:57 +00:00
|
|
|
/bin/time -f "Time: %es" ./$(OUTPUT_ONE_THREAD) && echo
|
2023-05-29 21:17:07 +00:00
|
|
|
|
2023-05-30 17:01:31 +00:00
|
|
|
debian-install-dependencies:
|
2023-05-29 21:47:52 +00:00
|
|
|
sudo apt-get install libomp-dev
|