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

Keeps a queue of tasks for workers and manages the queue process through its event loop.

The Queue maintains a set of tasks on the queue process by receiving them from the master process. Worker processes can request to pop them off the queue. The communication between these processes is handled inside 'Queue::loop()', the queue process's event loop that polls the Messenger's sockets for incoming messages and handles them when they come.

The reason for this class is to get automatic load balancing between workers. By allowing workers to request tasks whenever they are ready to do work, we don't need to manually distribute work over workers and they will always have something to do until all tasks have been completed. The alternative simple strategy of just distributing all tasks evenly over workers will be suboptimal when tasks have different or even varying runtimes (this simple strategy could be implemented with a PUSH-PULL ZeroMQ socket from master to workers, which would distribute tasks in a round-robin fashion, which, indeed, does not do load balancing).

Definition at line 22 of file Queue.h.

Public Member Functions

virtual ~Queue ()=default
 
virtual void add (JobTask job_task)=0
 Enqueue a task.
 
void loop ()
 The queue process's event loop.
 
virtual bool pop (JobTask &job_task)=0
 Have a worker ask for a task-message from the queue.
 
void process_master_message (M2Q message)
 Helper function for 'Queue::loop()'.
 
void process_worker_message (std::size_t this_worker_id, W2Q message)
 Helper function for 'Queue::loop()'.
 

Protected Attributes

std::size_t N_tasks_ = 0
 
std::size_t N_tasks_at_workers_ = 0
 

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

Inheritance diagram for RooFit::MultiProcess::Queue:
[legend]

Constructor & Destructor Documentation

◆ ~Queue()

virtual RooFit::MultiProcess::Queue::~Queue ( )
virtualdefault

Member Function Documentation

◆ add()

virtual void RooFit::MultiProcess::Queue::add ( JobTask  job_task)
pure virtual

Enqueue a task.

Parameters
[in]job_taskJobTask object that contains the Job ID and the task index.

Implemented in RooFit::MultiProcess::FIFOQueue, and RooFit::MultiProcess::PriorityQueue.

◆ loop()

void RooFit::MultiProcess::Queue::loop ( )

The queue process's event loop.

Polls for incoming messages from other processes and handles them.

Definition at line 83 of file Queue.cxx.

◆ pop()

virtual bool RooFit::MultiProcess::Queue::pop ( JobTask job_task)
pure virtual

Have a worker ask for a task-message from the queue.

Parameters
[out]job_taskJobTask reference to put the Job ID and the task index into.
Returns
true if a task was popped from the queue successfully, false if the queue was empty.

Implemented in RooFit::MultiProcess::FIFOQueue, and RooFit::MultiProcess::PriorityQueue.

◆ process_master_message()

void RooFit::MultiProcess::Queue::process_master_message ( M2Q  message)

Helper function for 'Queue::loop()'.

Definition at line 43 of file Queue.cxx.

◆ process_worker_message()

void RooFit::MultiProcess::Queue::process_worker_message ( std::size_t  this_worker_id,
W2Q  message 
)

Helper function for 'Queue::loop()'.

Definition at line 60 of file Queue.cxx.

Member Data Documentation

◆ N_tasks_

std::size_t RooFit::MultiProcess::Queue::N_tasks_ = 0
protected

Definition at line 43 of file Queue.h.

◆ N_tasks_at_workers_

std::size_t RooFit::MultiProcess::Queue::N_tasks_at_workers_ = 0
protected

Definition at line 44 of file Queue.h.

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