From 00c7f8cdf97fa886669c4a8b7be3236dc340ed36 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sat, 15 Jul 2023 23:26:48 +0200 Subject: [PATCH] add scratchpad --- scratchpad/makefile | 57 ++++++++++++++++++++++++++++++++++++++++ scratchpad/scratchpad | Bin 0 -> 16704 bytes scratchpad/scratchpad.c | 7 +++++ 3 files changed, 64 insertions(+) create mode 100644 scratchpad/makefile create mode 100755 scratchpad/scratchpad create mode 100644 scratchpad/scratchpad.c diff --git a/scratchpad/makefile b/scratchpad/makefile new file mode 100644 index 0000000..cc2fe53 --- /dev/null +++ b/scratchpad/makefile @@ -0,0 +1,57 @@ +# Interface: +# make +# make build +# make format +# make run + +# Compiler +CC=gcc # required for nested functions +# CC=tcc # <= faster compilation + +# Main file +SRC=scratchpad.c +OUTPUT=scratchpad + +## 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 scratchpad.c -lm -o scratchpad + $(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/scratchpad/scratchpad b/scratchpad/scratchpad new file mode 100755 index 0000000000000000000000000000000000000000..37e8b9d8f84a1eee7909f988e0420dbe02dafae7 GIT binary patch literal 16704 zcmeHOeQX>@6`%9P$>r;O`Jzq&@wNoXq4ma26U%8ax${@n=<-40P*-ibUf-?lL-*CY zJz_^yF>+efN=@?*qN4qyNT7l$L=hm&9|(uEQTPLzNC*`wM5u^xQ3+1kpcF`s_h#R- zch~D6RsF9!*4=O3Z{B+|`(}1;#yj)X?qp9*C?q(A#peY|<1w3wQ^ELN$^gVgn^+6q z4Pu*E4)QX|+2wH?pwv!p*0?c3d>9bz>M`SkpR{Sg$Sp)fyCoAg2oob+2inylPqG(p zPz8)!K3|`L#*h^GJ&*ll$LO@fCQLWk`qS-h?5DU45V9SLXm^3^E|4AL9M#9j@x++m zr;Xz2MFq+*De_wguU$Xcd9jQ18L%cL!|KKqJ zZf209Fv`BzNHUhc@l5A)$=4ezKl$}5-~Z_k(;HG(i*K_JtP^!Gp*;@?lzBX$j(z=K zLwbIAUowB2lf)8V`+!$`%2orn-iNO0Vx zE#%EUV=#-B!?{A9EOlGeR}q_4Ls8~fhXnpDJRT}rGAmK*e!2#}fBC){SZ5c^(EZ80 zLVP4{mov}uo7f?curIMbPL~}#k0C6Zb?|&IAV25e<#P>5NH-n4^M1KV{0h+FYnBGV zR}g_90zm|V2m}!bA`nC%h``4x0`Jvr`?ognZbUm>`-h!EXiv>pHPwsS#A}grG7i-} z-vau2^)oL3)HMjyAHkCA@BF1&t)4*{N`D|ryM!zUx#E_=A9!1{T)(&&pik`Zflcs+S#l7w6izETIjrX>9(~I99&Ut z2a)RKp}GdR4z|bZ8*j&AQMvb+Hqrho%xaTYtTo!{_VXajesH^5olQd%&)5C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