From d744bcd354811876058f9a3b69fedbb3ba54df10 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sat, 15 Jul 2023 23:22:44 +0200 Subject: [PATCH] savepoint --- examples/01_one_sample/example | Bin 17696 -> 17608 bytes examples/02_many_samples/example | Bin 17696 -> 17648 bytes examples/03_gcc_nested_function/example | Bin 0 -> 17672 bytes examples/03_gcc_nested_function/example.c | 37 ++++++++++++++ examples/03_gcc_nested_function/makefile | 57 ++++++++++++++++++++++ squiggle.h | 5 +- to-do.md | 5 +- 7 files changed, 101 insertions(+), 3 deletions(-) create mode 100755 examples/03_gcc_nested_function/example create mode 100644 examples/03_gcc_nested_function/example.c create mode 100644 examples/03_gcc_nested_function/makefile diff --git a/examples/01_one_sample/example b/examples/01_one_sample/example index b3db352fd1b79c50dd3ef781efa445004e27efc9..0be17e76fca55db27a76312134d65b3cae0dc51d 100755 GIT binary patch delta 3991 zcmZ`+eNa@_6~FK8F8cwvyTGyw^0CN2eq%&!CI%ZHzM;%%h>{ObuQ<~{GIDQm!b!+ha8qvU9hB5niPzj zGwGs%%%#f`APIGIsV;A>{W6}Ab-9c7NM3iVuxb@nt#nfQOF`7H+swuuon}4sro5uy z|BY}|jBu3frVSapT8=EKeeFT%@HcO-db;=i$b0|%*~j#Xsn|0I&Wy=2wnuY4ht8WG zmCn&kQ;3SqK60Tpo6DqMf$>r&S{?LP^9Jb%m0J$e6-%p`VK8b;%3Ulmlje@6A&j~+ zdyAcC;&*6sE_U!R(qdtM67p-BY+`?-x0CX}^|4?xwroL~&Fq$tbuY5!1r#%~DHevY zbj~u?BJyYO@ia=a)@NCDt@fL!(*?dbHhSLbEf))_(PJ~TJTpe=5IpxJ(Vwkex?)X9 z?VQ1yX$tHl*sd9D5|!G#S;)Y2iOOMWLv*IhqoQ}zuh7tNT#M&*F{kzzEISVN$u zJf3)0RaIxP%(@gi2_BHw1`_>a=Q$c`aLoa^F=rI> z$^pv@y#15-4!b(&%-@Xx*(HInk7@Rc_LkDt^ttk~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ewzj|;bA}CLMj9HNM^(X&HW)M1F?hm@)u012 zJliVuf5vDT#UmDb79;Vwi7B7sRk4)iJkh_xhtAHd&*v+q9+a7rJRF+<+FzLUo3Q>; zVrt#)@pHqF!XM5eW7g;M8dDDoDr(ig9XNi*qsO;Q{CGv5*Tm+FZ_VfnA z=Rc-BOT#P ze8Tpzl`xW`YMY=yqpmcA%#ZLf>wAf8ik%$s@l-mqF6s+-?S5 zMTY#(`nm4qv%Gcw9j^C;ijx5_im^b_c4CVhVY z&^nK-O~k9gP4KM$B?>5Z)v}j +#include +#include +#include "../../squiggle.h" + +int main(){ + // set randomness seed + uint32_t* seed = malloc(sizeof(uint32_t)); + *seed = 1000; // xorshift can't start with 0 + + float p_a = 0.8; + float p_b = 0.5; + float p_c = p_a * p_b; + + int n_dists = 4; + + float sample_0(uint32_t* seed){ return 0; } + float sample_1(uint32_t* seed) { return 1; } + float sample_few(uint32_t* seed){ return random_to(1, 3, seed); } + float sample_many(uint32_t* seed){ return random_to(2, 10, seed); } + + float (*samplers[])(uint32_t*) = { sample_0, sample_1, sample_few, sample_many }; + float weights[] = { 1 - p_c, p_c / 2, p_c / 4, p_c / 4 }; + + int n_samples = 1000000; + float* result_many = (float *) malloc(n_samples * sizeof(float)); + for(int i=0; i&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/squiggle.h b/squiggle.h index 5409e01..d887b21 100644 --- a/squiggle.h +++ b/squiggle.h @@ -95,14 +95,17 @@ float mixture(float (*samplers[])(uint32_t*), float* weights, int n_dists, uint3 cumsummed_normalized_weights[i] = cumsummed_normalized_weights[i - 1] + weights[i]/sum_weights; } - float p = random_uniform(0, 1, seed); float result; + int result_set_flag = 0; + float p = random_uniform(0, 1, seed); for (int k = 0; k < n_dists; k++) { if (p < cumsummed_normalized_weights[k]) { result = samplers[k](seed); + result_set_flag = 1; break; } } + if(result_set_flag == 0) result = samplers[n_dists-1](seed); free(cumsummed_normalized_weights); return result; diff --git a/to-do.md b/to-do.md index 3be7ffb..1f32078 100644 --- a/to-do.md +++ b/to-do.md @@ -1,9 +1,10 @@ -- [ ] Add example for only one sample -- [ ] Add example for many samples +- [x] Add example for only one sample +- [x] Add example for many samples - [ ] Use gcc extension to define functions nested inside main. - [ ] Use OpenMP for acceleration - [ ] Chain various mixture functions - [ ] Have some more complicated & realistic example - [ ] Add summarization functions, like mean, std, 90% ci (or all c.i.?) - [ ] Add beta distribution +- [ ] Add a custom preprocessor to allow simple nested functions that don't rely on local scope?