Main point of access for all MultiProcess infrastructure.
This class mainly serves as the access point to the multi-process infrastructure for 'Job's. It is meant to be used as a singleton that holds and connects the other infrastructural classes: the messenger, process manager, worker and queue loops.
It is important that the user of this class, particularly the one that calls 'instance()' first, calls 'activate()' soon after, because everything that is done in between 'instance()' and 'activate()' will be executed on all processes. This may be useful in some cases, but in general, one will probably want to always use the 'JobManager' in its full capacity, including the queue and worker loops. This is the way the Job class uses this class, see 'Job::get_manager()'.
The default number of processes is set using 'std::thread::hardware_concurrency()'. To change it, use 'Config::setDefaultNWorkers()' to set it to a different value before creation of a new JobManager instance.
Definition at line 30 of file JobManager.h.
Public Member Functions | |
~JobManager () | |
void | activate () |
Start queue and worker loops on child processes. | |
bool | is_activated () const |
Messenger & | messenger () const |
ProcessManager & | process_manager () const |
Queue * | queue () const |
void | retrieve (std::size_t requesting_job_id) |
Retrieve results for a Job. | |
Static Public Member Functions | |
static std::size_t | add_job_object (Job *job_object) |
static Job * | get_job_object (std::size_t job_object_id) |
static JobManager * | instance () |
static bool | is_instantiated () |
static bool | remove_job_object (std::size_t job_object_id) |
Private Member Functions | |
JobManager (std::size_t N_workers) | |
Don't construct JobManager objects manually, use the static instance if you need to run multiple jobs. | |
Private Attributes | |
bool | activated_ = false |
std::unique_ptr< Messenger > | messenger_ptr_ |
std::unique_ptr< ProcessManager > | process_manager_ptr_ |
std::unique_ptr< Queue > | queue_ptr_ |
Static Private Attributes | |
static std::unique_ptr< JobManager > | instance_ {nullptr} |
static std::size_t | job_counter_ = 0 |
static std::map< std::size_t, Job * > | job_objects_ |
RooFit::MultiProcess::JobManager::~JobManager | ( | ) |
Definition at line 85 of file JobManager.cxx.
|
explicitprivate |
Don't construct JobManager objects manually, use the static instance if you need to run multiple jobs.
Definition at line 69 of file JobManager.cxx.
void RooFit::MultiProcess::JobManager::activate | ( | ) |
Start queue and worker loops on child processes.
This function exists purely because activation from the constructor is impossible; the constructor must return a constructed instance, which it can't do if it's stuck in an infinite loop. This means the Job that first creates the JobManager instance must also activate it (or any other user of this class). This should be called soon after creation of instance, because everything between construction and activation gets executed both on the master process and on the slaves.
Definition at line 214 of file JobManager.cxx.
|
static |
Definition at line 112 of file JobManager.cxx.
|
static |
Definition at line 130 of file JobManager.cxx.
|
static |
Definition at line 49 of file JobManager.cxx.
bool RooFit::MultiProcess::JobManager::is_activated | ( | ) | const |
Definition at line 229 of file JobManager.cxx.
|
static |
Definition at line 61 of file JobManager.cxx.
Messenger & RooFit::MultiProcess::JobManager::messenger | ( | ) | const |
Definition at line 151 of file JobManager.cxx.
ProcessManager & RooFit::MultiProcess::JobManager::process_manager | ( | ) | const |
Definition at line 146 of file JobManager.cxx.
Queue * RooFit::MultiProcess::JobManager::queue | ( | ) | const |
Definition at line 156 of file JobManager.cxx.
|
static |
Definition at line 137 of file JobManager.cxx.
void RooFit::MultiProcess::JobManager::retrieve | ( | std::size_t | requesting_job_id | ) |
Retrieve results for a Job.
requesting_job_id | ID number of the Job in the JobManager's Job list |
Definition at line 164 of file JobManager.cxx.
|
private |
Definition at line 56 of file JobManager.h.
|
staticprivate |
Definition at line 60 of file JobManager.h.
|
staticprivate |
Definition at line 59 of file JobManager.h.
|
staticprivate |
Definition at line 58 of file JobManager.h.
|
private |
Definition at line 54 of file JobManager.h.
|
private |
Definition at line 53 of file JobManager.h.
|
private |
Definition at line 55 of file JobManager.h.