ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthHIP
AthHIPComps
python
AthHIPCompsConfig.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3
# Framework import(s).
4
from
AthenaConfiguration.ComponentFactory
import
CompFactory
5
from
AthenaConfiguration.ComponentAccumulator
import
ComponentAccumulator
6
7
# Local import(s).
8
from
AthHIPComps.HIPConfigFlags
import
HIPStream
9
10
11
def
HostMemoryResourceToolCfg
(flags, **kwargs):
12
'''Default HIP host memory resource tool to use
13
14
It makes sure that appropriate caching would be used, as allocating pinned
15
host memory is relatively slow.
16
'''
17
18
# Create an accumulator to hold the configuration.
19
result = ComponentAccumulator()
20
21
# Create the components that would collaborate to provide thread-safe
22
# caching to the "bare" memory resource.
23
tool = CompFactory.AthHIP.HostMemoryResourceTool(**kwargs)
24
if
flags.Device.Memory.Debug:
25
debugTool = CompFactory.AthDevice.DebugMemoryResourceTool(
26
'HIPHostMemoryResourceDebugTool'
,
27
MRTool=tool)
28
tool = debugTool
29
pass
30
if
flags.Device.Memory.Cache:
31
cacheSvc = CompFactory.AthDevice.BinaryPageMemoryResourceSvc(
32
'HIPHostCachedMemoryResourceSvc'
,
33
MRTool=tool)
34
result.addService(cacheSvc)
35
cacheTool = CompFactory.AthDevice.MemoryResourceSvcAdaptorTool(
36
'HIPHostCachedMemoryResourceTool'
,
37
MRSvc=cacheSvc)
38
tool = cacheTool
39
if
flags.Device.Memory.Debug:
40
debugTool = CompFactory.AthDevice.DebugMemoryResourceTool(
41
'HIPHostCachedMemoryResourceDebugTool'
,
42
MRTool=tool)
43
tool = debugTool
44
pass
45
pass
46
result.setPrivateTools(tool)
47
48
# Return the CA.
49
return
result
50
51
52
def
DeviceMemoryResourceToolCfg
(flags, **kwargs):
53
'''Default HIP device memory resource tool to use
54
55
It makes sure that appropriate caching would be used, as allocating device
56
memory is relatively slow.
57
'''
58
59
# Create an accumulator to hold the configuration.
60
result = ComponentAccumulator()
61
62
# Create the components that would collaborate to provide thread-safe
63
# caching to the "bare" memory resource.
64
tool = CompFactory.AthHIP.DeviceMemoryResourceTool(**kwargs)
65
if
flags.Device.Memory.Debug:
66
debugTool = CompFactory.AthDevice.DebugMemoryResourceTool(
67
'HIPDeviceMemoryResourceDebugTool'
,
68
MRTool=tool)
69
tool = debugTool
70
pass
71
if
flags.Device.Memory.Cache:
72
cacheSvc = CompFactory.AthDevice.BinaryPageMemoryResourceSvc(
73
'HIPDeviceCachedMemoryResourceSvc'
,
74
MRTool=tool)
75
result.addService(cacheSvc)
76
cacheTool = CompFactory.AthDevice.MemoryResourceSvcAdaptorTool(
77
'HIPDeviceCachedMemoryResourceTool'
,
78
MRSvc=cacheSvc)
79
tool = cacheTool
80
if
flags.Device.Memory.Debug:
81
debugTool = CompFactory.AthDevice.DebugMemoryResourceTool(
82
'HIPDeviceCachedMemoryResourceDebugTool'
,
83
MRTool=tool)
84
tool = debugTool
85
pass
86
pass
87
result.setPrivateTools(tool)
88
89
# Return the CA.
90
return
result
91
92
93
def
ManagedMemoryResourceToolCfg
(flags, **kwargs):
94
'''Default HIP managed memory resource tool to use
95
96
It makes sure that appropriate caching would be used, as allocating managed
97
memory is relatively slow.
98
'''
99
100
# Create an accumulator to hold the configuration.
101
result = ComponentAccumulator()
102
103
# Create the components that would collaborate to provide thread-safe
104
# caching to the "bare" memory resource.
105
tool = CompFactory.AthHIP.ManagedMemoryResourceTool(**kwargs)
106
if
flags.Device.Memory.Debug:
107
debugTool = CompFactory.AthDevice.DebugMemoryResourceTool(
108
'HIPManagedMemoryResourceDebugTool'
,
109
MRTool=tool)
110
tool = debugTool
111
pass
112
if
flags.Device.Memory.Cache:
113
cacheSvc = CompFactory.AthDevice.BinaryPageMemoryResourceSvc(
114
'HIPManagedCachedMemoryResourceSvc'
,
115
MRTool=tool)
116
result.addService(cacheSvc)
117
cacheTool = CompFactory.AthDevice.MemoryResourceSvcAdaptorTool(
118
'HIPManagedCachedMemoryResourceTool'
,
119
MRSvc=cacheSvc)
120
tool = cacheTool
121
if
flags.Device.Memory.Debug:
122
debugTool = CompFactory.AthDevice.DebugMemoryResourceTool(
123
'HIPManagedCachedMemoryResourceDebugTool'
,
124
MRTool=tool)
125
tool = debugTool
126
pass
127
pass
128
result.setPrivateTools(tool)
129
130
# Return the CA.
131
return
result
132
133
134
def
MemoryResourcesToolCfg
(flags, **kwargs):
135
'''Default tool providing the IMemoryResourcesTool interface for HIP
136
'''
137
138
# Create an accumulator to hold the configuration.
139
result = ComponentAccumulator()
140
141
# Create the main tool that would provide the
142
# AthDevice::IMemoryResourcesTool interface.
143
tool = CompFactory.AthDevice.MemoryResourcesAdaptorTool(**kwargs)
144
145
# Set up the main tool according to the received flags.
146
if
flags.Device.Memory.Shared:
147
tool.MainMRTool = result.getPrimaryAndMerge(
148
ManagedMemoryResourceToolCfg
(flags))
149
else
:
150
tool.MainMRTool = result.getPrimaryAndMerge(
151
DeviceMemoryResourceToolCfg
(flags))
152
tool.HostMRTool = result.getPrimaryAndMerge(
153
HostMemoryResourceToolCfg
(flags))
154
pass
155
156
# Return the adaptor tool as the main component of the CA.
157
result.setPrivateTools(tool)
158
return
result
159
160
161
def
SingleStreamToolCfg
(flags, **kwargs):
162
'''Tool providing a single HIP stream for all components in the entire job
163
'''
164
165
# Create an accumulator to hold the configuration.
166
result = ComponentAccumulator()
167
168
# Create the stream service and add it to the accumulator.
169
streamSvc = CompFactory.AthHIP.SingleStreamSvc(**kwargs)
170
result.addService(streamSvc)
171
172
# Create an adaptor tool on top of the service, and set that as the main
173
# component of the CA.
174
streamTool = CompFactory.AthHIP.StreamSvcAdaptorTool(
175
'HIPSingleStreamTool'
, StreamSvc=streamSvc)
176
result.setPrivateTools(streamTool)
177
178
# Return the CA.
179
return
result
180
181
182
def
PerEventStreamToolCfg
(flags, **kwargs):
183
'''Tool providing one HIP stream per event/slot
184
'''
185
186
# Create an accumulator to hold the configuration.
187
result = ComponentAccumulator()
188
189
# Create the stream service and add it to the accumulator.
190
streamSvc = CompFactory.AthHIP.PerEventStreamSvc(**kwargs)
191
result.addService(streamSvc)
192
193
# Create an adaptor tool on top of the service, and set that as the main
194
# component of the CA.
195
streamTool = CompFactory.AthHIP.StreamSvcAdaptorTool(
196
'HIPPerEventStreamTool'
, StreamSvc=streamSvc)
197
result.setPrivateTools(streamTool)
198
199
# Return the CA.
200
return
result
201
202
203
def
PerComponentStreamToolCfg
(flags, **kwargs):
204
'''Tool providing one HIP stream per component (algorithm/tool/service)
205
'''
206
207
# Create an accumulator to hold the configuration.
208
result = ComponentAccumulator()
209
210
# Create an tool that implements this behaviour.
211
streamTool = CompFactory.AthHIP.PerComponentStreamTool(**kwargs)
212
result.setPrivateTools(streamTool)
213
214
# Return the CA.
215
return
result
216
217
218
def
PerEventAndComponentStreamToolCfg
(flags, **kwargs):
219
'''Tool providing one HIP stream per component and event/slot
220
'''
221
222
# Create an accumulator to hold the configuration.
223
result = ComponentAccumulator()
224
225
# Create an tool that implements this behaviour.
226
streamTool = CompFactory.AthHIP.PerEventAndComponentStreamTool(**kwargs)
227
result.setPrivateTools(streamTool)
228
229
# Return the CA.
230
return
result
231
232
233
def
StreamToolCfg
(flags, **kwargs):
234
'''Default HIP stream provider tool to use
235
'''
236
237
# Create the default stream tool, depending on the job's configuration.
238
if
flags.HIP.Stream == HIPStream.Single:
239
return
SingleStreamToolCfg
(flags, **kwargs)
240
elif
flags.HIP.Stream == HIPStream.PerEvent:
241
return
PerEventStreamToolCfg
(flags, **kwargs)
242
elif
flags.HIP.Stream == HIPStream.PerComponent:
243
return
PerComponentStreamToolCfg
(flags, **kwargs)
244
elif
flags.HIP.Stream == HIPStream.PerEventAndComponent:
245
return
PerEventAndComponentStreamToolCfg
(flags, **kwargs)
246
else
:
247
raise
ValueError(f
"Invalid HIP stream strategy: {flags.HIP.Stream}"
)
248
pass
249
pass
250
251
252
def
SyncCopyToolCfg
(flags, **kwargs):
253
'''Synchronous copy object provider tool
254
'''
255
256
# Create an accumulator to hold the configuration.
257
result = ComponentAccumulator()
258
259
# Create the tool in a simple way.
260
result.setPrivateTools(CompFactory.AthHIP.CopyTool(**kwargs))
261
262
# Return the CA.
263
return
result
264
265
266
def
AsyncCopyToolCfg
(flags, **kwargs):
267
'''Asynchronous copy object provider tool
268
'''
269
270
# Create an accumulator to hold the configuration.
271
result = ComponentAccumulator()
272
273
# Create the tool. Attaching a stream tool to it.
274
copyTool = CompFactory.AthHIP.AsyncCopyTool(**kwargs)
275
streamTool =
StreamToolCfg
(flags, **kwargs)
276
copyTool.StreamTool = streamTool.getPrimary()
277
result.merge(streamTool)
278
result.setPrivateTools(copyTool)
279
280
# Return the CA.
281
return
result
282
283
284
def
CopyToolCfg
(flags, **kwargs):
285
'''Default tool providing the ICopyTool interface for HIP
286
'''
287
288
# Set up the device copy tool according to the received flags.
289
if
flags.Device.Copy.Async:
290
return
AsyncCopyToolCfg
(flags, **kwargs)
291
else
:
292
return
SyncCopyToolCfg
(flags, **kwargs)
293
pass
294
295
296
def
CopiesToolCfg
(flags, **kwargs):
297
'''Default tool providing the ICopiesTool interface for HIP
298
'''
299
300
# Create an accumulator to hold the configuration.
301
result = ComponentAccumulator()
302
303
# Create the main tool that would provide the AthDevice::ICopiesTool
304
# interface.
305
tool = CompFactory.AthDevice.CopiesAdaptorTool(**kwargs)
306
307
# Set up the "host" copy tool. Which is always the same in our current code.
308
from
AthDeviceComps.AthDeviceCompsConfig
import
HostCopyToolCfg
309
tool.HostCopyTool = \
310
result.popToolsAndMerge(HostCopyToolCfg(flags, **kwargs))
311
312
# Set up the device copy tool according to the received flags.
313
if
flags.Device.Copy.Async:
314
tool.DeviceCopyTool = \
315
result.popToolsAndMerge(
AsyncCopyToolCfg
(flags, **kwargs))
316
else
:
317
tool.DeviceCopyTool = \
318
result.popToolsAndMerge(
SyncCopyToolCfg
(flags, **kwargs))
319
pass
320
321
# Return the adaptor tool as the main component of the CA.
322
result.setPrivateTools(tool)
323
324
# Return the CA.
325
return
result
AthHIPCompsConfig.PerEventAndComponentStreamToolCfg
PerEventAndComponentStreamToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:218
AthHIPCompsConfig.ManagedMemoryResourceToolCfg
ManagedMemoryResourceToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:93
AthHIPCompsConfig.MemoryResourcesToolCfg
MemoryResourcesToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:134
AthHIPCompsConfig.AsyncCopyToolCfg
AsyncCopyToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:266
AthHIPCompsConfig.CopyToolCfg
CopyToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:284
AthHIPCompsConfig.SyncCopyToolCfg
SyncCopyToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:252
AthHIPCompsConfig.CopiesToolCfg
CopiesToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:296
AthHIPCompsConfig.HostMemoryResourceToolCfg
HostMemoryResourceToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:11
AthHIPCompsConfig.PerComponentStreamToolCfg
PerComponentStreamToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:203
AthHIPCompsConfig.DeviceMemoryResourceToolCfg
DeviceMemoryResourceToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:52
AthHIPCompsConfig.StreamToolCfg
StreamToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:233
AthHIPCompsConfig.PerEventStreamToolCfg
PerEventStreamToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:182
AthHIPCompsConfig.SingleStreamToolCfg
SingleStreamToolCfg(flags, **kwargs)
Definition
AthHIPCompsConfig.py:161
Generated on
for ATLAS Offline Software by
1.17.0