squiggle.c

Self-contained Monte Carlo estimation in C99
Log | Files | Refs | README

commit 5d76f089bd945b34c623ffbf339528005dddfc12
parent 930a431012bcf651956176745d23e9da116ae092
Author: NunoSempere <nuno.sempere@protonmail.com>
Date:   Sun, 23 Jul 2023 11:27:34 +0200

remove scratchpad

Diffstat:
Dscratchpad/correlated/correlated | 0
Dscratchpad/correlated/correlated.c | 21---------------------
Dscratchpad/correlated/makefile | 53-----------------------------------------------------
Dscratchpad/uncorrelated/makefile | 53-----------------------------------------------------
Dscratchpad/uncorrelated/uncorrelated | 0
Dscratchpad/uncorrelated/uncorrelated.c | 24------------------------
6 files changed, 0 insertions(+), 151 deletions(-)

diff --git a/scratchpad/correlated/correlated b/scratchpad/correlated/correlated Binary files differ. diff --git a/scratchpad/correlated/correlated.c b/scratchpad/correlated/correlated.c @@ -1,21 +0,0 @@ -// correlated samples - -#include "../../squiggle.h" -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> - -int main() -{ - // set randomness seed - uint32_t* seed = malloc(sizeof(uint32_t)); - *seed = 1000; // xorshift can't start with 0 - - float a = sample_to(1, 10, seed); - float b = 2 * a; - float c = a / b; - - printf("a: %f, b: %f, c: %f\n", a, b, c); - - free(seed); -} diff --git a/scratchpad/correlated/makefile b/scratchpad/correlated/makefile @@ -1,53 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc -# CC=tcc # <= faster compilation - -# Main file -SRC=correlated.c ../../squiggle.c -OUTPUT=correlated - -## 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/scratchpad/uncorrelated/makefile b/scratchpad/uncorrelated/makefile @@ -1,53 +0,0 @@ -# Interface: -# make -# make build -# make format -# make run - -# Compiler -CC=gcc -# CC=tcc # <= faster compilation - -# Main file -SRC=uncorrelated.c ../../squiggle.c -OUTPUT=uncorrelated - -## 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/scratchpad/uncorrelated/uncorrelated b/scratchpad/uncorrelated/uncorrelated Binary files differ. diff --git a/scratchpad/uncorrelated/uncorrelated.c b/scratchpad/uncorrelated/uncorrelated.c @@ -1,24 +0,0 @@ -// uncorrelated samples - -#include "../../squiggle.h" -#include <stdint.h> -#include <stdlib.h> -#include <stdio.h> - -float draw_xyz(uint32_t* seed){ - // function could also be placed inside main with gcc nested functions extension. - return sample_to(1, 20, seed); -} - -int main(){ - // set randomness seed - uint32_t* seed = malloc(sizeof(uint32_t)); - *seed = 1000; // xorshift can't start with 0 - - float a = draw_xyz(seed); - float b = 2 * draw_xyz(seed); - float c = b / a; - - printf("a: %f, b: %f, c: %f\n", a, b, c); - -}