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

Fork processes for queue and workers.

This class manages three types of processes:

  1. master: the initial main process. It defines and enqueues tasks and processes results.
  2. workers: a pool of processes that will try to take tasks from the queue. These are forked from master.
  3. queue: This process runs the queue_loop and maintains the queue of tasks. It is also forked from master.
Parameters
N_workersNumber of worker processes to spawn.

Definition at line 26 of file ProcessManager.h.

Public Member Functions

 ProcessManager (std::size_t N_workers)
 
 ~ProcessManager ()
 
pid_t get_queue_pid () const
 
std::vector< pid_t > get_worker_pids ()
 
void identify_processes () const
 Print to stdout which type of process we are on and what its PID is (for debugging)
 
bool is_initialized () const
 
bool is_master () const
 
bool is_queue () const
 
bool is_worker () const
 
std::size_t N_workers () const
 
void terminate () noexcept
 Shutdown forked processes if on master and if this process manager is initialized.
 
void wait_for_sigterm_then_exit ()
 
std::size_t worker_id () const
 

Static Public Member Functions

static void handle_sigterm (int signum)
 We need this to tell the children to die, because we can't talk to them anymore during JobManager destruction, because that kills the Messenger first.
 
static bool sigterm_received ()
 

Private Member Functions

void initialize_processes (bool cpu_pinning=true)
 Fork processes and activate CPU pinning.
 
void shutdown_processes ()
 Shutdown forked processes if on master.
 

Private Attributes

bool initialized_ = false
 
bool is_master_ = false
 
bool is_queue_ = false
 
bool is_worker_ = false
 
std::size_t N_workers_
 
friend Queue
 
pid_t queue_pid_
 
std::size_t worker_id_
 
std::vector< pid_t > worker_pids_
 

Static Private Attributes

static volatile sig_atomic_t sigterm_received_ = 0
 

#include </home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master/roofit/multiprocess/res/RooFit/MultiProcess/ProcessManager.h>

Constructor & Destructor Documentation

◆ ProcessManager()

RooFit::MultiProcess::ProcessManager::ProcessManager ( std::size_t  N_workers)
explicit

Definition at line 41 of file ProcessManager.cxx.

◆ ~ProcessManager()

RooFit::MultiProcess::ProcessManager::~ProcessManager ( )

Definition at line 58 of file ProcessManager.cxx.

Member Function Documentation

◆ get_queue_pid()

pid_t RooFit::MultiProcess::ProcessManager::get_queue_pid ( ) const
inline

Definition at line 50 of file ProcessManager.h.

◆ get_worker_pids()

std::vector< pid_t > RooFit::MultiProcess::ProcessManager::get_worker_pids ( )
inline

Definition at line 51 of file ProcessManager.h.

◆ handle_sigterm()

void RooFit::MultiProcess::ProcessManager::handle_sigterm ( int  signum)
static

We need this to tell the children to die, because we can't talk to them anymore during JobManager destruction, because that kills the Messenger first.

We do that with SIGTERMs. The sigterm_received() should be checked in message loops to stop them when it's true.

Definition at line 75 of file ProcessManager.cxx.

◆ identify_processes()

void RooFit::MultiProcess::ProcessManager::identify_processes ( ) const

Print to stdout which type of process we are on and what its PID is (for debugging)

Definition at line 318 of file ProcessManager.cxx.

◆ initialize_processes()

void RooFit::MultiProcess::ProcessManager::initialize_processes ( bool  cpu_pinning = true)
private

Fork processes and activate CPU pinning.

Parameters
cpu_pinningActivate CPU pinning if true. Effective on Linux only.

Definition at line 111 of file ProcessManager.cxx.

◆ is_initialized()

bool RooFit::MultiProcess::ProcessManager::is_initialized ( ) const

Definition at line 204 of file ProcessManager.cxx.

◆ is_master()

bool RooFit::MultiProcess::ProcessManager::is_master ( ) const

Definition at line 292 of file ProcessManager.cxx.

◆ is_queue()

bool RooFit::MultiProcess::ProcessManager::is_queue ( ) const

Definition at line 297 of file ProcessManager.cxx.

◆ is_worker()

bool RooFit::MultiProcess::ProcessManager::is_worker ( ) const

Definition at line 302 of file ProcessManager.cxx.

◆ N_workers()

std::size_t RooFit::MultiProcess::ProcessManager::N_workers ( ) const

Definition at line 312 of file ProcessManager.cxx.

◆ shutdown_processes()

void RooFit::MultiProcess::ProcessManager::shutdown_processes ( )
private

Shutdown forked processes if on master.

Definition at line 266 of file ProcessManager.cxx.

◆ sigterm_received()

bool RooFit::MultiProcess::ProcessManager::sigterm_received ( )
static

Definition at line 81 of file ProcessManager.cxx.

◆ terminate()

void RooFit::MultiProcess::ProcessManager::terminate ( )
noexcept

Shutdown forked processes if on master and if this process manager is initialized.

Definition at line 210 of file ProcessManager.cxx.

◆ wait_for_sigterm_then_exit()

void RooFit::MultiProcess::ProcessManager::wait_for_sigterm_then_exit ( )

Definition at line 222 of file ProcessManager.cxx.

◆ worker_id()

std::size_t RooFit::MultiProcess::ProcessManager::worker_id ( ) const

Definition at line 307 of file ProcessManager.cxx.

Member Data Documentation

◆ initialized_

bool RooFit::MultiProcess::ProcessManager::initialized_ = false
private

Definition at line 67 of file ProcessManager.h.

◆ is_master_

bool RooFit::MultiProcess::ProcessManager::is_master_ = false
private

Definition at line 57 of file ProcessManager.h.

◆ is_queue_

bool RooFit::MultiProcess::ProcessManager::is_queue_ = false
private

Definition at line 58 of file ProcessManager.h.

◆ is_worker_

bool RooFit::MultiProcess::ProcessManager::is_worker_ = false
private

Definition at line 59 of file ProcessManager.h.

◆ N_workers_

std::size_t RooFit::MultiProcess::ProcessManager::N_workers_
private

Definition at line 61 of file ProcessManager.h.

◆ Queue

friend RooFit::MultiProcess::ProcessManager::Queue
private

Definition at line 27 of file ProcessManager.h.

◆ queue_pid_

pid_t RooFit::MultiProcess::ProcessManager::queue_pid_
private

Definition at line 65 of file ProcessManager.h.

◆ sigterm_received_

volatile sig_atomic_t RooFit::MultiProcess::ProcessManager::sigterm_received_ = 0
staticprivate

Definition at line 69 of file ProcessManager.h.

◆ worker_id_

std::size_t RooFit::MultiProcess::ProcessManager::worker_id_
private

Definition at line 60 of file ProcessManager.h.

◆ worker_pids_

std::vector<pid_t> RooFit::MultiProcess::ProcessManager::worker_pids_
private

Definition at line 64 of file ProcessManager.h.

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