tweak: don't use inline functions, add profiling

This commit is contained in:
NunoSempere 2023-06-03 01:29:16 -06:00
parent 396170d0a9
commit a13a042492
3 changed files with 24 additions and 4 deletions

View File

@ -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

Binary file not shown.

View File

@ -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);