Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooRealMPFE.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooRealMPFE.cxx
19\class RooRealMPFE
20\ingroup Roofitcore
21
22Multi-processor front-end for parallel calculation
23of RooAbsReal objects. Each RooRealMPFE forks a process that calculates
24the value of the proxies RooAbsReal object. The (re)calculation of
25the proxied object is started asynchronously with the calculate() option.
26A subsequent call to getVal() will return the calculated value when available
27If the calculation is still in progress when getVal() is called it blocks
28the calling process until the calculation is done. The forked calculation process
29is terminated when the front-end object is deleted
30Simple use demonstration
31
32~~~{.cpp}
33RooAbsReal* slowFunc ;
34
35double val = slowFunc->getVal() // Evaluate slowFunc in current process
36
37RooRealMPFE mpfe("mpfe","frontend to slowFunc",*slowFunc) ;
38mpfe.calculate() ; // Start calculation of slow-func in remote process
39 // .. do other stuff here ..
40double val = mpfe.getVal() // Wait for remote calculation to finish and retrieve value
41~~~
42
43For general multiprocessing in ROOT, please refer to the TProcessExecutor class.
44
45**/
46
47#include "Riostream.h"
48
49#ifndef _WIN32
50#include "BidirMMapPipe.h"
51#endif
52
53#include <cstdlib>
54#include <sstream>
55#include "RooRealMPFE.h"
56#include "RooArgSet.h"
57#include "RooAbsCategory.h"
58#include "RooRealVar.h"
59#include "RooCategory.h"
60#include "RooMsgService.h"
61#include "RooNLLVar.h"
62#include "RooTrace.h"
63
64#include "Rtypes.h"
65#include "TSystem.h"
66
67
68class RooRealMPFE ;
69
70// RooMPSentinel is a singleton class that keeps track of all
71// parallel execution processes for goodness-of-fit calculations.
72// The primary task of RooMPSentinel is to terminate all server processes
73// when the main ROOT process is exiting.
75
76 static RooMPSentinel& instance();
77
79
80 void add(RooRealMPFE& mpfe) ;
81 void remove(RooRealMPFE& mpfe) ;
82
84};
85
87 static RooMPSentinel inst;
88 return inst;
89}
90
91
92using namespace std;
93using namespace RooFit;
94
96
97
98////////////////////////////////////////////////////////////////////////////////
99/// Construct front-end object for object 'arg' whose evaluation will be calculated
100/// asynchronously in a separate process. If calcInline is true the value of 'arg'
101/// is calculate synchronously in the current process.
102
103RooRealMPFE::RooRealMPFE(const char *name, const char *title, RooAbsReal& arg, bool calcInline) :
104 RooAbsReal(name,title),
105 _state(Initialize),
106 _arg("arg","arg",this,arg),
107 _vars("vars","vars",this),
108 _calcInProgress(false),
109 _verboseClient(false),
110 _verboseServer(false),
111 _inlineMode(calcInline),
112 _remoteEvalErrorLoggingState(RooAbsReal::PrintErrors),
113 _pipe(nullptr),
114 _updateMaster(nullptr),
115 _retrieveDispatched(false), _evalCarry(0.)
116{
117#ifdef _WIN32
118 _inlineMode = true;
119#endif
120 initVars() ;
122
123}
124
125
126
127////////////////////////////////////////////////////////////////////////////////
128/// Copy constructor. Initializes in clean state so that upon eval
129/// this instance will create its own server processes
130
131RooRealMPFE::RooRealMPFE(const RooRealMPFE& other, const char* name) :
132 RooAbsReal(other, name),
133 _state(Initialize),
134 _arg("arg",this,other._arg),
135 _vars("vars",this,other._vars),
136 _calcInProgress(false),
137 _verboseClient(other._verboseClient),
138 _verboseServer(other._verboseServer),
139 _inlineMode(other._inlineMode),
140 _forceCalc(other._forceCalc),
141 _remoteEvalErrorLoggingState(other._remoteEvalErrorLoggingState),
142 _pipe(nullptr),
143 _updateMaster(nullptr),
144 _retrieveDispatched(false), _evalCarry(other._evalCarry)
145{
146 initVars() ;
148}
149
150
151
152////////////////////////////////////////////////////////////////////////////////
153/// Destructor
154
156{
157 if (_state==Client) standby();
159}
160
161
162
163////////////////////////////////////////////////////////////////////////////////
164/// Initialize list of variables of front-end argument 'arg'
165
167{
168 // Empty current lists
169 _vars.removeAll() ;
171
172 // Retrieve non-constant parameters
173 auto vars = _arg->getParameters(RooArgSet());
174 //RooArgSet* ncVars = (RooArgSet*) vars->selectByAttrib("Constant",false) ;
175 RooArgList varList(*vars) ;
176
177 // Save in lists
178 _vars.add(varList) ;
179 _saveVars.addClone(varList) ;
180 _valueChanged.resize(_vars.getSize()) ;
181 _constChanged.resize(_vars.getSize()) ;
182
183 // Force next calculation
184 _forceCalc = true ;
185}
186
188{
189 if (_inlineMode) {
190 RooAbsTestStatistic* tmp = dynamic_cast<RooAbsTestStatistic*>(_arg.absArg());
191 if (tmp) return tmp->getCarry();
192 else return 0.;
193 } else {
194 return _evalCarry;
195 }
196}
197
198////////////////////////////////////////////////////////////////////////////////
199/// Initialize the remote process and message passing
200/// pipes between current process and remote process
201
203{
204 // Trivial case: Inline mode
205 if (_inlineMode) {
206 _state = Inline ;
207 return ;
208 }
209
210#ifndef _WIN32
211 // Clear eval error log prior to forking
212 // to avoid confusions...
214 // Fork server process and setup IPC
215 _pipe = new BidirMMapPipe();
216
217 if (_pipe->isChild()) {
218 // Start server loop
220 _state = Server ;
221 serverLoop();
222
223 // Kill server at end of service
224 if (_verboseServer) ccoutD(Minimization) << "RooRealMPFE::initialize(" <<
225 GetName() << ") server process terminating" << endl ;
226
227 delete _arg.absArg();
228 delete _pipe;
229 _exit(0) ;
230 } else {
231 // Client process - fork successful
232 if (_verboseClient) ccoutD(Minimization) << "RooRealMPFE::initialize(" <<
233 GetName() << ") successfully forked server process " <<
234 _pipe->pidOtherEnd() << endl ;
235 _state = Client ;
236 _calcInProgress = false ;
237 }
238#endif // _WIN32
239}
240
241
242
243////////////////////////////////////////////////////////////////////////////////
244/// Server loop of remote processes. This function will return
245/// only when an incoming TERMINATE message is received.
246
248{
249#ifndef _WIN32
250 int msg ;
251
252 Int_t idx, index, numErrors ;
253 double value ;
254 bool isConst ;
255
257
258 while(*_pipe && !_pipe->eof()) {
259 *_pipe >> msg;
260 if (Terminate == msg) {
261 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
262 << ") IPC fromClient> Terminate" << endl;
263 // send terminate acknowledged to client
264 *_pipe << msg << BidirMMapPipe::flush;
265 break;
266 }
267
268 switch (msg) {
269 case SendReal:
270 {
271 *_pipe >> idx >> value >> isConst;
272 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
273 << ") IPC fromClient> SendReal [" << idx << "]=" << value << endl ;
274 RooRealVar* rvar = (RooRealVar*)_vars.at(idx) ;
275 rvar->setVal(value) ;
276 if (rvar->isConstant() != isConst) {
277 rvar->setConstant(isConst) ;
278 }
279 }
280 break ;
281
282 case SendCat:
283 {
284 *_pipe >> idx >> index;
285 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
286 << ") IPC fromClient> SendCat [" << idx << "]=" << index << endl ;
287 ((RooCategory*)_vars.at(idx))->setIndex(index) ;
288 }
289 break ;
290
291 case Calculate:
292 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
293 << ") IPC fromClient> Calculate" << endl ;
294 _value = _arg ;
295 break ;
296
298 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
299 << ") IPC fromClient> Calculate" << endl ;
300
302 _value = _arg ;
304 break ;
305
306 case Retrieve:
307 {
308 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
309 << ") IPC fromClient> Retrieve" << endl ;
310 msg = ReturnValue;
311 numErrors = numEvalErrors();
312 *_pipe << msg << _value << getCarry() << numErrors;
313
314 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
315 << ") IPC toClient> ReturnValue " << _value << " NumError " << numErrors << endl ;
316
317 if (numErrors) {
318 // Loop over errors
319 std::string objidstr;
320 {
321 ostringstream oss2;
322 // Format string with object identity as this cannot be evaluated on the other side
323 oss2 << "PID" << gSystem->GetPid() << "/";
325 objidstr = oss2.str();
326 }
327 std::map<const RooAbsArg*,pair<string,list<EvalError> > >::const_iterator iter = evalErrorIter();
328 const RooAbsArg* ptr = nullptr;
329 for (int i = 0; i < numEvalErrorItems(); ++i) {
330 list<EvalError>::const_iterator iter2 = iter->second.second.begin();
331 for (; iter->second.second.end() != iter2; ++iter2) {
332 ptr = iter->first;
333 *_pipe << ptr << iter2->_msg << iter2->_srvval << objidstr;
334 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
335 << ") IPC toClient> sending error log Arg " << iter->first << " Msg " << iter2->_msg << endl ;
336 }
337 }
338 // let other end know that we're done with the list of errors
339 ptr = nullptr;
340 *_pipe << ptr;
341 // Clear error list on local side
343 }
344 *_pipe << BidirMMapPipe::flush;
345 }
346 break;
347
348 case ConstOpt:
349 {
350 bool doTrack ;
351 int code;
352 *_pipe >> code >> doTrack;
353 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
354 << ") IPC fromClient> ConstOpt " << code << " doTrack = " << (doTrack?"T":"F") << endl ;
355 ((RooAbsReal&)_arg.arg()).constOptimizeTestStatistic(static_cast<RooAbsArg::ConstOpCode>(code),doTrack) ;
356 break ;
357 }
358
359 case Verbose:
360 {
361 bool flag ;
362 *_pipe >> flag;
363 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
364 << ") IPC fromClient> Verbose " << (flag?1:0) << endl ;
365 _verboseServer = flag ;
366 }
367 break ;
368
369
370 case ApplyNLLW2:
371 {
372 bool flag ;
373 *_pipe >> flag;
374 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
375 << ") IPC fromClient> ApplyNLLW2 " << (flag?1:0) << endl ;
376
377 // Do application of weight-squared here
378 doApplyNLLW2(flag) ;
379 }
380 break ;
381
382 case EnableOffset:
383 {
384 bool flag ;
385 *_pipe >> flag;
386 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
387 << ") IPC fromClient> EnableOffset " << (flag?1:0) << endl ;
388
389 // Enable likelihoof offsetting here
390 ((RooAbsReal&)_arg.arg()).enableOffsetting(flag) ;
391 }
392 break ;
393
394 case LogEvalError:
395 {
396 int iflag2;
397 *_pipe >> iflag2;
400 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
401 << ") IPC fromClient> LogEvalError flag = " << flag2 << endl ;
402 }
403 break ;
404
405
406 default:
407 if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
408 << ") IPC fromClient> Unknown message (code = " << msg << ")" << endl ;
409 break ;
410 }
411 }
412
413#endif // _WIN32
414}
415
416
417
418////////////////////////////////////////////////////////////////////////////////
419/// Client-side function that instructs server process to start
420/// asynchronuous (re)calculation of function value. This function
421/// returns immediately. The calculated value can be retrieved
422/// using getVal()
423
425{
426
427 // Start asynchronous calculation of arg value
428 if (_state==Initialize) {
429 // cout << "RooRealMPFE::calculate(" << GetName() << ") initializing" << endl ;
430 const_cast<RooRealMPFE*>(this)->initialize() ;
431 }
432
433 // Inline mode -- Calculate value now
434 if (_state==Inline) {
435 // cout << "RooRealMPFE::calculate(" << GetName() << ") performing Inline calculation NOW" << endl ;
436 _value = _arg ;
438 }
439
440#ifndef _WIN32
441 // Compare current value of variables with saved values and send changes to server
442 if (_state==Client) {
443 // cout << "RooRealMPFE::calculate(" << GetName() << ") state is Client trigger remote calculation" << endl ;
444 Int_t i(0) ;
445
446 //for (i=0 ; i<_vars.getSize() ; i++) {
447 RooAbsArg *var, *saveVar ;
448 for (std::size_t j=0 ; j<_vars.size() ; j++) {
449 var = _vars.at(j);
450 saveVar = _saveVars.at(j);
451
452 //bool valChanged = !(*var==*saveVar) ;
453 bool valChanged,constChanged ;
454 if (!_updateMaster) {
455 valChanged = !var->isIdentical(*saveVar,true) ;
456 constChanged = (var->isConstant() != saveVar->isConstant()) ;
457 _valueChanged[i] = valChanged ;
458 _constChanged[i] = constChanged ;
459 } else {
460 valChanged = _updateMaster->_valueChanged[i] ;
461 constChanged = _updateMaster->_constChanged[i] ;
462 }
463
464 if ( valChanged || constChanged || _forceCalc) {
465 //cout << "RooRealMPFE::calculate(" << GetName() << " variable " << var->GetName() << " changed " << endl ;
466 if (_verboseClient) cout << "RooRealMPFE::calculate(" << GetName()
467 << ") variable " << _vars.at(i)->GetName() << " changed" << endl ;
468 if (constChanged) {
469 ((RooRealVar*)saveVar)->setConstant(var->isConstant()) ;
470 }
471 saveVar->copyCache(var) ;
472
473 // send message to server
474 if (dynamic_cast<RooAbsReal*>(var)) {
475 int msg = SendReal ;
476 double val = ((RooAbsReal*)var)->getVal() ;
477 bool isC = var->isConstant() ;
478 *_pipe << msg << i << val << isC;
479
480 if (_verboseServer) cout << "RooRealMPFE::calculate(" << GetName()
481 << ") IPC toServer> SendReal [" << i << "]=" << val << (isC?" (Constant)":"") << endl ;
482 } else if (dynamic_cast<RooAbsCategory*>(var)) {
483 int msg = SendCat ;
484 UInt_t idx = ((RooAbsCategory*)var)->getCurrentIndex() ;
485 *_pipe << msg << i << idx;
486 if (_verboseServer) cout << "RooRealMPFE::calculate(" << GetName()
487 << ") IPC toServer> SendCat [" << i << "]=" << idx << endl ;
488 }
489 }
490 i++ ;
491 }
492
493 int msg = hideOffset() ? Calculate : CalculateNoOffset;
494 *_pipe << msg;
495 if (_verboseServer) cout << "RooRealMPFE::calculate(" << GetName()
496 << ") IPC toServer> Calculate " << endl ;
497
498 // Clear dirty state and mark that calculation request was dispatched
500 _calcInProgress = true ;
501 _forceCalc = false ;
502
503 msg = Retrieve ;
504 *_pipe << msg << BidirMMapPipe::flush;
505 if (_verboseServer) cout << "RooRealMPFE::evaluate(" << GetName()
506 << ") IPC toServer> Retrieve " << endl ;
507 _retrieveDispatched = true ;
508
509 } else if (_state!=Inline) {
510 cout << "RooRealMPFE::calculate(" << GetName()
511 << ") ERROR not in Client or Inline mode" << endl ;
512 }
513
514
515#endif // _WIN32
516}
517
518
519
520
521////////////////////////////////////////////////////////////////////////////////
522/// If value needs recalculation and calculation has not been started
523/// with a call to calculate() start it now. This function blocks
524/// until remote process has finished calculation and returns
525/// remote value
526
527double RooRealMPFE::getValV(const RooArgSet* /*nset*/) const
528{
529
530 if (isValueDirty()) {
531 // Cache is dirty, no calculation has been started yet
532 //cout << "RooRealMPFE::getValF(" << GetName() << ") cache is dirty, calling calculate and evaluate" << endl ;
533 calculate() ;
534 _value = evaluate() ;
535 } else if (_calcInProgress) {
536 //cout << "RooRealMPFE::getValF(" << GetName() << ") calculation in progress, calling evaluate" << endl ;
537 // Cache is clean and calculation is in progress
538 _value = evaluate() ;
539 } else {
540 //cout << "RooRealMPFE::getValF(" << GetName() << ") cache is clean, doing nothing" << endl ;
541 // Cache is clean and calculated value is in cache
542 }
543
544// cout << "RooRealMPFE::getValV(" << GetName() << ") value = " << Form("%5.10f",_value) << endl ;
545 return _value ;
546}
547
548
549
550////////////////////////////////////////////////////////////////////////////////
551/// Send message to server process to retrieve output value
552/// If error were logged use logEvalError() on remote side
553/// transfer those errors to the local eval error queue.
554
556{
557 // Retrieve value of arg
558 double return_value = 0;
559 if (_state==Inline) {
560 return_value = _arg ;
561 } else if (_state==Client) {
562#ifndef _WIN32
563 bool needflush = false;
564 int msg;
565 double value;
566
567 // If current error logging state is not the same as remote state
568 // update the remote state
570 msg = LogEvalError ;
572 *_pipe << msg << flag;
573 needflush = true;
575 }
576
577 if (!_retrieveDispatched) {
578 msg = Retrieve ;
579 *_pipe << msg;
580 needflush = true;
581 if (_verboseServer) cout << "RooRealMPFE::evaluate(" << GetName()
582 << ") IPC toServer> Retrieve " << endl ;
583 }
584 if (needflush) *_pipe << BidirMMapPipe::flush;
585 _retrieveDispatched = false ;
586
587
588 Int_t numError;
589
590 *_pipe >> msg >> value >> _evalCarry >> numError;
591
592 if (msg!=ReturnValue) {
593 cout << "RooRealMPFE::evaluate(" << GetName()
594 << ") ERROR: unexpected message from server process: " << msg << endl ;
595 return 0 ;
596 }
597 if (_verboseServer) cout << "RooRealMPFE::evaluate(" << GetName()
598 << ") IPC fromServer> ReturnValue " << value << endl ;
599
600 if (_verboseServer) cout << "RooRealMPFE::evaluate(" << GetName()
601 << ") IPC fromServer> NumErrors " << numError << endl ;
602 if (numError) {
603 // Retrieve remote errors and feed into local error queue
604 char *msgbuf1 = nullptr, *msgbuf2 = nullptr, *msgbuf3 = nullptr;
605 RooAbsArg *ptr = nullptr;
606 while (true) {
607 *_pipe >> ptr;
608 if (!ptr) break;
609 *_pipe >> msgbuf1 >> msgbuf2 >> msgbuf3;
610 if (_verboseServer) cout << "RooRealMPFE::evaluate(" << GetName()
611 << ") IPC fromServer> retrieving error log Arg " << ptr << " Msg " << msgbuf1 << endl ;
612
613 logEvalError(reinterpret_cast<RooAbsReal*>(ptr),msgbuf3,msgbuf1,msgbuf2) ;
614 }
615 std::free(msgbuf1);
616 std::free(msgbuf2);
617 std::free(msgbuf3);
618 }
619
620 // Mark end of calculation in progress
621 _calcInProgress = false ;
622 return_value = value ;
623#endif // _WIN32
624 }
625
626 return return_value;
627}
628
629
630
631////////////////////////////////////////////////////////////////////////////////
632/// Terminate remote server process and return front-end class
633/// to standby mode. Calls to calculate() or evaluate() after
634/// this call will automatically recreated the server process.
635
637{
638#ifndef _WIN32
639 if (_state==Client) {
640 if (_pipe->good()) {
641 // Terminate server process ;
642 if (_verboseServer) cout << "RooRealMPFE::standby(" << GetName()
643 << ") IPC toServer> Terminate " << endl;
644 int msg = Terminate;
645 *_pipe << msg << BidirMMapPipe::flush;
646 // read handshake
647 msg = 0;
648 *_pipe >> msg;
649 if (Terminate != msg || 0 != _pipe->close()) {
650 std::cerr << "In " << __func__ << "(" << __FILE__ ", " << __LINE__ <<
651 "): Server shutdown failed." << std::endl;
652 }
653 } else {
654 if (_verboseServer) {
655 std::cerr << "In " << __func__ << "(" << __FILE__ ", " <<
656 __LINE__ << "): Pipe has already shut down, not sending "
657 "Terminate to server." << std::endl;
658 }
659 }
660 // Close pipes
661 delete _pipe;
662 _pipe = nullptr;
663
664 // Revert to initialize state
666 }
667#endif // _WIN32
668}
669
670
671
672////////////////////////////////////////////////////////////////////////////////
673/// Intercept call to optimize constant term in test statistics
674/// and forward it to object on server side.
675
677{
678#ifndef _WIN32
679 if (_state==Client) {
680
681 int msg = ConstOpt ;
682 int op = opcode;
683 *_pipe << msg << op << doAlsoTracking;
684 if (_verboseServer) cout << "RooRealMPFE::constOptimize(" << GetName()
685 << ") IPC toServer> ConstOpt " << opcode << endl ;
686
687 initVars() ;
688 }
689#endif // _WIN32
690
691 if (_state==Inline) {
692 ((RooAbsReal&)_arg.arg()).constOptimizeTestStatistic(opcode,doAlsoTracking) ;
693 }
694}
695
696
697
698////////////////////////////////////////////////////////////////////////////////
699/// Control verbose messaging related to inter process communication
700/// on both client and server side
701
702void RooRealMPFE::setVerbose(bool clientFlag, bool serverFlag)
703{
704#ifndef _WIN32
705 if (_state==Client) {
706 int msg = Verbose ;
707 *_pipe << msg << serverFlag;
708 if (_verboseServer) cout << "RooRealMPFE::setVerbose(" << GetName()
709 << ") IPC toServer> Verbose " << (serverFlag?1:0) << endl ;
710 }
711#endif // _WIN32
712 _verboseClient = clientFlag ; _verboseServer = serverFlag ;
713}
714
715
716////////////////////////////////////////////////////////////////////////////////
717/// Control verbose messaging related to inter process communication
718/// on both client and server side
719
721{
722#ifndef _WIN32
723 if (_state==Client) {
724 int msg = ApplyNLLW2 ;
725 *_pipe << msg << flag;
726 if (_verboseServer) cout << "RooRealMPFE::applyNLLWeightSquared(" << GetName()
727 << ") IPC toServer> ApplyNLLW2 " << (flag?1:0) << endl ;
728 }
729#endif // _WIN32
730 doApplyNLLW2(flag) ;
731}
732
733
734////////////////////////////////////////////////////////////////////////////////
735
737{
738 RooNLLVar* nll = dynamic_cast<RooNLLVar*>(_arg.absArg()) ;
739 if (nll) {
740 nll->applyWeightSquared(flag) ;
741 }
742}
743
744
745////////////////////////////////////////////////////////////////////////////////
746/// Control verbose messaging related to inter process communication
747/// on both client and server side
748
750{
751#ifndef _WIN32
752 if (_state==Client) {
753 int msg = EnableOffset ;
754 *_pipe << msg << flag;
755 if (_verboseServer) cout << "RooRealMPFE::enableOffsetting(" << GetName()
756 << ") IPC toServer> EnableOffset " << (flag?1:0) << endl ;
757 }
758#endif // _WIN32
759 ((RooAbsReal&)_arg.arg()).enableOffsetting(flag) ;
760}
761
762
763
764////////////////////////////////////////////////////////////////////////////////
765/// Destructor. Terminate all parallel processes still registered with
766/// the sentinel
767
769{
770 for(auto * mpfe : static_range_cast<RooRealMPFE*>(_mpfeSet)) {
771 mpfe->standby() ;
772 }
773}
774
775
776
777////////////////////////////////////////////////////////////////////////////////
778/// Register given multi-processor front-end object with the sentinel
779
781{
782 _mpfeSet.add(mpfe,true) ;
783}
784
785
786
787////////////////////////////////////////////////////////////////////////////////
788/// Remove given multi-processor front-end object from the sentinel
789
791{
792 _mpfeSet.remove(mpfe,true) ;
793}
794
#define ccoutD(a)
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
R__EXTERN TSystem * gSystem
Definition TSystem.h:560
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:79
virtual void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValDirty=true)=0
bool isConstant() const
Check if the "Constant" attribute is set.
Definition RooAbsArg.h:363
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
void clearValueDirty() const
Definition RooAbsArg.h:604
bool isValueDirty() const
Definition RooAbsArg.h:421
virtual bool isIdentical(const RooAbsArg &other, bool assumeSameType=false) const =0
friend class RooRealMPFE
Definition RooAbsArg.h:670
A space to attach TBranches.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
void setConstant(bool value=true)
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
static Int_t numEvalErrorItems()
static bool hideOffset()
static EvalErrorIter evalErrorIter()
static ErrorLoggingMode evalErrorLoggingMode()
Return current evaluation error logging mode.
double _value
Cache for current value of object.
Definition RooAbsReal.h:543
static void setHideOffset(bool flag)
static Int_t numEvalErrors()
Return the number of logged evaluation errors since the last clearing.
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
void logEvalError(const char *message, const char *serverValueString=nullptr) const
Log evaluation error message.
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
Abstract base class for all test statistics.
virtual double getCarry() const
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition RooArgList.h:110
RooAbsArg * absArg() const
Return pointer to contained argument.
Definition RooArgProxy.h:46
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
Object to represent discrete states.
Definition RooCategory.h:28
void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
Class RooNLLVar implements a -log(likelihood) calculation from a dataset and a PDF.
Definition RooNLLVar.h:25
void applyWeightSquared(bool flag) override
Disables or enables the usage of squared weights.
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
Multi-processor front-end for parallel calculation of RooAbsReal objects.
Definition RooRealMPFE.h:29
RooFit::BidirMMapPipe * _pipe
! connection to child
Definition RooRealMPFE.h:81
RooArgList _saveVars
Copy of variables.
Definition RooRealMPFE.h:73
void calculate() const
Client-side function that instructs server process to start asynchronuous (re)calculation of function...
void initialize()
Initialize the remote process and message passing pipes between current process and remote process.
void serverLoop()
Server loop of remote processes.
void standby()
Terminate remote server process and return front-end class to standby mode.
bool _calcInProgress
Definition RooRealMPFE.h:74
RooListProxy _vars
Variables.
Definition RooRealMPFE.h:72
double _evalCarry
!
Definition RooRealMPFE.h:87
void applyNLLWeightSquared(bool flag)
Control verbose messaging related to inter process communication on both client and server side.
void initVars()
Initialize list of variables of front-end argument 'arg'.
RooRealMPFE * _updateMaster
! Update master
Definition RooRealMPFE.h:85
void doApplyNLLW2(bool flag)
bool _retrieveDispatched
!
Definition RooRealMPFE.h:86
bool _verboseClient
Definition RooRealMPFE.h:75
void setVerbose(bool clientFlag=true, bool serverFlag=true)
Control verbose messaging related to inter process communication on both client and server side.
bool _forceCalc
Definition RooRealMPFE.h:78
std::vector< bool > _constChanged
! Flags if variable needs update on server-side
Definition RooRealMPFE.h:84
double evaluate() const override
Send message to server process to retrieve output value If error were logged use logEvalError() on re...
void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTracking=true) override
Intercept call to optimize constant term in test statistics and forward it to object on server side.
virtual double getCarry() const
std::vector< bool > _valueChanged
! Flags if variable needs update on server-side
Definition RooRealMPFE.h:83
void enableOffsetting(bool flag) override
Control verbose messaging related to inter process communication on both client and server side.
bool _verboseServer
Definition RooRealMPFE.h:76
RooRealProxy _arg
Function to calculate in parallel process.
Definition RooRealMPFE.h:71
bool _inlineMode
Definition RooRealMPFE.h:77
~RooRealMPFE() override
Destructor.
RooAbsReal::ErrorLoggingMode _remoteEvalErrorLoggingState
Definition RooRealMPFE.h:79
double getValV(const RooArgSet *nset=nullptr) const override
If value needs recalculation and calculation has not been started with a call to calculate() start it...
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:37
void setVal(double value) override
Set value of variable to 'value'.
const T & arg() const
Return reference to object held in proxy.
static void callgrind_zero()
Utility function to trigger zeroing of callgrind counters.
Definition RooTrace.cxx:354
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
virtual int GetPid()
Get process id.
Definition TSystem.cxx:694
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26
void remove(RooRealMPFE &mpfe)
Remove given multi-processor front-end object from the sentinel.
RooArgSet _mpfeSet
void add(RooRealMPFE &mpfe)
Register given multi-processor front-end object with the sentinel.
static RooMPSentinel & instance()
~RooMPSentinel()
Destructor.