commit 5cfc4ab468ba1db38024985a3005e19ae58ba26e
parent 7d1919dc3de31b0983e619f9d36442e0fab49c31
Author: NunoSempere <nuno.sempere@protonmail.com>
Date: Mon, 29 May 2023 17:47:52 -0400
tweak: link math library.
Diffstat:
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git 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
@@ -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
+}