From 5cfc4ab468ba1db38024985a3005e19ae58ba26e Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Mon, 29 May 2023 17:47:52 -0400 Subject: [PATCH] tweak: link math library. --- C-optimized/makefile | 8 +++++--- C-optimized/samples.c | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/C-optimized/makefile b/C-optimized/makefile index 9a3b62c7..ba66a0a3 100644 --- a/C-optimized/makefile +++ b/C-optimized/makefile @@ -21,14 +21,14 @@ STANDARD=-std=c99 WARNINGS=-Wall OPTIMIZED=-O3 #-O3 actually gives better performance than -Ofast, at least for this version OPENMP=-fopenmp - +MATH=-lm ## Formatter STYLE_BLUEPRINT=webkit FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) ## make build build: $(SRC) - $(CC) $(OPTIMIZED) $(DEBUG) $(OPENMP) $(SRC) -o $(OUTPUT) + $(CC) $(OPTIMIZED) $(DEBUG) $(OPENMP) $(SRC) $(MATH) -o $(OUTPUT) #fast: Has been removed, compilation of "build" is very fast and it outputs optimized code by default @@ -36,6 +36,7 @@ format: $(SRC) $(FORMATTER) $(SRC) run: $(SRC) $(OUTPUT) + ./$(OUTPUT) # echo "Increasing stack size limit, because we are dealing with 1M samples" # # ulimit: increase stack size limit # # -Ss: the soft limit. If you set the hard limit, you then can't raise it @@ -43,7 +44,8 @@ run: $(SRC) $(OUTPUT) # # Then run the program # ulimit -Ss 256000 && ./$(OUTPUT) - +linux: + sudo apt-get install libomp-dev # Old: # Link libraries, for good measure diff --git a/C-optimized/samples.c b/C-optimized/samples.c index 9b2be9c4..931c4320 100644 --- a/C-optimized/samples.c +++ b/C-optimized/samples.c @@ -258,11 +258,11 @@ int main() { float (*samplers[])(void) = {sample_0, sample_1, sample_few, sample_many}; mixture_f(samplers, weights, n_dists, dist_mixture, n_threads); - // printf("Sum(dist_mixture, N)/N = %f\n", split_array_sum(dist_mixture, N, n_threads) / N); + printf("Sum(dist_mixture, N)/N = %f\n", split_array_sum(dist_mixture, N, n_threads) / N); end = clock(); split_array_free(dist_mixture, n_threads); printf("Total time (ms): %f\n", ((double) (end-start)) / CLOCKS_PER_SEC * 1000); return 0; -} \ No newline at end of file +}