The Gaudi Framework  v30r3 (a5ef0a68)
CFplusViewBug.py
Go to the documentation of this file.
1 #!/usr/bin/env gaudirun.py
2 
3 '''
4 A deliberately badly-configured job to demonstrate a crash in
5 sub-event scheduling.
6 
7 The ViewTester is an algorithm specifically designed to create sub-event
8 contexts, pass them to the scheduler, and report on the current context.
9 
10 The re-use of filter_alg causes the CF to "skip over" filter_alg2
11 This would then cause sub-events to be scheduled, but with the
12 "ShortCircuit" property of the hltStep node set True, the event can
13 be deleted before the sub-events have completed, causing the crash.
14 
15 There is now protection in AvalancheScheduler against this crash,
16 but note that re-using algs in this way is still expected to cause
17 surprising CF behaviour.
18 '''
19 from Gaudi.Configuration import *
20 from Configurables import (HiveWhiteBoard, HiveSlimEventLoopMgr,
21  AvalancheSchedulerSvc, AlgResourcePool,
22  CPUCruncher, GaudiSequencer, Test__ViewTester)
23 
24 # metaconfig -------------------------------------------------------------------
25 # It's confortable to collect the relevant parameters at the top of the optionfile
26 evtslots = 1
27 evtMax = 10
28 cardinality = 1
29 threads = 1
30 viewsPerEvt = 2
31 # -------------------------------------------------------------------------------
32 
33 # The configuration of the whiteboard ------------------------------------------
34 # It is useful to call it EventDataSvc to replace the usual data service with
35 # the whiteboard transparently.
36 
37 whiteboard = HiveWhiteBoard("EventDataSvc", EventSlots=evtslots)
38 
39 # -------------------------------------------------------------------------------
40 
41 # Event Loop Manager -----------------------------------------------------------
42 # It's called slim since it has less functionalities overall than the good-old
43 # event loop manager. Here we just set its outputlevel to DEBUG.
44 
45 slimeventloopmgr = HiveSlimEventLoopMgr(
46  SchedulerName="AvalancheSchedulerSvc", OutputLevel=INFO)
47 
48 # -------------------------------------------------------------------------------
49 
50 # ForwardScheduler -------------------------------------------------------------
51 # We just decide how many algorithms in flight we want to have and how many
52 # threads in the pool. The default value is -1, which is for TBB equivalent
53 # to take over the whole machine.
54 
55 scheduler = AvalancheSchedulerSvc(ThreadPoolSize=threads, OutputLevel=INFO)
56 
57 # -------------------------------------------------------------------------------
58 
59 # Algo Resource Pool -----------------------------------------------------------
60 # Nothing special here, we just set the debug level.
61 AlgResourcePool(OutputLevel=INFO)
62 
63 # -------------------------------------------------------------------------------
64 
65 filter_alg = CPUCruncher("filter_alg")
66 filter_alg.InvertDecision = False
67 filter_alg.avgRuntime = 0.0
68 
69 filter_alg2 = CPUCruncher("filter_alg2")
70 filter_alg2.InvertDecision = True
71 filter_alg2.avgRuntime = 0.0
72 
73 view_make_alg = Test__ViewTester("view_make_alg")
74 view_make_alg.baseViewName = 'view'
75 view_make_alg.viewNumber = viewsPerEvt
76 view_make_alg.viewNodeName = 'view_test_node'
77 
78 view_test_alg = CPUCruncher("view_test_alg")
79 view_test_alg.InvertDecision = False
80 view_test_alg.avgRuntime = 1.0
81 
82 for algo in [filter_alg, filter_alg2, view_make_alg, view_test_alg]:
83  algo.Cardinality = cardinality
84  algo.OutputLevel = INFO
85 
86 view_test_node = GaudiSequencer("view_test_node",
87  Members=[view_test_alg],
88  Sequential=False,
89  OutputLevel=INFO)
90 
91 view_make_node = GaudiSequencer("view_make_node",
92  Members=[filter_alg,
93  view_make_alg, view_test_node],
94  Sequential=True,
95  OutputLevel=INFO)
96 
97 hltStep = GaudiSequencer("hltStep",
98  Members=[filter_alg, filter_alg2, view_make_node],
99  Sequential=True,
100  ShortCircuit=True,
101  ModeOR=False,
102  OutputLevel=INFO)
103 
104 # Application Manager ----------------------------------------------------------
105 # We put everything together and change the type of message service
106 
107 ApplicationMgr(EvtMax=evtMax,
108  EvtSel='NONE',
109  ExtSvc=[whiteboard],
110  EventLoop=slimeventloopmgr,
111  TopAlg=[hltStep],
112  MessageSvcType="InertMessageSvc")
113 
114 # -------------------------------------------------------------------------------
A class that implements a search for prime numbers.
Definition: CPUCruncher.h:18
Sequencer for executing several algorithms, stopping when one is faulty.
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
Data service base class.
The Application Manager class.