update flags again
This commit is contained in:
@ -3,8 +3,9 @@
|
||||
|
||||
#include <raylib.h>
|
||||
|
||||
// #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;
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <raylib.h>
|
||||
@ -15,7 +16,7 @@
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#ifndef WEB
|
||||
#ifdef THREADPOOL
|
||||
#define BS_THREAD_POOL_NATIVE_EXTENSIONS
|
||||
#include <BS_thread_pool.hpp>
|
||||
#endif
|
||||
@ -62,7 +63,7 @@ class MassSpringSystem {
|
||||
private:
|
||||
Octree octree;
|
||||
|
||||
#ifndef WEB
|
||||
#ifdef THREADPOOL
|
||||
BS::thread_pool<BS::tp::none> 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;
|
||||
|
||||
|
||||
@ -204,14 +204,12 @@ inline auto state_new_century_wc(const State &state) -> bool {
|
||||
static std::vector<StateGenerator> 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<WinCondition> 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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#include "physics.hpp"
|
||||
#include "config.hpp"
|
||||
|
||||
#include <BS_thread_pool.hpp>
|
||||
#include <algorithm>
|
||||
#include <cfloat>
|
||||
#include <chrono>
|
||||
@ -11,6 +10,11 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#ifdef THREADPOOL
|
||||
#define BS_THREAD_POOL_NATIVE_EXTENSIONS
|
||||
#include <BS_thread_pool.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef TRACY
|
||||
#include "tracy.hpp"
|
||||
#include <tracy/Tracy.hpp>
|
||||
@ -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<void> 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user