tweak: link math library.

This commit is contained in:
NunoSempere 2023-05-29 17:47:52 -04:00
parent 7d1919dc3d
commit 5cfc4ab468
2 changed files with 7 additions and 5 deletions

View File

@ -21,14 +21,14 @@ STANDARD=-std=c99
WARNINGS=-Wall WARNINGS=-Wall
OPTIMIZED=-O3 #-O3 actually gives better performance than -Ofast, at least for this version OPTIMIZED=-O3 #-O3 actually gives better performance than -Ofast, at least for this version
OPENMP=-fopenmp OPENMP=-fopenmp
MATH=-lm
## Formatter ## Formatter
STYLE_BLUEPRINT=webkit STYLE_BLUEPRINT=webkit
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
## make build ## make build
build: $(SRC) 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 #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) $(FORMATTER) $(SRC)
run: $(SRC) $(OUTPUT) run: $(SRC) $(OUTPUT)
./$(OUTPUT)
# echo "Increasing stack size limit, because we are dealing with 1M samples" # echo "Increasing stack size limit, because we are dealing with 1M samples"
# # ulimit: increase stack size limit # # ulimit: increase stack size limit
# # -Ss: the soft limit. If you set the hard limit, you then can't raise it # # -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 # # Then run the program
# ulimit -Ss 256000 && ./$(OUTPUT) # ulimit -Ss 256000 && ./$(OUTPUT)
linux:
sudo apt-get install libomp-dev
# Old: # Old:
# Link libraries, for good measure # Link libraries, for good measure

View File

@ -258,11 +258,11 @@ int main() {
float (*samplers[])(void) = {sample_0, sample_1, sample_few, sample_many}; float (*samplers[])(void) = {sample_0, sample_1, sample_few, sample_many};
mixture_f(samplers, weights, n_dists, dist_mixture, n_threads); 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(); end = clock();
split_array_free(dist_mixture, n_threads); split_array_free(dist_mixture, n_threads);
printf("Total time (ms): %f\n", ((double) (end-start)) / CLOCKS_PER_SEC * 1000); printf("Total time (ms): %f\n", ((double) (end-start)) / CLOCKS_PER_SEC * 1000);
return 0; return 0;
} }