SDDPWorkPool class final
#include <gtopt/sddp_pool.hpp>
Work pool specialised for the SDDP solver with tuple priority key.
Uses SDDPTaskKey = std::tuple<IterationIndex, int, SDDPTaskKind> (iteration, is_backward, kind) as the secondary sort key with the default std::less<SDDPTaskKey> comparator (lexicographic). A concrete derived class so that class SDDPWorkPool; can be forward-declared in headers that only need the pointer type.
Base classes
-
template<typename Key = int64_t, typename KeyCompare = std::less<Key>>class BasicWorkPool<SDDPTaskKey>
- Adaptive thread pool with generic priority key.
Public types
- using key_compare = std::less<SDDPTaskKey>
- using key_type = SDDPTaskKey
- using Requirements = BasicTaskRequirements<SDDPTaskKey>
Public functions
- auto format_statistics() const -> std::string noexcept
- auto get_statistics() const -> Statistics noexcept
- void log_statistics() const
- auto max_memory_percent() const -> double noexcept
- auto max_process_rss_mb() const -> double noexcept
- auto max_threads() const -> int noexcept
- auto max_threads_ceiling() const -> int noexcept
- auto release_slot_while_blocking() -> SlotReleaseGuard noexcept
- void shutdown()
- void start()
- auto submit(Func&& func, const Requirements& req = Requirements(), Args && ... args) -> std::expected<std::future<std::invoke_result_t<Func, Args...>>, std::error_code>
- auto submit_batch(std::vector<std::pair<Func, Requirements>>& tasks) -> std::vector<std::expected<std::future<std::invoke_result_t<Func>>, std::error_code>>
- auto submit_lambda(Func&& func, Requirements req = {}) -> auto
Typedef documentation
using gtopt:: SDDPWorkPool:: key_compare = std::less<SDDPTaskKey>
#include <gtopt/work_pool.hpp>
using gtopt:: SDDPWorkPool:: key_type = SDDPTaskKey
#include <gtopt/work_pool.hpp>
using gtopt:: SDDPWorkPool:: Requirements = BasicTaskRequirements<SDDPTaskKey>
#include <gtopt/work_pool.hpp>
Function documentation
std::string gtopt:: SDDPWorkPool:: format_statistics() const noexcept
#include <gtopt/work_pool.hpp>
Statistics gtopt:: SDDPWorkPool:: get_statistics() const noexcept
#include <gtopt/work_pool.hpp>
void gtopt:: SDDPWorkPool:: log_statistics() const
#include <gtopt/work_pool.hpp>
double gtopt:: SDDPWorkPool:: max_memory_percent() const noexcept
#include <gtopt/work_pool.hpp>
System-wide memory-usage backstop threshold (percent). Routine throttling is the marginal-RSS gate; this fires only near OOM.
double gtopt:: SDDPWorkPool:: max_process_rss_mb() const noexcept
#include <gtopt/work_pool.hpp>
Process-RSS budget driving the marginal-RSS dispatch gate (0 = the gate + measured model are disabled). Exposed for tests / diagnostics.
int gtopt:: SDDPWorkPool:: max_threads() const noexcept
#include <gtopt/work_pool.hpp>
Thread cap configured for this pool. Needed by tests that verify make_solver_work_pool(cpu_factor) clamps its thread count correctly (e.g. tiny cpu_factor must floor to 1 thread to give a genuine serial baseline). Safe to call from any thread — max_threads_ may grow at runtime up to the ceiling.
int gtopt:: SDDPWorkPool:: max_threads_ceiling() const noexcept
#include <gtopt/work_pool.hpp>
Absolute growth ceiling for max_threads() (the un-clamped CPU budget). Equals max_threads() initially when growth is disabled.
SlotReleaseGuard gtopt:: SDDPWorkPool:: release_slot_while_blocking() noexcept
#include <gtopt/work_pool.hpp>
Acquire a guard that releases this task's worker slot for the duration of an external blocking wait. See SlotReleaseGuard for rationale and usage.
void gtopt:: SDDPWorkPool:: shutdown()
#include <gtopt/work_pool.hpp>
void gtopt:: SDDPWorkPool:: start()
#include <gtopt/work_pool.hpp>
std::expected<std::future<std::invoke_result_t<Func, Args...>>, std::error_code> gtopt:: SDDPWorkPool:: submit(Func&& func,
const Requirements& req = Requirements(),
Args && ... args)
#include <gtopt/work_pool.hpp>
std::vector<std::expected<std::future<std::invoke_result_t<Func>>, std::error_code>> gtopt:: SDDPWorkPool:: submit_batch(std::vector<std::pair<Func, Requirements>>& tasks)
#include <gtopt/work_pool.hpp>
Submit multiple callables under a single lock acquisition. Returns a vector of futures, one per callable.
auto gtopt:: SDDPWorkPool:: submit_lambda(Func&& func,
Requirements req = {})
#include <gtopt/work_pool.hpp>