update flags again
This commit is contained in:
@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
|
|
||||||
// #define WEB // Disables multithreading
|
#define THREADPOOL // Enable physics threadpool
|
||||||
// #define TRACY // Enable tracy profiling support
|
#define TRACY // Enable tracy profiling support
|
||||||
|
#define BACKWARD // Enable pretty stack traces
|
||||||
|
|
||||||
// Window
|
// Window
|
||||||
constexpr int INITIAL_WIDTH = 800;
|
constexpr int INITIAL_WIDTH = 800;
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <iostream>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
@ -15,7 +16,7 @@
|
|||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef WEB
|
#ifdef THREADPOOL
|
||||||
#define BS_THREAD_POOL_NATIVE_EXTENSIONS
|
#define BS_THREAD_POOL_NATIVE_EXTENSIONS
|
||||||
#include <BS_thread_pool.hpp>
|
#include <BS_thread_pool.hpp>
|
||||||
#endif
|
#endif
|
||||||
@ -62,7 +63,7 @@ class MassSpringSystem {
|
|||||||
private:
|
private:
|
||||||
Octree octree;
|
Octree octree;
|
||||||
|
|
||||||
#ifndef WEB
|
#ifdef THREADPOOL
|
||||||
BS::thread_pool<BS::tp::none> threads;
|
BS::thread_pool<BS::tp::none> threads;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -73,11 +74,14 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MassSpringSystem()
|
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::cout << "Using Barnes-Hut + octree repulsion force calculation."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
#ifndef WEB
|
#ifdef THREADPOOL
|
||||||
std::cout << "Thread-Pool: " << threads.get_thread_count() << " threads."
|
std::cout << "Thread-Pool: " << threads.get_thread_count() << " threads."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -89,7 +93,9 @@ public:
|
|||||||
MassSpringSystem &operator=(MassSpringSystem &&move) = delete;
|
MassSpringSystem &operator=(MassSpringSystem &&move) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifdef THREADPOOL
|
||||||
static auto SetThreadName(std::size_t idx) -> void;
|
static auto SetThreadName(std::size_t idx) -> void;
|
||||||
|
#endif
|
||||||
|
|
||||||
auto BuildOctree() -> void;
|
auto BuildOctree() -> void;
|
||||||
|
|
||||||
|
|||||||
@ -204,14 +204,12 @@ inline auto state_new_century_wc(const State &state) -> bool {
|
|||||||
static std::vector<StateGenerator> generators{
|
static std::vector<StateGenerator> generators{
|
||||||
state_simple_1r, state_simple_2r, state_simple_3r, state_complex_1r,
|
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_2r, state_complex_3r, state_complex_4f, state_complex_5r,
|
||||||
state_complex_6r, state_klotski, state_century, state_super_century,
|
state_complex_6r, state_klotski, state_century, state_super_century};
|
||||||
state_new_century};
|
|
||||||
|
|
||||||
static std::vector<WinCondition> win_conditions{
|
static std::vector<WinCondition> win_conditions{
|
||||||
state_simple_1r_wc, state_simple_2r_wc, state_simple_3r_wc,
|
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_1r_wc, state_complex_2r_wc, state_complex_3r_wc,
|
||||||
state_complex_4f_wc, state_complex_5r_wc, state_complex_6r_wc,
|
state_complex_4f_wc, state_complex_5r_wc, state_complex_6r_wc,
|
||||||
state_klotski_wc, state_century_wc, state_super_century_wc,
|
state_klotski_wc, state_century_wc, state_super_century_wc};
|
||||||
state_new_century_wc};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -33,6 +33,10 @@
|
|||||||
// - g++/clang++ -lunwind
|
// - g++/clang++ -lunwind
|
||||||
// #define BACKWARD_HAS_LIBUNWIND 1
|
// #define BACKWARD_HAS_LIBUNWIND 1
|
||||||
|
|
||||||
|
#include "config.hpp"
|
||||||
|
|
||||||
|
#ifdef BACKWARD
|
||||||
|
|
||||||
#include "backward.hpp"
|
#include "backward.hpp"
|
||||||
|
|
||||||
namespace backward {
|
namespace backward {
|
||||||
@ -40,3 +44,5 @@ namespace backward {
|
|||||||
backward::SignalHandling sh;
|
backward::SignalHandling sh;
|
||||||
|
|
||||||
} // namespace backward
|
} // namespace backward
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
#include "physics.hpp"
|
#include "physics.hpp"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
|
||||||
#include <BS_thread_pool.hpp>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -11,6 +10,11 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef THREADPOOL
|
||||||
|
#define BS_THREAD_POOL_NATIVE_EXTENSIONS
|
||||||
|
#include <BS_thread_pool.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TRACY
|
#ifdef TRACY
|
||||||
#include "tracy.hpp"
|
#include "tracy.hpp"
|
||||||
#include <tracy/Tracy.hpp>
|
#include <tracy/Tracy.hpp>
|
||||||
@ -116,9 +120,11 @@ auto MassSpringSystem::CalculateSpringForces() -> void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef THREADPOOL
|
||||||
auto MassSpringSystem::SetThreadName(std::size_t idx) -> void {
|
auto MassSpringSystem::SetThreadName(std::size_t idx) -> void {
|
||||||
BS::this_thread::set_os_thread_name(std::format("bh-worker-{}", idx));
|
BS::this_thread::set_os_thread_name(std::format("bh-worker-{}", idx));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
auto MassSpringSystem::BuildOctree() -> void {
|
auto MassSpringSystem::BuildOctree() -> void {
|
||||||
#ifdef TRACY
|
#ifdef TRACY
|
||||||
@ -170,14 +176,14 @@ auto MassSpringSystem::CalculateRepulsionForces() -> void {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Calculate forces using Barnes-Hut
|
// Calculate forces using Barnes-Hut
|
||||||
#ifdef WEB
|
#ifdef THREADPOOL
|
||||||
for (int i = 0; i < mass_pointers.size(); ++i) {
|
|
||||||
solve_octree(i);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
BS::multi_future<void> loop_future =
|
BS::multi_future<void> loop_future =
|
||||||
threads.submit_loop(0, masses.size(), solve_octree, 256);
|
threads.submit_loop(0, masses.size(), solve_octree, 256);
|
||||||
loop_future.wait();
|
loop_future.wait();
|
||||||
|
#else
|
||||||
|
for (std::size_t i = 0; i < masses.size(); ++i) {
|
||||||
|
solve_octree(i);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +199,9 @@ auto MassSpringSystem::VerletUpdate(float delta_time) -> void {
|
|||||||
|
|
||||||
auto ThreadedPhysics::PhysicsThread(ThreadedPhysics::PhysicsState &state)
|
auto ThreadedPhysics::PhysicsThread(ThreadedPhysics::PhysicsState &state)
|
||||||
-> void {
|
-> void {
|
||||||
|
#ifdef THREADPOOL
|
||||||
BS::this_thread::set_os_thread_name("physics");
|
BS::this_thread::set_os_thread_name("physics");
|
||||||
|
#endif
|
||||||
|
|
||||||
MassSpringSystem mass_springs;
|
MassSpringSystem mass_springs;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user