The Gaudi Framework
master (9f3f8895)
Toggle main menu visibility
Loading...
Searching...
No Matches
GPUAvalancheSchedulerSimpleTest.py
Go to the documentation of this file.
1
#!/usr/bin/env gaudirun.py
2
12
"""
13
Reference optionfile which shows in a simple way how to take advantage of the
14
Gaudi components desicated to concurrency.
15
The components are:
16
o HiveWhiteBoard: a convenient way to collect several TES (one per "processing
17
slot"), accessible in a thread safe way, keeps a catalogue of the products
18
written on each processing slot. The number of slots in the whiteboard
19
determines also the number of events processed simultaneously by the scheduler.
20
o AvalancheSchedulerSvc: state machine of the algorithms interfaced with the
21
TBB runtime. It is responsible for the submission of the algorithms. An
22
algorithm is marked ready for submission when its needed input is available.
23
It deals the asynchronous termination of algorithms with a "receiver" thread
24
and a thread safe queue.
25
o HiveSlimEventLoopMgr: an event factory. Pushes new events and pops finished
26
events to/from the scheduler. It does not manage algorithms/streams.
27
o AlgResourcePool: Service managing the creation of algorithms (through the
28
algorithm manager), including clones. It also manages the algorithms according
29
to the resources they need.
30
o InertMessageSvc: as the TBBMsgSvc, it manages the printing of the messages in
31
a multithreaded environment.
32
33
The CPUCruncher is not a component dealing with concurrency, but a useful
34
entity to test it. It's an algorithm that simply wastes cpu.
35
36
"""
37
38
from
Configurables
import
(
39
AlgResourcePool,
40
AvalancheSchedulerSvc,
41
ContextEventCounterData,
42
ContextEventCounterPtr,
43
CPUCruncher,
44
GPUCruncher,
45
CPUCrunchSvc,
46
HiveSlimEventLoopMgr,
47
HiveWhiteBoard,
48
)
49
from
Gaudi.Configuration
import
*
50
51
# metaconfig -------------------------------------------------------------------
52
# It's confortable to collect the relevant parameters at the top of the optionfile
53
evtslots = 48
54
evtMax = 50
55
cardinality = 16
56
threads = 16
57
gpuThreads = 4
58
# -------------------------------------------------------------------------------
59
60
# The configuration of the whiteboard ------------------------------------------
61
# It is useful to call it EventDataSvc to replace the usual data service with
62
# the whiteboard transparently.
63
64
whiteboard =
HiveWhiteBoard
(
"EventDataSvc"
, EventSlots=evtslots)
65
66
# -------------------------------------------------------------------------------
67
68
# Event Loop Manager -----------------------------------------------------------
69
# It's called slim since it has less functionalities overall than the good-old
70
# event loop manager. Here we just set its outputlevel to DEBUG.
71
72
slimeventloopmgr =
HiveSlimEventLoopMgr
(
73
SchedulerName=
"AvalancheSchedulerSvc"
, OutputLevel=WARNING
74
)
75
76
# -------------------------------------------------------------------------------
77
78
# AvalancheScheduler -----------------------------------------------------------
79
# We just decide how many algorithms in flight we want to have and how many
80
# threads in the pool. The default value is -1, which is for TBB equivalent
81
# to take over the whole machine.
82
83
scheduler =
AvalancheSchedulerSvc
(
84
ThreadPoolSize=threads, NumOffloadThreads=gpuThreads, OutputLevel=WARNING
85
)
86
87
# -------------------------------------------------------------------------------
88
89
# Algo Resource Pool -----------------------------------------------------------
90
# Nothing special here, we just set the debug level.
91
AlgResourcePool
(OutputLevel=WARNING)
92
93
CPUCrunchSvc
(shortCalib=
True
)
94
95
# -------------------------------------------------------------------------------
96
97
# Set up of the crunchers, daily business --------------------------------------
98
99
a1 =
CPUCruncher
(
"A1"
)
100
a1.outKeys = [
"/Event/a1"
]
101
102
a2 =
CPUCruncher
(
"A2"
)
103
a2.inpKeys = [
"/Event/a1"
]
104
a2.outKeys = [
"/Event/a2"
]
105
106
a3 =
CPUCruncher
(
"A3"
)
107
a3.inpKeys = [
"/Event/a1"
]
108
a3.outKeys = [
"/Event/a3"
]
109
110
ga1 =
GPUCruncher
(
"GA1"
)
111
ga1.inpKeys = [
"/Event/a1"
]
112
ga1.outKeys = [
"/Event/ga1"
]
113
114
ga2 =
GPUCruncher
(
"GA2"
)
115
ga2.inpKeys = [
"/Event/ga1"
]
116
ga2.outKeys = [
"/Event/ga2"
]
117
118
a4 =
CPUCruncher
(
"A4"
)
119
a4.inpKeys = [
"/Event/a2"
,
"/Event/a3"
,
"/Event/ga2"
]
120
# a4.inpKeys = ["/Event/a2", "/Event/a3",]
121
a4.outKeys = [
"/Event/a4"
]
122
123
for
algo
in
[a1, a2, a3, a4, ga1, ga2]:
124
algo.Cardinality = cardinality
125
algo.OutputLevel = INFO
126
algo.varRuntime = 0.001
127
algo.avgRuntime = 0.001
128
129
for
algo
in
[ga1, ga2]:
130
algo.avgRuntime = 10.0
131
algo.varRuntime = 1.00
132
algo.Cardinality = 0
133
134
ctrp =
ContextEventCounterPtr
(
"CNT*"
, Cardinality=1, OutputLevel=INFO)
135
ctrd =
ContextEventCounterData
(
"CNT&"
, Cardinality=1, OutputLevel=INFO)
136
137
# Application Manager ----------------------------------------------------------
138
# We put everything together and change the type of message service
139
140
ApplicationMgr
(
141
EvtMax=evtMax,
142
EvtSel=
"NONE"
,
143
ExtSvc=[whiteboard],
144
EventLoop=slimeventloopmgr,
145
TopAlg=[a1, a2, a3, a4, ga1, ga2, ctrp, ctrd],
146
# TopAlg=[a1, a2, a3, a4, ctrp, ctrd],
147
MessageSvcType=
"InertMessageSvc"
,
148
)
149
150
# -------------------------------------------------------------------------------
AlgResourcePool
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
Definition
AlgResourcePool.h:35
ApplicationMgr
The Application Manager class.
Definition
ApplicationMgr.h:54
AvalancheSchedulerSvc
Definition
AvalancheSchedulerSvc.h:114
CPUCrunchSvc
Definition
CPUCrunchSvc.h:22
CPUCruncher
A class that implements a search for prime numbers.
Definition
CPUCruncher.h:30
ContextEventCounterData
Definition
ContextEventCounter.h:32
ContextEventCounterPtr
Definition
ContextEventCounter.h:23
GPUCruncher
A test asynchronous algorithm on the GPU.
Definition
GPUCruncher.h:26
HiveSlimEventLoopMgr
Definition
HiveSlimEventLoopMgr.cpp:39
HiveWhiteBoard
Data service base class.
Definition
HiveWhiteBoard.cpp:100
Gaudi.Configuration
Definition
Configuration.py:1
GaudiCUDA
options
GPUAvalancheSchedulerSimpleTest.py
Generated on
for The Gaudi Framework by
1.17.0