commit 0a660ce6a593505d3491a3c01ccda3df13337163 parent f6af0c33fa611100f113a1bc50ba8c1da2c3c780 Author: NunoSempere <nuno.sempere@protonmail.com> Date: Sun, 19 Nov 2023 15:50:01 +0000 slighgly simplify parallel time to botec example Diffstat:
13 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/examples/more/00_example_template/example b/examples/more/00_example_template/example Binary files differ. diff --git a/examples/more/01_sample_from_cdf/example b/examples/more/01_sample_from_cdf/example Binary files differ. diff --git a/examples/more/02_sample_from_cdf_beta/example b/examples/more/02_sample_from_cdf_beta/example Binary files differ. diff --git a/examples/more/03_ci_beta/example b/examples/more/03_ci_beta/example Binary files differ. diff --git a/examples/more/04_nuclear_war/example b/examples/more/04_nuclear_war/example Binary files differ. diff --git a/examples/more/05_burn_10kg_fat/example b/examples/more/05_burn_10kg_fat/example Binary files differ. diff --git a/examples/more/06_nuclear_recovery/example b/examples/more/06_nuclear_recovery/example Binary files differ. diff --git a/examples/more/07_algebra/example b/examples/more/07_algebra/example Binary files differ. diff --git a/examples/more/08_algebra_and_conversion/example b/examples/more/08_algebra_and_conversion/example Binary files differ. diff --git a/examples/more/09_ergonomic_algebra/example b/examples/more/09_ergonomic_algebra/example Binary files differ. diff --git a/examples/more/10_twitter_thread_example/example b/examples/more/10_twitter_thread_example/example Binary files differ. diff --git a/examples/more/12_time_to_botec_parallel/example.c b/examples/more/12_time_to_botec_parallel/example.c @@ -1,6 +1,5 @@ #include "../../../squiggle.h" #include "../../../squiggle_more.h" -#include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -22,12 +21,9 @@ int main() return sample_mixture(samplers, weights, n_dists, seed); } - int n_samples = 1000 * 1000; - int n_threads = 16; + int n_samples = 1000 * 1000, n_threads = 16; double* results = malloc(n_samples * sizeof(double)); parallel_sampler(sampler_result, results, n_threads, n_samples); - - double avg = array_sum(results, n_samples)/n_samples; - printf("Avg: %f", avg); + printf("Avg: %f", array_sum(results, n_samples)/n_samples); free(results); } diff --git a/examples/more/makefile b/examples/more/makefile @@ -35,17 +35,19 @@ 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_sample_from_cdf/$(SRC) $(DEPS) -o 01_sample_from_cdf/$(OUTPUT) - $(CC) $(OPTIMIZED) $(DEBUG) 02_sample_from_cdf_beta/$(SRC) $(DEPS) -o 02_sample_from_cdf_beta/$(OUTPUT) - $(CC) $(OPTIMIZED) $(DEBUG) 03_ci_beta/$(SRC) $(DEPS) -o 03_ci_beta/$(OUTPUT) - $(CC) $(OPTIMIZED) $(DEBUG) 04_nuclear_war/$(SRC) $(DEPS) -o 04_nuclear_war/$(OUTPUT) - $(CC) $(OPTIMIZED) $(DEBUG) 05_burn_10kg_fat/$(SRC) $(DEPS) -o 05_burn_10kg_fat/$(OUTPUT) - $(CC) $(OPTIMIZED) $(DEBUG) 06_nuclear_recovery/$(SRC) $(DEPS) -o 06_nuclear_recovery/$(OUTPUT) - $(CC) $(OPTIMIZED) $(DEBUG) 07_algebra/$(SRC) $(DEPS) -o 07_algebra/$(OUTPUT) - $(CC) $(OPTIMIZED) $(DEBUG) 08_algebra_and_conversion/$(SRC) $(DEPS) -o 08_algebra_and_conversion/$(OUTPUT) - $(CC) $(OPTIMIZED) $(DEBUG) 09_ergonomic_algebra/$(SRC) $(DEPS) -o 09_ergonomic_algebra/$(OUTPUT) - $(CC) $(OPTIMIZED) $(DEBUG) 10_twitter_thread_example/$(SRC) $(DEPS) -o 10_twitter_thread_example/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 00_example_template/$(SRC) $(DEPS) -o 00_example_template/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 01_sample_from_cdf/$(SRC) $(DEPS) -o 01_sample_from_cdf/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 02_sample_from_cdf_beta/$(SRC) $(DEPS) -o 02_sample_from_cdf_beta/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 03_ci_beta/$(SRC) $(DEPS) -o 03_ci_beta/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 04_nuclear_war/$(SRC) $(DEPS) -o 04_nuclear_war/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 05_burn_10kg_fat/$(SRC) $(DEPS) -o 05_burn_10kg_fat/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 06_nuclear_recovery/$(SRC) $(DEPS) -o 06_nuclear_recovery/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 07_algebra/$(SRC) $(DEPS) -o 07_algebra/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 08_algebra_and_conversion/$(SRC) $(DEPS) -o 08_algebra_and_conversion/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 09_ergonomic_algebra/$(SRC) $(DEPS) -o 09_ergonomic_algebra/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 10_twitter_thread_example/$(SRC) $(DEPS) -o 10_twitter_thread_example/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 11_billion_lognormals_paralell/$(SRC) $(DEPS) -o 11_billion_lognormals_paralell/$(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) 12_time_to_botec_parallel/$(SRC) $(DEPS) -o 12_time_to_botec_parallel/$(OUTPUT) format-all: $(FORMATTER) 00_example_template/$(SRC) @@ -59,6 +61,8 @@ format-all: $(FORMATTER) 08_algebra_and_conversion/$(SRC) $(FORMATTER) 09_ergonomic_algebra/$(SRC) $(FORMATTER) 10_twitter_thread_example/$(SRC) + $(FORMATTER) 11_billion_lognormals_paralell/$(SRC) + $(FORMATTER) 12_time_to_botec_parallel/$(SRC) run-all: 00_example_template/$(OUTPUT) @@ -72,6 +76,8 @@ run-all: 08_algebra_and_conversion/$(OUTPUT) 09_ergonomic_algebra/$(OUTPUT) 10_twitter_thread_example/$(OUTPUT) + 11_billion_lognormals_paralell/$(OUTPUT) + 12_time_to_botec_parallel/$(OUTPUT) ## make one DIR=06_nuclear_recovery one: $(DIR)/$(SRC) @@ -89,7 +95,7 @@ run-one: $(DIR)/$(OUTPUT) 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 + @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 ## e.g., make profile-linux-one DIR=06_nuclear_recovery profile-linux-one: