diff --git a/examples/more/00_example_template/example b/examples/more/00_example_template/example index ab405cb..ccbfe41 100755 Binary files a/examples/more/00_example_template/example and b/examples/more/00_example_template/example differ diff --git a/examples/more/01_sample_from_cdf/example b/examples/more/01_sample_from_cdf/example index 52f8eb4..3b21bf4 100755 Binary files a/examples/more/01_sample_from_cdf/example and b/examples/more/01_sample_from_cdf/example differ diff --git a/examples/more/02_sample_from_cdf_beta/example b/examples/more/02_sample_from_cdf_beta/example index e79ab13..37932a2 100755 Binary files a/examples/more/02_sample_from_cdf_beta/example and b/examples/more/02_sample_from_cdf_beta/example differ diff --git a/examples/more/03_ci_beta/example b/examples/more/03_ci_beta/example index 7410d7b..ffefed0 100755 Binary files a/examples/more/03_ci_beta/example and b/examples/more/03_ci_beta/example differ diff --git a/examples/more/04_nuclear_war/example b/examples/more/04_nuclear_war/example index 92db813..46690da 100755 Binary files a/examples/more/04_nuclear_war/example and b/examples/more/04_nuclear_war/example differ diff --git a/examples/more/05_burn_10kg_fat/example b/examples/more/05_burn_10kg_fat/example index 220f4a7..58c1406 100755 Binary files a/examples/more/05_burn_10kg_fat/example and b/examples/more/05_burn_10kg_fat/example differ diff --git a/examples/more/06_nuclear_recovery/example b/examples/more/06_nuclear_recovery/example index 538cebd..c8d31d5 100755 Binary files a/examples/more/06_nuclear_recovery/example and b/examples/more/06_nuclear_recovery/example differ diff --git a/examples/more/07_algebra/example b/examples/more/07_algebra/example index 301d72d..653b76a 100755 Binary files a/examples/more/07_algebra/example and b/examples/more/07_algebra/example differ diff --git a/examples/more/08_algebra_and_conversion/example b/examples/more/08_algebra_and_conversion/example index 4f5f399..ee4b5fe 100755 Binary files a/examples/more/08_algebra_and_conversion/example and b/examples/more/08_algebra_and_conversion/example differ diff --git a/examples/more/09_ergonomic_algebra/example b/examples/more/09_ergonomic_algebra/example index c68453f..a508872 100755 Binary files a/examples/more/09_ergonomic_algebra/example and b/examples/more/09_ergonomic_algebra/example differ diff --git a/examples/more/10_twitter_thread_example/example b/examples/more/10_twitter_thread_example/example index 376681b..3465550 100755 Binary files a/examples/more/10_twitter_thread_example/example and b/examples/more/10_twitter_thread_example/example differ diff --git a/examples/more/11_billion_lognormals_paralell/example b/examples/more/11_billion_lognormals_paralell/example index 38dbe70..6d40a9f 100755 Binary files a/examples/more/11_billion_lognormals_paralell/example and b/examples/more/11_billion_lognormals_paralell/example differ diff --git a/examples/more/12_time_to_botec_parallel/example b/examples/more/12_time_to_botec_parallel/example index 5633d7c..71e3c17 100755 Binary files a/examples/more/12_time_to_botec_parallel/example and b/examples/more/12_time_to_botec_parallel/example differ diff --git a/examples/more/13_parallelize_min/example b/examples/more/13_parallelize_min/example index 14fbc48..4cce4a3 100755 Binary files a/examples/more/13_parallelize_min/example and b/examples/more/13_parallelize_min/example differ diff --git a/examples/more/14_check_confidence_interval/example b/examples/more/14_check_confidence_interval/example index a4d9d30..c344ca1 100755 Binary files a/examples/more/14_check_confidence_interval/example and b/examples/more/14_check_confidence_interval/example differ diff --git a/makefile b/makefile index e1bc95f..eddd664 100644 --- a/makefile +++ b/makefile @@ -4,6 +4,9 @@ MAKEFLAGS += --no-print-directory STYLE_BLUEPRINT=webkit FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) +## Time to botec +TTB=./examples/more/12_time_to_botec_parallel/example + build-examples: cd examples/core && make all cd examples/more && make all @@ -25,3 +28,6 @@ profile: sudo perf report rm perf.data +time-linux: + @echo "Running 100x and taking avg time: $(TTB)" + @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(TTB); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 16 threads: |" | sed 's|$$|ms|' && echo diff --git a/squiggle_more.c b/squiggle_more.c index 0b87b7e..3c29f18 100644 --- a/squiggle_more.c +++ b/squiggle_more.c @@ -64,6 +64,8 @@ void sampler_parallel(double (*sampler)(uint64_t* seed), double* results, int n_ { #pragma omp for for (i = 0; i < n_threads; i++) { + // Simple version + /* int quotient = n_samples / n_threads; int lower_bound_inclusive = i * quotient; int upper_bound_not_inclusive = ((i + 1) * quotient); // note the < in the for loop below, @@ -71,6 +73,34 @@ void sampler_parallel(double (*sampler)(uint64_t* seed), double* results, int n_ results[j] = sampler(&(cache_box[i].seed)); // Could also result in inefficient cache stuff, but hopefully not too often } + */ + + // Version with loop unrolling + int quotient = n_samples / n_threads; + int lower_bound_inclusive = i * quotient; + int upper_bound_not_inclusive = ((i + 1) * quotient); // note the < in the for loop below, + int delta = quotient; + int eighth_of_deltas = delta/8; // why 8? a double in 8 bytes, 8 doubles is the size of a cache line + int k; + // to do: simplify these variables. Maybe divide by n_threads * 8 directly + for(int j=0; j