ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthDevice
AthDeviceComps
python
AthDeviceCompsConfig.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
AthDeviceComps.DeviceConfigFlags
import
DeviceBackend
9
10
11
def
HostCopyToolCfg
(flags, **kwargs):
12
'''Default "host side" copy object provider tool
13
'''
14
15
# Create an accumulator to hold the configuration.
16
result = ComponentAccumulator()
17
18
# Create the tool in a simple way.
19
result.setPrivateTools(CompFactory.AthDevice.HostCopyTool(**kwargs))
20
21
# Return the CA.
22
return
result
23
24
25
def
HostMemoryResourceToolCfg
(flags, **kwargs):
26
'''Default "host side" memory resource provider tool
27
'''
28
29
# Create an accumulator to hold the configuration.
30
result = ComponentAccumulator()
31
32
# Make a decision based on the selected backend.
33
if
flags.Device.Backend == DeviceBackend.CUDA:
34
from
AthCUDAServices.AthCUDAServicesConfig \
35
import
HostMemoryResourceToolCfg
as
CUDAHostMemoryResourceToolCfg
36
result.setPrivateTools(result.popToolsAndMerge(
37
CUDAHostMemoryResourceToolCfg(flags, **kwargs)))
38
elif
flags.Device.Backend == DeviceBackend.HIPAMD
or
\
39
flags.Device.Backend == DeviceBackend.HIPNVIDIA:
40
from
AthHIPComps.AthHIPCompsConfig \
41
import
HostMemoryResourceToolCfg
as
HIPHostMemoryResourceToolCfg
42
result.setPrivateTools(result.popToolsAndMerge(
43
HIPHostMemoryResourceToolCfg(flags, **kwargs)))
44
else
:
45
# For an unknown backend, we just fall back on the generic host memory
46
# resource tool.
47
result.setPrivateTools(
48
CompFactory.AthDevice.HostMemoryResourceTool(**kwargs))
49
pass
50
51
# Return the CA.
52
return
result
53
54
55
def
DeviceMemoryResourceToolCfg
(flags, **kwargs):
56
'''Default "device side" memory resource provider tool
57
'''
58
59
# Create an accumulator to hold the configuration.
60
result = ComponentAccumulator()
61
62
# Make a decision based on the selected backend.
63
if
flags.Device.Backend == DeviceBackend.CUDA:
64
from
AthCUDAServices.AthCUDAServicesConfig \
65
import
DeviceMemoryResourceToolCfg
as
\
66
CUDADeviceMemoryResourceToolCfg
67
result.setPrivateTools(result.popToolsAndMerge(
68
CUDADeviceMemoryResourceToolCfg(flags, **kwargs)))
69
elif
flags.Device.Backend == DeviceBackend.HIPAMD
or
\
70
flags.Device.Backend == DeviceBackend.HIPNVIDIA:
71
from
AthHIPComps.AthHIPCompsConfig \
72
import
DeviceMemoryResourceToolCfg
as
HIPDeviceMemoryResourceToolCfg
73
result.setPrivateTools(result.popToolsAndMerge(
74
HIPDeviceMemoryResourceToolCfg(flags, **kwargs)))
75
else
:
76
raise
RuntimeError(
'No device memory resource tool is available for '
77
'the selected backend: {}'
.format(
78
flags.Device.Backend))
79
80
# Return the CA.
81
return
result
82
83
84
def
SharedMemoryResourceToolCfg
(flags, **kwargs):
85
'''Default "host/device shared" memory resource provider tool
86
'''
87
88
# Create an accumulator to hold the configuration.
89
result = ComponentAccumulator()
90
91
# Make a decision based on the selected backend.
92
if
flags.Device.Backend == DeviceBackend.CUDA:
93
from
AthCUDAServices.AthCUDAServicesConfig \
94
import
ManagedMemoryResourceToolCfg
as
\
95
CUDAManagedMemoryResourceToolCfg
96
result.setPrivateTools(result.popToolsAndMerge(
97
CUDAManagedMemoryResourceToolCfg(flags, **kwargs)))
98
elif
flags.Device.Backend == DeviceBackend.HIPAMD
or
\
99
flags.Device.Backend == DeviceBackend.HIPNVIDIA:
100
from
AthHIPComps.AthHIPCompsConfig \
101
import
ManagedMemoryResourceToolCfg
as
\
102
HIPManagedMemoryResourceToolCfg
103
result.setPrivateTools(result.popToolsAndMerge(
104
HIPManagedMemoryResourceToolCfg(flags, **kwargs)))
105
else
:
106
raise
RuntimeError(
'No shared memory resource tool is available for '
107
'the selected backend: {}'
.format(
108
flags.Device.Backend))
109
110
# Return the CA.
111
return
result
112
113
114
def
MemoryResourcesToolCfg
(flags, **kwargs):
115
'''Default tool providing the IMemoryResourcesTool interface for the
116
selected backend
117
'''
118
119
# Create an accumulator to hold the configuration.
120
result = ComponentAccumulator()
121
122
# Make a decision based on the selected backend.
123
if
flags.Device.Backend == DeviceBackend.CUDA:
124
from
AthCUDAServices.AthCUDAServicesConfig \
125
import
MemoryResourcesToolCfg
as
CUDAMemoryResourcesToolCfg
126
result.setPrivateTools(result.popToolsAndMerge(
127
CUDAMemoryResourcesToolCfg(flags, **kwargs)))
128
elif
flags.Device.Backend == DeviceBackend.HIPAMD
or
\
129
flags.Device.Backend == DeviceBackend.HIPNVIDIA:
130
from
AthHIPComps.AthHIPCompsConfig \
131
import
MemoryResourcesToolCfg
as
HIPMemoryResourcesToolCfg
132
result.setPrivateTools(result.popToolsAndMerge(
133
HIPMemoryResourcesToolCfg(flags, **kwargs)))
134
else
:
135
raise
RuntimeError(
'No memory resources tool is available for the '
136
'selected backend: {}'
.format(flags.Device.Backend))
137
138
# Return the CA.
139
return
result
140
141
142
def
CopyToolCfg
(flags, **kwargs):
143
'''Default tool providing the ICopyTool interface for the selected backend
144
'''
145
146
# Create an accumulator to hold the configuration.
147
result = ComponentAccumulator()
148
149
# Make a decision based on the selected backend.
150
if
flags.Device.Backend == DeviceBackend.CUDA:
151
from
AthCUDAServices.AthCUDAServicesConfig \
152
import
CopyToolCfg
as
CUDACopyToolCfg
153
result.setPrivateTools(result.popToolsAndMerge(
154
CUDACopyToolCfg(flags, **kwargs)))
155
elif
flags.Device.Backend == DeviceBackend.HIPAMD
or
\
156
flags.Device.Backend == DeviceBackend.HIPNVIDIA:
157
from
AthHIPComps.AthHIPCompsConfig \
158
import
CopyToolCfg
as
HIPCopyToolCfg
159
result.setPrivateTools(result.popToolsAndMerge(
160
HIPCopyToolCfg(flags, **kwargs)))
161
else
:
162
raise
RuntimeError(
'No copy tool is available for the selected '
163
'backend: {}'
.format(flags.Device.Backend))
164
165
# Return the CA.
166
return
result
167
168
169
def
CopiesToolCfg
(flags, **kwargs):
170
'''Default tool providing the ICopiesTool interface for the selected backend
171
'''
172
173
# Create an accumulator to hold the configuration.
174
result = ComponentAccumulator()
175
176
# Make a decision based on the selected backend.
177
if
flags.Device.Backend == DeviceBackend.CUDA:
178
from
AthCUDAServices.AthCUDAServicesConfig \
179
import
CopiesToolCfg
as
CUDACopiesToolCfg
180
result.setPrivateTools(result.popToolsAndMerge(
181
CUDACopiesToolCfg(flags, **kwargs)))
182
elif
flags.Device.Backend == DeviceBackend.HIPAMD
or
\
183
flags.Device.Backend == DeviceBackend.HIPNVIDIA:
184
from
AthHIPComps.AthHIPCompsConfig \
185
import
CopiesToolCfg
as
HIPCopiesToolCfg
186
result.setPrivateTools(result.popToolsAndMerge(
187
HIPCopiesToolCfg(flags, **kwargs)))
188
else
:
189
raise
RuntimeError(
'No copies tool is available for the selected '
190
'backend: {}'
.format(flags.Device.Backend))
191
192
# Return the CA.
193
return
result
python.AthDeviceCompsConfig.MemoryResourcesToolCfg
MemoryResourcesToolCfg(flags, **kwargs)
Definition
AthDeviceCompsConfig.py:114
python.AthDeviceCompsConfig.CopyToolCfg
CopyToolCfg(flags, **kwargs)
Definition
AthDeviceCompsConfig.py:142
python.AthDeviceCompsConfig.CopiesToolCfg
CopiesToolCfg(flags, **kwargs)
Definition
AthDeviceCompsConfig.py:169
python.AthDeviceCompsConfig.HostCopyToolCfg
HostCopyToolCfg(flags, **kwargs)
Definition
AthDeviceCompsConfig.py:11
python.AthDeviceCompsConfig.HostMemoryResourceToolCfg
HostMemoryResourceToolCfg(flags, **kwargs)
Definition
AthDeviceCompsConfig.py:25
python.AthDeviceCompsConfig.DeviceMemoryResourceToolCfg
DeviceMemoryResourceToolCfg(flags, **kwargs)
Definition
AthDeviceCompsConfig.py:55
python.AthDeviceCompsConfig.SharedMemoryResourceToolCfg
SharedMemoryResourceToolCfg(flags, **kwargs)
Definition
AthDeviceCompsConfig.py:84
Generated on
for ATLAS Offline Software by
1.17.0