Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooFit::MultiProcess::JobManager Class Reference

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
 
Messengermessenger () const
 
ProcessManagerprocess_manager () const
 
Queuequeue () 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 Jobget_job_object (std::size_t job_object_id)
 
static JobManagerinstance ()
 
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< Messengermessenger_ptr_
 
std::unique_ptr< ProcessManagerprocess_manager_ptr_
 
std::unique_ptr< Queuequeue_ptr_
 

Static Private Attributes

static std::unique_ptr< JobManagerinstance_ {nullptr}
 
static std::size_t job_counter_ = 0
 
static std::map< std::size_t, Job * > job_objects_
 

#include </home/sftnight/build/workspace/root-makedoc-v628/rootspi/rdoc/src/v6-28-00-patches/roofit/multiprocess/res/RooFit/MultiProcess/JobManager.h>

Constructor & Destructor Documentation

◆ ~JobManager()

RooFit::MultiProcess::JobManager::~JobManager ( )

Definition at line 85 of file JobManager.cxx.

◆ JobManager()

RooFit::MultiProcess::JobManager::JobManager ( std::size_t  N_workers)
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.

Member Function Documentation

◆ activate()

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.

◆ add_job_object()

std::size_t RooFit::MultiProcess::JobManager::add_job_object ( Job job_object)
static
Returns
job_id for added job_object

Definition at line 112 of file JobManager.cxx.

◆ get_job_object()

Job * RooFit::MultiProcess::JobManager::get_job_object ( std::size_t  job_object_id)
static

Definition at line 130 of file JobManager.cxx.

◆ instance()

JobManager * RooFit::MultiProcess::JobManager::instance ( )
static

Definition at line 49 of file JobManager.cxx.

◆ is_activated()

bool RooFit::MultiProcess::JobManager::is_activated ( ) const

Definition at line 229 of file JobManager.cxx.

◆ is_instantiated()

bool RooFit::MultiProcess::JobManager::is_instantiated ( )
static

Definition at line 61 of file JobManager.cxx.

◆ messenger()

Messenger & RooFit::MultiProcess::JobManager::messenger ( ) const

Definition at line 151 of file JobManager.cxx.

◆ process_manager()

ProcessManager & RooFit::MultiProcess::JobManager::process_manager ( ) const

Definition at line 146 of file JobManager.cxx.

◆ queue()

Queue * RooFit::MultiProcess::JobManager::queue ( ) const

Definition at line 156 of file JobManager.cxx.

◆ remove_job_object()

bool RooFit::MultiProcess::JobManager::remove_job_object ( std::size_t  job_object_id)
static
Returns
Returns 'true' when removed successfully, 'false' otherwise.

Definition at line 137 of file JobManager.cxx.

◆ retrieve()

void RooFit::MultiProcess::JobManager::retrieve ( std::size_t  requesting_job_id)

Retrieve results for a Job.

Parameters
requesting_job_idID number of the Job in the JobManager's Job list

Definition at line 164 of file JobManager.cxx.

Member Data Documentation

◆ activated_

bool RooFit::MultiProcess::JobManager::activated_ = false
private

Definition at line 56 of file JobManager.h.

◆ instance_

std::unique_ptr< JobManager > RooFit::MultiProcess::JobManager::instance_ {nullptr}
staticprivate

Definition at line 60 of file JobManager.h.

◆ job_counter_

std::size_t RooFit::MultiProcess::JobManager::job_counter_ = 0
staticprivate

Definition at line 59 of file JobManager.h.

◆ job_objects_

std::map< std::size_t, Job * > RooFit::MultiProcess::JobManager::job_objects_
staticprivate

Definition at line 58 of file JobManager.h.

◆ messenger_ptr_

std::unique_ptr<Messenger> RooFit::MultiProcess::JobManager::messenger_ptr_
private

Definition at line 54 of file JobManager.h.

◆ process_manager_ptr_

std::unique_ptr<ProcessManager> RooFit::MultiProcess::JobManager::process_manager_ptr_
private

Definition at line 53 of file JobManager.h.

◆ queue_ptr_

std::unique_ptr<Queue> RooFit::MultiProcess::JobManager::queue_ptr_
private

Definition at line 55 of file JobManager.h.

  • roofit/multiprocess/res/RooFit/MultiProcess/JobManager.h
  • roofit/multiprocess/src/JobManager.cxx