Linus/one baseline file

This commit is contained in:
Linus Baumberger
2026-05-17 16:17:00 +02:00
committed by salijagic
parent f294167b08
commit 1c5839e1d6
9 changed files with 240320 additions and 160 deletions
+26 -6
View File
@@ -45,16 +45,21 @@ endif
# cross-file optimizations such as function inlining
CXXFLAGS := -O3 -march=native -std=c++23 -Wall -Wextra -flto
SRC := main.cpp forces.cpp social_force_baseline.cpp
VARIANT ?= baseline
VARIANT_SRC := variant_$(VARIANT).cpp
SRC := main.cpp $(VARIANT_SRC)
HEADERS := board.hpp forces.hpp pedestrian.hpp vector2d.hpp constants.hpp social_force.hpp
TEST_SRC := test_vector2d.cpp test_board.cpp test_forces.cpp forces.cpp
TEST_SRC := test_vector2d.cpp test_board.cpp test_forces.cpp $(VARIANT_SRC)
TEST_TARGET := run_tests
TEST_LIBS := -lgtest -lgtest_main -pthread
TARGET := main
TARGET := main_$(VARIANT)
SIZES_TARGET := sizes
# Default simulation parameters and output files.
# These can be overridden from the make command line; see examples above.
N_P ?= 60 # Default number of pedestrians.
@@ -70,7 +75,11 @@ RANDOM_SEED ?= 0
# Pass random-seeding mode to the C++ code.
CXXFLAGS += -DRANDOM_SEED=$(RANDOM_SEED)
.PHONY: all main run bench run-bench video sizes asm test clean clean-all
# Benchmark suite parameters.
BENCH_SIZES ?= 50 100 200 500 1000 2000 5000 10000
BENCH_ITER ?= 1000
.PHONY: all main run bench run-bench bench-suite video sizes asm test clean clean-all
all: main
@@ -91,6 +100,17 @@ bench: clean
run-bench: bench
$(SUDO_BENCH) ./$(TARGET) $(N_P) $(N_ITER)
# make bench-suite : compile once and run benchmarks across multiple pedestrian counts.
# Results are printed to stdout; redirect to a file to save them.
# make bench-suite > benchmarks/baseline.txt
# make bench-suite VARIANT=v1_cutoff BENCH_SIZES="100 500 1000" > benchmarks/v1_cutoff.txt
bench-suite: bench
@for n in $(BENCH_SIZES); do \
echo "=== N_P=$$n N_ITER=$(BENCH_ITER) ==="; \
$(SUDO_BENCH) ./$(TARGET) $$n $(BENCH_ITER); \
echo ""; \
done
# make video : compile the code, run the simulation, and generate the video.
video: run
python visualization.py $(CSV) $(MP4)
@@ -105,14 +125,14 @@ test: clean
./$(TEST_TARGET)
# make asm : compile and generate assembly files.
asm: clean main.s forces.s social_force_baseline.s
asm: clean main.s variant_$(VARIANT).s
%.s: %.cpp $(HEADERS)
$(CXX) -O3 -march=native -std=c++23 -Wall -Wextra -DRANDOM_SEED=$(RANDOM_SEED) -S $< -o $@
# make clean : delete generated files from previous builds.
clean:
rm -f $(TARGET) $(SIZES_TARGET) $(TEST_TARGET) *.o *.s
rm -f main_* $(SIZES_TARGET) $(TEST_TARGET) *.o *.s
# make clean-all : delete all generated files from previous builds and runs.
# WARNING: this deletes all *.csv and *.mp4 files in this directory.