117def ManagedMemoryResourceToolCfg(flags, **kwargs):
118 '''Default HIP managed memory resource tool to use
119
120 It makes sure that appropriate caching would be used, as allocating managed
121 memory is relatively slow.
122 '''
123
124
125 result = ComponentAccumulator()
126
127
128
129 tool = CompFactory.AthHIP.ManagedMemoryResourceTool(**kwargs)
130 if flags.Device.Memory.Monitor:
131 monitorTool = CompFactory.AthDevice.MonitoredMemoryResourceTool(
132 'HIPManagedMemoryResourceMonitorTool',
133 MRTool=tool)
134 tool = monitorTool
135 pass
136 if flags.Device.Memory.Debug:
137 debugTool = CompFactory.AthDevice.DebugMemoryResourceTool(
138 'HIPManagedMemoryResourceDebugTool',
139 MRTool=tool)
140 tool = debugTool
141 pass
142 if flags.Device.Memory.Cache:
143 cacheSvc = CompFactory.AthDevice.BinaryPageMemoryResourceSvc(
144 'HIPManagedCachedMemoryResourceSvc',
145 MRTool=tool)
146 result.addService(cacheSvc)
147 cacheTool = CompFactory.AthDevice.MemoryResourceSvcAdaptorTool(
148 'HIPManagedCachedMemoryResourceTool',
149 MRSvc=cacheSvc)
150 tool = cacheTool
151 if flags.Device.Memory.Debug:
152 debugTool = CompFactory.AthDevice.DebugMemoryResourceTool(
153 'HIPManagedCachedMemoryResourceDebugTool',
154 MRTool=tool)
155 tool = debugTool
156 pass
157 pass
158 if flags.Device.Memory.Monitor and flags.Device.Memory.Cache:
159 monitorTool = CompFactory.AthDevice.MonitoredMemoryResourceTool(
160 'HIPManagedCachedMemoryResourceMonitorTool',
161 MRTool=tool)
162 tool = monitorTool
163 pass
164 result.setPrivateTools(tool)
165
166
167 return result
168
169