Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
|
#include <ThreadPool.hh>
Classes | |
struct | Config |
Public Types | |
template<typename KeyT , typename MappedT , typename HashT = KeyT> | |
using | uomap = std::unordered_map< KeyT, MappedT, std::hash< HashT > > |
using | size_type = size_t |
using | task_count_type = std::shared_ptr< std::atomic_uintmax_t > |
using | atomic_int_type = std::shared_ptr< std::atomic_uintmax_t > |
using | pool_state_type = std::shared_ptr< std::atomic_short > |
using | atomic_bool_type = std::shared_ptr< std::atomic_bool > |
using | task_type = VTask |
using | lock_t = std::shared_ptr< Mutex > |
using | condition_t = std::shared_ptr< Condition > |
using | task_pointer = std::shared_ptr< task_type > |
using | task_queue_t = VUserTaskQueue |
using | thread_list_t = std::deque< ThreadId > |
using | bool_list_t = std::vector< bool > |
using | thread_id_map_t = std::map< ThreadId, uintmax_t > |
using | thread_index_map_t = std::map< uintmax_t, ThreadId > |
using | thread_vec_t = std::vector< Thread > |
using | thread_data_t = std::vector< std::shared_ptr< ThreadData > > |
using | initialize_func_t = std::function< void()> |
using | finalize_func_t = std::function< void()> |
using | affinity_func_t = std::function< intmax_t(intmax_t)> |
Static Public Member Functions | |
static affinity_func_t & | affinity_functor () |
static initialize_func_t & | initialization_functor () |
static finalize_func_t & | finalization_functor () |
static bool | using_tbb () |
static void | set_use_tbb (bool _v) |
static void | set_default_use_tbb (bool _v) |
set the default use of tbb | |
static void | set_default_use_cpu_affinity (bool _v) |
set the default use of cpu affinity | |
static void | set_default_scheduling_priority (int _v) |
set the default scheduling priority of threads in thread-pool | |
static void | set_default_verbose (int _v) |
set the default verbosity | |
static void | set_default_size (size_type _v) |
set the default pool size | |
static bool | get_default_use_tbb () |
get the default use of tbb | |
static bool | get_default_use_cpu_affinity () |
get the default use of cpu affinity | |
static int | get_default_scheduling_priority () |
get the default scheduling priority of threads in thread-pool | |
static int | get_default_verbose () |
get the default verbosity | |
static size_type | get_default_size () |
get the default pool size | |
static tbb_global_control_t *& | tbb_global_control () |
static const thread_id_map_t & | get_thread_ids () |
static uintmax_t | get_thread_id (ThreadId) |
static uintmax_t | get_this_thread_id () |
static uintmax_t | add_thread_id (ThreadId=ThisThread::get_id()) |
Protected Member Functions | |
void | execute_thread (VUserTaskQueue *) |
int | insert (task_pointer &&, int=-1) |
int | run_on_this (task_pointer &&) |
void | record_entry () |
void | record_exit () |
Static Protected Member Functions | |
static void | start_thread (ThreadPool *, thread_data_t *, intmax_t=-1) |
Definition at line 87 of file ThreadPool.hh.
using PTL::ThreadPool::affinity_func_t = std::function<intmax_t(intmax_t)> |
Definition at line 115 of file ThreadPool.hh.
using PTL::ThreadPool::atomic_bool_type = std::shared_ptr<std::atomic_bool> |
Definition at line 98 of file ThreadPool.hh.
using PTL::ThreadPool::atomic_int_type = std::shared_ptr<std::atomic_uintmax_t> |
Definition at line 96 of file ThreadPool.hh.
using PTL::ThreadPool::bool_list_t = std::vector<bool> |
Definition at line 107 of file ThreadPool.hh.
using PTL::ThreadPool::condition_t = std::shared_ptr<Condition> |
Definition at line 102 of file ThreadPool.hh.
using PTL::ThreadPool::finalize_func_t = std::function<void()> |
Definition at line 114 of file ThreadPool.hh.
using PTL::ThreadPool::initialize_func_t = std::function<void()> |
Definition at line 113 of file ThreadPool.hh.
using PTL::ThreadPool::lock_t = std::shared_ptr<Mutex> |
Definition at line 101 of file ThreadPool.hh.
using PTL::ThreadPool::pool_state_type = std::shared_ptr<std::atomic_short> |
Definition at line 97 of file ThreadPool.hh.
using PTL::ThreadPool::size_type = size_t |
Definition at line 94 of file ThreadPool.hh.
using PTL::ThreadPool::task_count_type = std::shared_ptr<std::atomic_uintmax_t> |
Definition at line 95 of file ThreadPool.hh.
using PTL::ThreadPool::task_pointer = std::shared_ptr<task_type> |
Definition at line 103 of file ThreadPool.hh.
Definition at line 104 of file ThreadPool.hh.
using PTL::ThreadPool::task_type = VTask |
Definition at line 100 of file ThreadPool.hh.
using PTL::ThreadPool::thread_data_t = std::vector<std::shared_ptr<ThreadData> > |
Definition at line 111 of file ThreadPool.hh.
using PTL::ThreadPool::thread_id_map_t = std::map<ThreadId, uintmax_t> |
Definition at line 108 of file ThreadPool.hh.
using PTL::ThreadPool::thread_index_map_t = std::map<uintmax_t, ThreadId> |
Definition at line 109 of file ThreadPool.hh.
using PTL::ThreadPool::thread_list_t = std::deque<ThreadId> |
Definition at line 106 of file ThreadPool.hh.
using PTL::ThreadPool::thread_vec_t = std::vector<Thread> |
Definition at line 110 of file ThreadPool.hh.
using PTL::ThreadPool::uomap = std::unordered_map<KeyT, MappedT, std::hash<HashT> > |
Definition at line 91 of file ThreadPool.hh.
|
explicit |
Definition at line 257 of file ThreadPool.cc.
ThreadPool::ThreadPool | ( | const size_type & | pool_size, |
VUserTaskQueue * | task_queue = nullptr , |
||
bool | _use_affinity = f_use_cpu_affinity() , |
||
affinity_func_t | _affinity_func = affinity_functor() , |
||
initialize_func_t | _init_func = initialization_functor() , |
||
finalize_func_t | _fini_func = finalization_functor() |
||
) |
Definition at line 282 of file ThreadPool.cc.
ThreadPool::ThreadPool | ( | const size_type & | pool_size, |
initialize_func_t | _init_func, | ||
finalize_func_t | _fini_func, | ||
bool | _use_affinity = f_use_cpu_affinity() , |
||
affinity_func_t | _affinity_func = affinity_functor() , |
||
VUserTaskQueue * | task_queue = nullptr |
||
) |
Definition at line 290 of file ThreadPool.cc.
|
virtual |
Definition at line 303 of file ThreadPool.cc.
|
delete |
|
default |
|
inline |
Definition at line 450 of file ThreadPool.hh.
Referenced by PTL::TaskManager::async(), and PTL::TaskManager::exec().
|
inline |
Definition at line 461 of file ThreadPool.hh.
|
static |
Definition at line 223 of file ThreadPool.cc.
Referenced by execute_on_all_threads(), and execute_on_specific_threads().
|
inlinestatic |
Definition at line 117 of file ThreadPool.hh.
ThreadPool::size_type ThreadPool::destroy_threadpool | ( | ) |
Definition at line 572 of file ThreadPool.cc.
Referenced by PTL::TaskManager::finalize(), PTL::TaskRunManager::Terminate(), and G4TaskRunManager::~G4TaskRunManager().
|
inline |
Definition at line 493 of file ThreadPool.hh.
Referenced by G4TaskRunManager::CreateAndStartWorkers(), destroy_threadpool(), initialize_threadpool(), G4TaskRunManager::RequestWorkersProcessCommandsStack(), G4TaskRunManager::TerminateWorkers(), and G4TaskRunManager::WaitForEndEventLoopWorkers().
|
inline |
Definition at line 611 of file ThreadPool.hh.
|
protected |
Definition at line 768 of file ThreadPool.cc.
|
inlinestatic |
Definition at line 133 of file ThreadPool.hh.
|
inline |
Definition at line 262 of file ThreadPool.hh.
|
inlinestatic |
get the default scheduling priority of threads in thread-pool
Definition at line 216 of file ThreadPool.hh.
|
inlinestatic |
get the default pool size
Definition at line 220 of file ThreadPool.hh.
|
inlinestatic |
get the default use of cpu affinity
Definition at line 214 of file ThreadPool.hh.
|
inlinestatic |
|
inlinestatic |
|
inline |
Definition at line 189 of file ThreadPool.hh.
Referenced by execute_on_all_threads(), execute_on_specific_threads(), PTL::ThreadData::update(), and PTL::TaskGroup< Tp, Arg, MaxDepth >::wait().
|
inline |
Definition at line 392 of file ThreadPool.hh.
Referenced by execute_on_all_threads(), execute_on_specific_threads(), and run_on_this().
|
static |
Definition at line 215 of file ThreadPool.cc.
Referenced by PTL::UserTaskQueue::GetThreadBin(), initialize_threadpool(), G4TaskRunManagerKernel::InitializeWorker(), ThreadPool(), and PTL::UserTaskQueue::UserTaskQueue().
Thread * PTL::ThreadPool::get_thread | ( | std::thread::id | id | ) | const |
|
static |
Definition at line 191 of file ThreadPool.cc.
Referenced by get_this_thread_id(), set_affinity(), and set_priority().
|
static |
Definition at line 183 of file ThreadPool.cc.
ThreadPool::task_queue_t *& ThreadPool::get_valid_queue | ( | task_queue_t *& | _queue | ) | const |
Definition at line 759 of file ThreadPool.cc.
Referenced by add_tasks(), and insert().
|
inline |
Definition at line 269 of file ThreadPool.hh.
Referenced by destroy_threadpool(), execute_on_all_threads(), and execute_on_specific_threads().
|
inlinestatic |
Definition at line 127 of file ThreadPool.hh.
ThreadPool::size_type ThreadPool::initialize_threadpool | ( | size_type | proposed_size | ) |
Definition at line 402 of file ThreadPool.cc.
Referenced by resize(), and ThreadPool().
|
inlineprotected |
Definition at line 439 of file ThreadPool.hh.
Referenced by add_task().
|
inline |
Definition at line 257 of file ThreadPool.hh.
Referenced by PTL::TaskGroup< Tp, Arg, MaxDepth >::wait().
bool ThreadPool::is_initialized | ( | ) | const |
Definition at line 331 of file ThreadPool.cc.
|
inline |
Definition at line 270 of file ThreadPool.hh.
Referenced by execute_on_all_threads().
|
inline |
Definition at line 192 of file ThreadPool.hh.
Referenced by G4TaskRunManager::InitializeThreadPool().
|
inline |
Definition at line 342 of file ThreadPool.hh.
Referenced by add_tasks(), and insert().
|
inline |
Definition at line 361 of file ThreadPool.hh.
|
inline |
Definition at line 353 of file ThreadPool.hh.
|
delete |
|
default |
|
protected |
Definition at line 339 of file ThreadPool.cc.
|
protected |
Definition at line 347 of file ThreadPool.cc.
|
inline |
Definition at line 243 of file ThreadPool.hh.
|
inline |
Definition at line 239 of file ThreadPool.hh.
|
inline |
Definition at line 413 of file ThreadPool.hh.
Referenced by PTL::TaskRunManager::Initialize(), and G4TaskRunManager::SetNumberOfThreads().
|
inlineprotected |
Definition at line 421 of file ThreadPool.hh.
Referenced by add_task().
|
inline |
Definition at line 264 of file ThreadPool.hh.
Referenced by initialize_threadpool().
void ThreadPool::set_affinity | ( | intmax_t | i, |
Thread & | _thread | ||
) | const |
Definition at line 355 of file ThreadPool.cc.
|
inlinestatic |
set the default scheduling priority of threads in thread-pool
Definition at line 205 of file ThreadPool.hh.
|
inlinestatic |
set the default pool size
Definition at line 209 of file ThreadPool.hh.
|
static |
set the default use of cpu affinity
Definition at line 171 of file ThreadPool.cc.
|
inlinestatic |
|
inlinestatic |
|
inline |
Definition at line 237 of file ThreadPool.hh.
|
inline |
Definition at line 236 of file ThreadPool.hh.
void ThreadPool::set_priority | ( | int | _prio, |
Thread & | _thread | ||
) | const |
Definition at line 378 of file ThreadPool.cc.
Referenced by initialize_threadpool().
|
static |
Definition at line 159 of file ThreadPool.cc.
Referenced by G4TaskRunManager::G4TaskRunManager(), set_default_use_tbb(), and PTL::TaskRunManager::TaskRunManager().
|
inline |
Definition at line 268 of file ThreadPool.hh.
|
inline |
Definition at line 252 of file ThreadPool.hh.
Referenced by G4TaskRunManager::ComputeNumberOfTasks(), execute_on_all_threads(), execute_on_specific_threads(), get_task_arena(), PTL::TaskRunManager::GetNumberActiveThreads(), PTL::TaskRunManager::GetNumberOfThreads(), PTL::TaskRunManager::Initialize(), G4TaskRunManagerKernel::InitializeWorker(), notify(), PTL::TaskManager::size(), and PTL::TaskGroup< Tp, Arg, MaxDepth >::wait().
|
staticprotected |
Definition at line 116 of file ThreadPool.cc.
Referenced by initialize_threadpool().
|
inline |
Definition at line 250 of file ThreadPool.hh.
Referenced by PTL::TaskGroup< Tp, Arg, MaxDepth >::wait().
ThreadPool::size_type ThreadPool::stop_thread | ( | ) |
Definition at line 711 of file ThreadPool.cc.
Referenced by initialize_threadpool().
|
inlinestatic |
Definition at line 384 of file ThreadPool.hh.
Referenced by destroy_threadpool(), execute_on_all_threads(), get_task_arena(), and initialize_threadpool().
|
inline |
Definition at line 256 of file ThreadPool.hh.
|
static |
Definition at line 151 of file ThreadPool.cc.
Referenced by PTL::TaskRunManager::Initialize().