commit 3f9027a530edb48f361e4de3ce781794acdd5d19 parent a81c0df32999af1acf32aa1e86bf60d757838d32 Author: NunoSempere <nuno.sempere@protonmail.com> Date: Sun, 19 Nov 2023 14:32:29 +0000 add one sole makefile for examples using core functionality Diffstat:
41 files changed, 215 insertions(+), 963 deletions(-)
diff --git a/examples/core/00_example_template/example.c b/examples/core/00_example_template/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include <stdint.h> #include <stdio.h> #include <stdlib.h> diff --git a/examples/core/00_example_template/makefile b/examples/core/00_example_template/makefile @@ -1,53 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c -OUTPUT=example - -## Dependencies -MATH=-lm - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 -WARNINGS=-Wall -OPTIMIZED=-O3 #-Ofast -# OPENMP=-fopenmp - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - $(CC) $(OPTIMIZED) $(DEBUG) $(SRC) $(MATH) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - OMP_NUM_THREADS=1 ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/core/01_one_sample/example.c b/examples/core/01_one_sample/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include <stdint.h> #include <stdio.h> #include <stdlib.h> diff --git a/examples/core/01_one_sample/makefile b/examples/core/01_one_sample/makefile @@ -1,53 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c -OUTPUT=example - -## Dependencies -MATH=-lm - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 -WARNINGS=-Wall -OPTIMIZED=-O3 #-Ofast -# OPENMP=-fopenmp - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - $(CC) $(OPTIMIZED) $(DEBUG) $(SRC) $(MATH) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - OMP_NUM_THREADS=1 ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/core/02_many_samples_time_to_botec/example.c b/examples/core/02_many_samples_time_to_botec/example.c @@ -1,55 +0,0 @@ -#include "../../squiggle.h" -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> - -// Estimate functions -double sample_0(uint64_t* seed) -{ - return 0; -} - -double sample_1(uint64_t* seed) -{ - return 1; -} - -double sample_few(uint64_t* seed) -{ - return sample_to(1, 3, seed); -} - -double sample_many(uint64_t* seed) -{ - return sample_to(2, 10, seed); -} - -int main() -{ - // set randomness seed - uint64_t* seed = malloc(sizeof(uint64_t)); - *seed = 1000; // xorshift can't start with 0 - - double p_a = 0.8; - double p_b = 0.5; - double p_c = p_a * p_b; - - int n_dists = 4; - double weights[] = { 1 - p_c, p_c / 2, p_c / 4, p_c / 4 }; - double (*samplers[])(uint64_t*) = { sample_0, sample_1, sample_few, sample_many }; - - int n_samples = 1000000; - double* result_many = (double*)malloc(n_samples * sizeof(double)); - for (int i = 0; i < n_samples; i++) { - result_many[i] = sample_mixture(samplers, weights, n_dists, seed); - } - printf("Mean: %f\n", array_mean(result_many, n_samples)); - - // printf("result_many: ["); - // for(int i=0; i<100; i++){ - // printf("%.2f, ", result_many[i]); - // } - // printf("]\n"); - - free(seed); -} diff --git a/examples/core/02_many_samples_time_to_botec/makefile b/examples/core/02_many_samples_time_to_botec/makefile @@ -1,53 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c -OUTPUT=example - -## Dependencies -MATH=-lm - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 -WARNINGS=-Wall -OPTIMIZED=-O3 #-Ofast -# OPENMP=-fopenmp - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - $(CC) $(OPTIMIZED) $(DEBUG) $(SRC) $(MATH) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do ./$(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/core/02_many_samples_time_to_botec/example b/examples/core/02_time_to_botec/example Binary files differ. diff --git a/examples/core/02_time_to_botec/example.c b/examples/core/02_time_to_botec/example.c @@ -0,0 +1,55 @@ +#include "../../../squiggle.h" +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +// Estimate functions +double sample_0(uint64_t* seed) +{ + return 0; +} + +double sample_1(uint64_t* seed) +{ + return 1; +} + +double sample_few(uint64_t* seed) +{ + return sample_to(1, 3, seed); +} + +double sample_many(uint64_t* seed) +{ + return sample_to(2, 10, seed); +} + +int main() +{ + // set randomness seed + uint64_t* seed = malloc(sizeof(uint64_t)); + *seed = 1000; // xorshift can't start with 0 + + double p_a = 0.8; + double p_b = 0.5; + double p_c = p_a * p_b; + + int n_dists = 4; + double weights[] = { 1 - p_c, p_c / 2, p_c / 4, p_c / 4 }; + double (*samplers[])(uint64_t*) = { sample_0, sample_1, sample_few, sample_many }; + + int n_samples = 1000000; + double* result_many = (double*)malloc(n_samples * sizeof(double)); + for (int i = 0; i < n_samples; i++) { + result_many[i] = sample_mixture(samplers, weights, n_dists, seed); + } + printf("Mean: %f\n", array_mean(result_many, n_samples)); + + // printf("result_many: ["); + // for(int i=0; i<100; i++){ + // printf("%.2f, ", result_many[i]); + // } + // printf("]\n"); + + free(seed); +} diff --git a/examples/core/03_gcc_nested_function/example b/examples/core/03_gcc_nested_function/example Binary files differ. diff --git a/examples/core/03_gcc_nested_function/example.c b/examples/core/03_gcc_nested_function/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include <stdint.h> #include <stdio.h> #include <stdlib.h> diff --git a/examples/core/03_gcc_nested_function/makefile b/examples/core/03_gcc_nested_function/makefile @@ -1,57 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc # required for nested functions -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c -OUTPUT=example - -## Dependencies -MATH=-lm -DEPENDENCIES=$(MATH) -# OPENMP=-fopenmp - -## Flags -DEBUG= #'-g' -STANDARD=-std=gnu99 ## allows for nested functions. -EXTENSIONS= #-fnested-functions -WARNINGS=-Wall -OPTIMIZED=-O3#-Ofast -CFLAGS=$(DEBUG) $(STANDARD) $(EXTENSIONS) $(WARNINGS) $(OPTIMIZED) - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - # gcc -std=gnu99 example.c -lm -o example - $(CC) $(CFLAGS) $(SRC) $(DEPENDENCIES) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/core/06_gamma_beta/example b/examples/core/04_gamma_beta/example Binary files differ. diff --git a/examples/core/04_gamma_beta/example.c b/examples/core/04_gamma_beta/example.c @@ -0,0 +1,44 @@ +#include "../../../squiggle.h" +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +// Estimate functions + +int main() +{ + // set randomness seed + uint64_t* seed = malloc(sizeof(uint64_t)); + *seed = 1000; // xorshift can't start with 0 + + int n = 1000 * 1000; + /* + for (int i = 0; i < n; i++) { + double gamma_0 = sample_gamma(0.0, seed); + // printf("sample_gamma(0.0): %f\n", gamma_0); + } + printf("\n"); + */ + + double* gamma_1_array = malloc(sizeof(double) * n); + for (int i = 0; i < n; i++) { + double gamma_1 = sample_gamma(1.0, seed); + // printf("sample_gamma(1.0): %f\n", gamma_1); + gamma_1_array[i] = gamma_1; + } + printf("gamma(1) summary statistics = mean: %f, std: %f\n", array_mean(gamma_1_array, n), array_std(gamma_1_array, n)); + free(gamma_1_array); + printf("\n"); + + double* beta_1_2_array = malloc(sizeof(double) * n); + for (int i = 0; i < n; i++) { + double beta_1_2 = sample_beta(1, 2.0, seed); + // printf("sample_beta(1.0, 2.0): %f\n", beta_1_2); + beta_1_2_array[i] = beta_1_2; + } + printf("beta(1,2) summary statistics: mean: %f, std: %f\n", array_mean(beta_1_2_array, n), array_std(beta_1_2_array, n)); + free(beta_1_2_array); + printf("\n"); + + free(seed); +} diff --git a/examples/core/16_100_lognormal_samples/example b/examples/core/05_hundred_lognormals/example Binary files differ. diff --git a/examples/core/05_hundred_lognormals/example.c b/examples/core/05_hundred_lognormals/example.c @@ -0,0 +1,18 @@ +#include "../../../squiggle.h" +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +// Estimate functions +int main() +{ + // set randomness seed + uint64_t* seed = malloc(sizeof(uint64_t)); + *seed = 1000; // xorshift can't start with 0 + + for (int i = 0; i < 100; i++) { + double sample = sample_lognormal(0, 10, seed); + printf("%f\n", sample); + } + free(seed); +} diff --git a/examples/core/16_100_lognormal_samples/run-sorted.sh b/examples/core/05_hundred_lognormals/run-sorted.sh diff --git a/examples/core/06_gamma_beta/example.c b/examples/core/06_gamma_beta/example.c @@ -1,44 +0,0 @@ -#include "../../squiggle.h" -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> - -// Estimate functions - -int main() -{ - // set randomness seed - uint64_t* seed = malloc(sizeof(uint64_t)); - *seed = 1000; // xorshift can't start with 0 - - int n = 1000 * 1000; - /* - for (int i = 0; i < n; i++) { - double gamma_0 = sample_gamma(0.0, seed); - // printf("sample_gamma(0.0): %f\n", gamma_0); - } - printf("\n"); - */ - - double* gamma_1_array = malloc(sizeof(double) * n); - for (int i = 0; i < n; i++) { - double gamma_1 = sample_gamma(1.0, seed); - // printf("sample_gamma(1.0): %f\n", gamma_1); - gamma_1_array[i] = gamma_1; - } - printf("gamma(1) summary statistics = mean: %f, std: %f\n", array_mean(gamma_1_array, n), array_std(gamma_1_array, n)); - free(gamma_1_array); - printf("\n"); - - double* beta_1_2_array = malloc(sizeof(double) * n); - for (int i = 0; i < n; i++) { - double beta_1_2 = sample_beta(1, 2.0, seed); - // printf("sample_beta(1.0, 2.0): %f\n", beta_1_2); - beta_1_2_array[i] = beta_1_2; - } - printf("beta(1,2) summary statistics: mean: %f, std: %f\n", array_mean(beta_1_2_array, n), array_std(beta_1_2_array, n)); - free(beta_1_2_array); - printf("\n"); - - free(seed); -} diff --git a/examples/core/06_gamma_beta/makefile b/examples/core/06_gamma_beta/makefile @@ -1,53 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c -OUTPUT=example - -## Dependencies -MATH=-lm - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 -WARNINGS=-Wall -OPTIMIZED=-O3 #-Ofast -# OPENMP=-fopenmp - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - $(CC) $(OPTIMIZED) $(DEBUG) $(SRC) $(MATH) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - OMP_NUM_THREADS=1 ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/core/16_100_lognormal_samples/example.c b/examples/core/16_100_lognormal_samples/example.c @@ -1,18 +0,0 @@ -#include "../../squiggle.h" -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> - -// Estimate functions -int main() -{ - // set randomness seed - uint64_t* seed = malloc(sizeof(uint64_t)); - *seed = 1000; // xorshift can't start with 0 - - for (int i = 0; i < 100; i++) { - double sample = sample_lognormal(0, 10, seed); - printf("%f\n", sample); - } - free(seed); -} diff --git a/examples/core/16_100_lognormal_samples/makefile b/examples/core/16_100_lognormal_samples/makefile @@ -1,53 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c -OUTPUT=example - -## Dependencies -MATH=-lm - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 -WARNINGS=-Wall -OPTIMIZED=-O3 #-Ofast -# OPENMP=-fopenmp - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - $(CC) $(OPTIMIZED) $(DEBUG) $(SRC) $(MATH) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - OMP_NUM_THREADS=1 ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/core/makefile b/examples/core/makefile @@ -0,0 +1,85 @@ +# Interface: +# make all +# make format-all +# make run-all +# make one DIR=01_one_sample +# make format-one DIR=01_one_sample +# make run-one DIR=01_one_sample +# make time-linux-one DIR=01_one_sample +# make profile-one DIR=01_one_sample + +# Compiler +CC=gcc +# CC=tcc # <= faster compilation + +# Main file +SRC=example.c +OUTPUT=example + +## Dependencies +SQUIGGLE=../../squiggle.c +MATH=-lm +DEPS=$(SQUIGGLE) $(MATH) + +## Flags +DEBUG= #'-g' +STANDARD=-std=c99 +WARNINGS=-Wall +OPTIMIZED=-O3 #-Ofast + +## Formatter +STYLE_BLUEPRINT=webkit +FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) + +## make all +all: + $(CC) $(OPTIMIZED) $(DEBUG) 00_example_template/$(SRC) $(DEPS) -o 00_example_template/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 01_one_sample/$(SRC) $(DEPS) -o 01_one_sample/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 02_time_to_botec/$(SRC) $(DEPS) -o 02_time_to_botec/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 03_gcc_nested_function/$(SRC) $(DEPS) -o 03_gcc_nested_function/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 04_gamma_beta/$(SRC) $(DEPS) -o 04_gamma_beta/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 05_hundred_lognormals/$(SRC) $(DEPS) -o 05_hundred_lognormals/$(OUTPUT) + +format-all: + $(FORMATTER) 00_example_template/$(SRC) + $(FORMATTER) 01_one_sample/$(SRC) + $(FORMATTER) 02_time_to_botec/$(SRC) + $(FORMATTER) 03_gcc_nested_function/$(SRC) + $(FORMATTER) 04_gamma_beta/$(SRC) + $(FORMATTER) 05_hundred_lognormals/$(SRC) + +run-all: + 00_example_template/$(OUTPUT) + 01_one_sample/$(OUTPUT) + 02_time_to_botec/$(OUTPUT) + 03_gcc_nested_function/$(OUTPUT) + 04_gamma_beta/$(OUTPUT) + 05_hundred_lognormals/$(OUTPUT) + +## make one DIR=01_one_sample +one: $(DIR)/$(SRC) + $(CC) $(OPTIMIZED) $(DEBUG) $(DIR)/$(SRC) $(DEPS) -o $(DIR)/$(OUTPUT) + +## make format-one DIR=01_one_sample +format-one: $(DIR)/$(SRC) + $(FORMATTER) $(DIR)/$(SRC) + +## make run-one DIR=01_one_sample +run-one: $(DIR)/$(OUTPUT) + $(DIR)/$(OUTPUT) && echo + +## make time-linux-one DIR=01_one_sample +time-linux-one: $(DIR)/$(OUTPUT) + @echo "Requires /bin/time, found on GNU/Linux systems" && echo + @echo "Running 100x and taking avg time $(DIR)/$(OUTPUT)" + @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 using 1 thread: |" | sed 's|$$|ms|' && echo + +## e.g., make profile-linux-one DIR=01_one_sample +profile-linux-one: + echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" + echo "Must be run as sudo" + $(CC) $(OPTIMIZED) $(DEBUG) $(DIR)/$(SRC) $(DEPS) -o $(DIR)/$(OUTPUT) + # $(CC) $(SRC) $(DEPS) -o $(OUTPUT) + sudo perf record $(DIR)/$(OUTPUT) + sudo perf report + rm perf.data diff --git a/examples/more/04_sample_from_cdf_simple/example.c b/examples/more/04_sample_from_cdf_simple/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include "../../squiggle_more.h" #include <math.h> #include <stdint.h> diff --git a/examples/more/05_sample_from_cdf_beta/example.c b/examples/more/05_sample_from_cdf_beta/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include "../../squiggle_more.h" #include <math.h> #include <stdint.h> diff --git a/examples/more/05_sample_from_cdf_beta/makefile b/examples/more/05_sample_from_cdf_beta/makefile @@ -1,58 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -# CC=gcc # required for nested functions -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c ../../squiggle_more.c -OUTPUT=./example - -## Dependencies -MATH=-lm -DEPENDENCIES=$(MATH) -# OPENMP=-fopenmp - -## Flags -VERBOSE=#-v -DEBUG= #'-g' -STANDARD=-std=c99 ## gnu99 allows for nested functions. -EXTENSIONS= #-fnested-functions -WARNINGS=-Wall -OPTIMIZED=-O3#-Ofast -CFLAGS=$(VERBOSE) $(DEBUG) $(STANDARD) $(EXTENSIONS) $(WARNINGS) $(OPTIMIZED) - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - # gcc -std=gnu99 example.c -lm -o example - $(CC) $(CFLAGS) $(SRC) $(DEPENDENCIES) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/more/07_ci_beta/example.c b/examples/more/07_ci_beta/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include "../../squiggle_more.h" #include <stdint.h> #include <stdio.h> diff --git a/examples/more/07_ci_beta/makefile b/examples/more/07_ci_beta/makefile @@ -1,58 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc # required for nested functions -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c ../../squiggle_more.c -OUTPUT=./example - -## Dependencies -OPENMP=-fopenmp -MATH=-lm -DEPENDENCIES=$(MATH) $(OPENMP) -# OPENMP=-fopenmp - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 ## gnu99 allows for nested functions. -EXTENSIONS= #-fnested-functions -WARNINGS=-Wall -OPTIMIZED=-O3#-Ofast -CFLAGS=$(DEBUG) $(STANDARD) $(EXTENSIONS) $(WARNINGS) $(OPTIMIZED) - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - # gcc -std=gnu99 example.c -lm -o example - $(CC) $(CFLAGS) $(SRC) $(DEPENDENCIES) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/more/08_nuclear_war/example.c b/examples/more/08_nuclear_war/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include "../../squiggle_more.h" #include <math.h> #include <stdint.h> diff --git a/examples/more/08_nuclear_war/makefile b/examples/more/08_nuclear_war/makefile @@ -1,53 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c ../../squiggle_more.c -OUTPUT=example - -## Dependencies -MATH=-lm - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 -WARNINGS=-Wall -OPTIMIZED=-O3 #-Ofast -# OPENMP=-fopenmp - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - $(CC) $(OPTIMIZED) $(DEBUG) $(SRC) $(MATH) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - OMP_NUM_THREADS=1 ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/more/09_burn_10kg_fat/example.c b/examples/more/09_burn_10kg_fat/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include "../../squiggle_more.h" #include <math.h> #include <stdint.h> diff --git a/examples/more/09_burn_10kg_fat/makefile b/examples/more/09_burn_10kg_fat/makefile @@ -1,57 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc # required for nested functions -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c ../../squiggle_more.c -OUTPUT=./example - -## Dependencies -MATH=-lm -DEPENDENCIES=$(MATH) -# OPENMP=-fopenmp - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 ## gnu99 allows for nested functions. -EXTENSIONS= #-fnested-functions -WARNINGS=-Wall -OPTIMIZED=-O3#-Ofast -CFLAGS=$(DEBUG) $(STANDARD) $(EXTENSIONS) $(WARNINGS) $(OPTIMIZED) - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - # gcc -std=gnu99 example.c -lm -o example - $(CC) $(CFLAGS) $(SRC) $(DEPENDENCIES) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/more/10_nuclear_recovery/example.c b/examples/more/10_nuclear_recovery/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include "../../squiggle_more.h" #include <math.h> #include <stdint.h> diff --git a/examples/more/10_nuclear_recovery/makefile b/examples/more/10_nuclear_recovery/makefile @@ -1,57 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc # required for nested functions -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c ../../squiggle_more.c -OUTPUT=./example - -## Dependencies -MATH=-lm -DEPENDENCIES=$(MATH) -# OPENMP=-fopenmp - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 ## gnu99 allows for nested functions. -EXTENSIONS= #-fnested-functions -WARNINGS=-Wall -OPTIMIZED=-O3#-Ofast -CFLAGS=$(DEBUG) $(STANDARD) $(EXTENSIONS) $(WARNINGS) $(OPTIMIZED) - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - # gcc -std=gnu99 example.c -lm -o example - $(CC) $(CFLAGS) $(SRC) $(DEPENDENCIES) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/more/11_algebra/example.c b/examples/more/11_algebra/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include "../../squiggle_more.h" #include <math.h> #include <stdint.h> diff --git a/examples/more/11_algebra/makefile b/examples/more/11_algebra/makefile @@ -1,57 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc # required for nested functions -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c ../../squiggle_more.c -OUTPUT=./example - -## Dependencies -MATH=-lm -DEPENDENCIES=$(MATH) -# OPENMP=-fopenmp - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 ## gnu99 allows for nested functions. -EXTENSIONS= #-fnested-functions -WARNINGS=-Wall -OPTIMIZED=-O3#-Ofast -CFLAGS=$(DEBUG) $(STANDARD) $(EXTENSIONS) $(WARNINGS) $(OPTIMIZED) - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - # gcc -std=gnu99 example.c -lm -o example - $(CC) $(CFLAGS) $(SRC) $(DEPENDENCIES) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/more/12_algebra_and_conversion/example.c b/examples/more/12_algebra_and_conversion/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include "../../squiggle_more.h" #include <math.h> #include <stdint.h> diff --git a/examples/more/12_algebra_and_conversion/makefile b/examples/more/12_algebra_and_conversion/makefile @@ -1,57 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc # required for nested functions -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c ../../squiggle_more.c -OUTPUT=./example - -## Dependencies -MATH=-lm -DEPENDENCIES=$(MATH) -# OPENMP=-fopenmp - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 ## gnu99 allows for nested functions. -EXTENSIONS= #-fnested-functions -WARNINGS=-Wall -OPTIMIZED=-O3#-Ofast -CFLAGS=$(DEBUG) $(STANDARD) $(EXTENSIONS) $(WARNINGS) $(OPTIMIZED) - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - # gcc -std=gnu99 example.c -lm -o example - $(CC) $(CFLAGS) $(SRC) $(DEPENDENCIES) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/more/13_ergonomic_algebra/example.c b/examples/more/13_ergonomic_algebra/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include "../../squiggle_more.h" #include <math.h> #include <stdint.h> diff --git a/examples/more/13_ergonomic_algebra/makefile b/examples/more/13_ergonomic_algebra/makefile @@ -1,57 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc # required for nested functions -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c ../../squiggle_more.c -OUTPUT=./example - -## Dependencies -MATH=-lm -DEPENDENCIES=$(MATH) -# OPENMP=-fopenmp - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 ## gnu99 allows for nested functions. -EXTENSIONS= #-fnested-functions -WARNINGS=-Wall -OPTIMIZED=-O3#-Ofast -CFLAGS=$(DEBUG) $(STANDARD) $(EXTENSIONS) $(WARNINGS) $(OPTIMIZED) - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - # gcc -std=gnu99 example.c -lm -o example - $(CC) $(CFLAGS) $(SRC) $(DEPENDENCIES) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/more/14_twitter_thread_example/example.c b/examples/more/14_twitter_thread_example/example.c @@ -1,4 +1,4 @@ -#include "../../squiggle.h" +#include "../../../squiggle.h" #include "../../squiggle_more.h" #include <stdint.h> #include <stdio.h> diff --git a/examples/more/14_twitter_thread_example/makefile b/examples/more/14_twitter_thread_example/makefile @@ -1,57 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc # required for nested functions -# CC=tcc # <= faster compilation - -# Main file -SRC=example.c ../../squiggle.c ../../squiggle_more.c -OUTPUT=./example - -## Dependencies -MATH=-lm -DEPENDENCIES=$(MATH) -# OPENMP=-fopenmp - -## Flags -DEBUG= #'-g' -STANDARD=-std=c99 ## gnu99 allows for nested functions. -EXTENSIONS= #-fnested-functions -WARNINGS=-Wall -OPTIMIZED=-O3#-Ofast -CFLAGS=$(DEBUG) $(STANDARD) $(EXTENSIONS) $(WARNINGS) $(OPTIMIZED) - -## Formatter -STYLE_BLUEPRINT=webkit -FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) - -## make build -build: $(SRC) - # gcc -std=gnu99 example.c -lm -o example - $(CC) $(CFLAGS) $(SRC) $(DEPENDENCIES) -o $(OUTPUT) - -format: $(SRC) - $(FORMATTER) $(SRC) - -run: $(SRC) $(OUTPUT) - ./$(OUTPUT) && echo - -time-linux: - @echo "Requires /bin/time, found on GNU/Linux systems" && echo - - @echo "Running 100x and taking avg time $(OUTPUT)" - @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo - -## Profiling - -profile-linux: - echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar" - echo "Must be run as sudo" - $(CC) $(SRC) $(MATH) -o $(OUTPUT) - sudo perf record ./$(OUTPUT) - sudo perf report - rm perf.data diff --git a/examples/more/04_sample_from_cdf_simple/makefile b/examples/more/makefile