From f31f9557b31910daddf43d0a52e0640bb93d37a9 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Tue, 24 Feb 2026 20:53:27 +0100 Subject: [PATCH] update flags again --- include/config.hpp | 5 +++-- include/physics.hpp | 14 ++++++++++---- include/presets.hpp | 6 ++---- src/backward.cpp | 6 ++++++ src/physics.cpp | 20 ++++++++++++++------ 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/include/config.hpp b/include/config.hpp index 9bcd1bc..dda39a1 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -3,8 +3,9 @@ #include -// #define WEB // Disables multithreading -// #define TRACY // Enable tracy profiling support +#define THREADPOOL // Enable physics threadpool +#define TRACY // Enable tracy profiling support +#define BACKWARD // Enable pretty stack traces // Window constexpr int INITIAL_WIDTH = 800; diff --git a/include/physics.hpp b/include/physics.hpp index 79e6ee9..7d9e1fc 100644 --- a/include/physics.hpp +++ b/include/physics.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -15,7 +16,7 @@ #include #include -#ifndef WEB +#ifdef THREADPOOL #define BS_THREAD_POOL_NATIVE_EXTENSIONS #include #endif @@ -62,7 +63,7 @@ class MassSpringSystem { private: Octree octree; -#ifndef WEB +#ifdef THREADPOOL BS::thread_pool threads; #endif @@ -73,11 +74,14 @@ public: public: MassSpringSystem() - : threads(std::thread::hardware_concurrency() - 1, SetThreadName) { +#ifdef THREADPOOL + : threads(std::thread::hardware_concurrency() - 1, SetThreadName) +#endif + { std::cout << "Using Barnes-Hut + octree repulsion force calculation." << std::endl; -#ifndef WEB +#ifdef THREADPOOL std::cout << "Thread-Pool: " << threads.get_thread_count() << " threads." << std::endl; #endif @@ -89,7 +93,9 @@ public: MassSpringSystem &operator=(MassSpringSystem &&move) = delete; private: +#ifdef THREADPOOL static auto SetThreadName(std::size_t idx) -> void; +#endif auto BuildOctree() -> void; diff --git a/include/presets.hpp b/include/presets.hpp index 8e4d224..c9881e3 100644 --- a/include/presets.hpp +++ b/include/presets.hpp @@ -204,14 +204,12 @@ inline auto state_new_century_wc(const State &state) -> bool { static std::vector generators{ state_simple_1r, state_simple_2r, state_simple_3r, state_complex_1r, state_complex_2r, state_complex_3r, state_complex_4f, state_complex_5r, - state_complex_6r, state_klotski, state_century, state_super_century, - state_new_century}; + state_complex_6r, state_klotski, state_century, state_super_century}; static std::vector win_conditions{ state_simple_1r_wc, state_simple_2r_wc, state_simple_3r_wc, state_complex_1r_wc, state_complex_2r_wc, state_complex_3r_wc, state_complex_4f_wc, state_complex_5r_wc, state_complex_6r_wc, - state_klotski_wc, state_century_wc, state_super_century_wc, - state_new_century_wc}; + state_klotski_wc, state_century_wc, state_super_century_wc}; #endif diff --git a/src/backward.cpp b/src/backward.cpp index 110441c..7eb1740 100644 --- a/src/backward.cpp +++ b/src/backward.cpp @@ -33,6 +33,10 @@ // - g++/clang++ -lunwind // #define BACKWARD_HAS_LIBUNWIND 1 +#include "config.hpp" + +#ifdef BACKWARD + #include "backward.hpp" namespace backward { @@ -40,3 +44,5 @@ namespace backward { backward::SignalHandling sh; } // namespace backward + +#endif diff --git a/src/physics.cpp b/src/physics.cpp index ed56592..199e6ab 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -1,7 +1,6 @@ #include "physics.hpp" #include "config.hpp" -#include #include #include #include @@ -11,6 +10,11 @@ #include #include +#ifdef THREADPOOL +#define BS_THREAD_POOL_NATIVE_EXTENSIONS +#include +#endif + #ifdef TRACY #include "tracy.hpp" #include @@ -116,9 +120,11 @@ auto MassSpringSystem::CalculateSpringForces() -> void { } } +#ifdef THREADPOOL auto MassSpringSystem::SetThreadName(std::size_t idx) -> void { BS::this_thread::set_os_thread_name(std::format("bh-worker-{}", idx)); } +#endif auto MassSpringSystem::BuildOctree() -> void { #ifdef TRACY @@ -170,14 +176,14 @@ auto MassSpringSystem::CalculateRepulsionForces() -> void { }; // Calculate forces using Barnes-Hut -#ifdef WEB - for (int i = 0; i < mass_pointers.size(); ++i) { - solve_octree(i); - } -#else +#ifdef THREADPOOL BS::multi_future loop_future = threads.submit_loop(0, masses.size(), solve_octree, 256); loop_future.wait(); +#else + for (std::size_t i = 0; i < masses.size(); ++i) { + solve_octree(i); + } #endif } @@ -193,7 +199,9 @@ auto MassSpringSystem::VerletUpdate(float delta_time) -> void { auto ThreadedPhysics::PhysicsThread(ThreadedPhysics::PhysicsState &state) -> void { +#ifdef THREADPOOL BS::this_thread::set_os_thread_name("physics"); +#endif MassSpringSystem mass_springs;