2023-07-15 21:26:48 +00:00
# Interface:
2023-11-19 14:47:19 +00:00
# make all
# make format-all
# make run-all
# make one DIR=06_nuclear_recovery
# make format-one DIR=06_nuclear_recovery
# make run-one DIR=06_nuclear_recovery
# make time-linux-one DIR=06_nuclear_recovery
# make profile-one DIR=06_nuclear_recovery
2023-07-15 21:26:48 +00:00
# Compiler
2023-11-19 14:47:19 +00:00
CC = gcc
2023-07-15 21:26:48 +00:00
# CC=tcc # <= faster compilation
# Main file
2023-11-19 14:47:19 +00:00
SRC = example.c
OUTPUT = example
2023-07-15 21:26:48 +00:00
## Dependencies
2023-11-19 14:47:19 +00:00
SQUIGGLE = ../../squiggle.c
SQUIGGLE_MORE = ../../squiggle_more.c
2023-07-15 21:26:48 +00:00
MATH = -lm
2023-11-19 14:47:19 +00:00
OPENMP = -fopenmp
DEPS = $( SQUIGGLE) $( SQUIGGLE_MORE) $( MATH) $( OPENMP)
2023-07-15 21:26:48 +00:00
## Flags
2023-12-09 18:49:20 +00:00
# DEBUG=-fsanitize=address,undefined
# DEBUG=-g
DEBUG =
WARN = -Wall -Wextra -Wdouble-promotion -Wconversion
2023-11-19 14:47:19 +00:00
STANDARD = -std= c99
2023-07-15 21:26:48 +00:00
WARNINGS = -Wall
2023-11-19 14:47:19 +00:00
OPTIMIZED = -O3 #-Ofast
2023-07-15 21:26:48 +00:00
## Formatter
STYLE_BLUEPRINT = webkit
FORMATTER = clang-format -i -style= $( STYLE_BLUEPRINT)
2023-11-19 14:47:19 +00:00
## make all
all :
2023-12-09 17:31:32 +00:00
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 00_example_template/$( SRC) $( DEPS) -o 00_example_template/$( OUTPUT)
2024-02-02 14:51:17 +00:00
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 02_ci_beta/$( SRC) $( DEPS) -o 02_ci_beta/$( OUTPUT)
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 03_ci_beta_parallel/$( SRC) $( DEPS) -o 03_ci_beta_parallel/$( OUTPUT)
2023-12-09 17:31:32 +00:00
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 04_nuclear_war/$( SRC) $( DEPS) -o 04_nuclear_war/$( OUTPUT)
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 05_burn_10kg_fat/$( SRC) $( DEPS) -o 05_burn_10kg_fat/$( OUTPUT)
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 06_nuclear_recovery/$( SRC) $( DEPS) -o 06_nuclear_recovery/$( OUTPUT)
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 07_algebra/$( SRC) $( DEPS) -o 07_algebra/$( OUTPUT)
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 08_algebra_and_conversion/$( SRC) $( DEPS) -o 08_algebra_and_conversion/$( OUTPUT)
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 09_ergonomic_algebra/$( SRC) $( DEPS) -o 09_ergonomic_algebra/$( OUTPUT)
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 10_twitter_thread_example/$( SRC) $( DEPS) -o 10_twitter_thread_example/$( OUTPUT)
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 11_billion_lognormals_paralell/$( SRC) $( DEPS) -o 11_billion_lognormals_paralell/$( OUTPUT)
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 12_time_to_botec_parallel/$( SRC) $( DEPS) -o 12_time_to_botec_parallel/$( OUTPUT)
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 13_parallelize_min/$( SRC) $( DEPS) -o 13_parallelize_min/$( OUTPUT)
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) 14_check_confidence_interval/$( SRC) $( DEPS) -o 14_check_confidence_interval/$( OUTPUT)
2023-07-15 21:26:48 +00:00
2023-11-19 14:47:19 +00:00
format-all :
$( FORMATTER) 00_example_template/$( SRC)
$( FORMATTER) 01_sample_from_cdf/$( SRC)
2024-02-02 14:51:17 +00:00
$( FORMATTER) 02_ci_beta/$( SRC)
$( FORMATTER) 03_ci_beta_parallel/$( SRC)
2023-11-19 14:47:19 +00:00
$( FORMATTER) 04_nuclear_war/$( SRC)
$( FORMATTER) 05_burn_10kg_fat/$( SRC)
$( FORMATTER) 06_nuclear_recovery/$( SRC)
$( FORMATTER) 07_algebra/$( SRC)
$( FORMATTER) 08_algebra_and_conversion/$( SRC)
$( FORMATTER) 09_ergonomic_algebra/$( SRC)
$( FORMATTER) 10_twitter_thread_example/$( SRC)
2023-11-19 15:50:01 +00:00
$( FORMATTER) 11_billion_lognormals_paralell/$( SRC)
$( FORMATTER) 12_time_to_botec_parallel/$( SRC)
2023-11-29 23:08:36 +00:00
$( FORMATTER) 13_parallelize_min/$( SRC)
2023-11-29 23:21:24 +00:00
$( FORMATTER) 14_check_confidence_interval/$( SRC)
2023-07-15 21:26:48 +00:00
2023-11-19 14:47:19 +00:00
run-all :
00_example_template/$( OUTPUT)
01_sample_from_cdf/$( OUTPUT)
2024-02-02 14:51:17 +00:00
02_ci_beta/$( OUTPUT)
03_ci_beta_parallel/$( OUTPUT)
2023-11-19 14:47:19 +00:00
04_nuclear_war/$( OUTPUT)
05_burn_10kg_fat/$( OUTPUT)
06_nuclear_recovery/$( OUTPUT)
07_algebra/$( OUTPUT)
08_algebra_and_conversion/$( OUTPUT)
09_ergonomic_algebra/$( OUTPUT)
10_twitter_thread_example/$( OUTPUT)
2023-11-19 15:50:01 +00:00
11_billion_lognormals_paralell/$( OUTPUT)
12_time_to_botec_parallel/$( OUTPUT)
2023-11-29 23:08:36 +00:00
13_parallelize_min/$( OUTPUT)
2023-11-29 23:21:24 +00:00
14_check_confidence_interval/$( OUTPUT)
2023-07-15 21:26:48 +00:00
2023-11-19 14:47:19 +00:00
## make one DIR=06_nuclear_recovery
one : $( DIR ) /$( SRC )
2023-12-09 17:31:32 +00:00
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) $( DIR) /$( SRC) $( DEPS) -o $( DIR) /$( OUTPUT)
2023-07-15 21:26:48 +00:00
2023-11-19 14:47:19 +00:00
## make format-one DIR=06_nuclear_recovery
format-one : $( DIR ) /$( SRC )
$( FORMATTER) $( DIR) /$( SRC)
## make run-one DIR=06_nuclear_recovery
run-one : $( DIR ) /$( OUTPUT )
$( DIR) /$( OUTPUT) && echo
## make time-linux-one DIR=06_nuclear_recovery
time-linux-one : $( DIR ) /$( OUTPUT )
@echo "Requires /bin/time, found on GNU/Linux systems" && echo
@echo " Running 100x and taking avg time $( DIR) / $( OUTPUT) "
2023-11-19 15:50:01 +00:00
@t= $$ ( /usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(DIR)/$(OUTPUT); done' 2>& 1 >/dev/null | grep real | awk '{print $$2}' ) ; echo " scale=2; 1000 * $$ t / 100 " | bc | sed "s|^|Time: |" | sed 's|$$|ms|' && echo
2023-07-15 21:26:48 +00:00
2023-11-19 14:47:19 +00:00
## e.g., make profile-linux-one DIR=06_nuclear_recovery
profile-linux-one :
2023-07-15 21:26:48 +00:00
echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar"
echo "Must be run as sudo"
2023-12-09 17:31:32 +00:00
$( CC) $( OPTIMIZED) $( DEBUG) $( WARN) $( DIR) /$( SRC) $( DEPS) -o $( DIR) /$( OUTPUT)
2023-11-19 14:47:19 +00:00
# $(CC) $(SRC) $(DEPS) -o $(OUTPUT)
sudo perf record $( DIR) /$( OUTPUT)
2023-07-15 21:26:48 +00:00
sudo perf report
rm perf.data