diff --git a/C/makefile b/C/makefile index 5e5029b4..3fe983c0 100644 --- a/C/makefile +++ b/C/makefile @@ -47,6 +47,8 @@ multi: OMP_NUM_THREADS=8 ./$(OUTPUT) && echo OMP_NUM_THREADS=16 ./$(OUTPUT) && echo +## Timing + time-linux: @echo "Requires /bin/time, found on GNU/Linux systems" && echo @@ -77,6 +79,24 @@ time-linux-simple: OMP_NUM_THREADS=8 /bin/time -f "Time: %es" ./$(OUTPUT) && echo OMP_NUM_THREADS=16 /bin/time -f "Time: %es" ./$(OUTPUT) && echo +## Profiling + +profile-linux: + echo "Requires perf, which depends on the kernel, and might be in linux-tools package or similar" + $(CC) $(SRC) $(OPENMP) $(MATH) -o $(OUTPUT) + # ./$(OUTPUT) + # gprof: + # gprof $(OUTPUT) gmon.out > analysis.txt + # rm gmon.out + # vim analysis.txt + # rm analysis.txt + # perf: + perf record $(OUTPUT) + perf report + rm perf.data + + +## Install debian-install-dependencies: sudo apt-get install libomp-dev diff --git a/C/out/samples b/C/out/samples index c234d999..18ec0585 100755 Binary files a/C/out/samples and b/C/out/samples differ diff --git a/C/samples.c b/C/samples.c index 1a76c7c5..a38f3532 100644 --- a/C/samples.c +++ b/C/samples.c @@ -94,22 +94,22 @@ float ur_normal(unsigned int* seed) return z; } -inline float random_uniform(float from, float to, unsigned int* seed) +float random_uniform(float from, float to, unsigned int* seed) { return ((float)rand_r(seed) / (float)RAND_MAX) * (to - from) + from; } -inline float random_normal(float mean, float sigma, unsigned int* seed) +float random_normal(float mean, float sigma, unsigned int* seed) { return (mean + sigma * ur_normal(seed)); } -inline float random_lognormal(float logmean, float logsigma, unsigned int* seed) +float random_lognormal(float logmean, float logsigma, unsigned int* seed) { return expf(random_normal(logmean, logsigma, seed)); } -inline float random_to(float low, float high, unsigned int* seed) +float random_to(float low, float high, unsigned int* seed) { const float NORMAL95CONFIDENCE = 1.6448536269514722; float loglow = logf(low);