124def ManagedMemoryResourceToolCfg(flags, **kwargs):
125 '''Default CUDA managed memory resource tool to use
126
127 It makes sure that appropriate caching would be used, as allocating managed
128 memory is relatively slow.
129 '''
130
131
132 result = ComponentAccumulator()
133
134
135
136 tool = CompFactory.AthCUDA.ManagedMemoryResourceTool(**kwargs)
137 if flags.Device.Memory.Monitor:
138 monitorTool = CompFactory.AthDevice.MonitoredMemoryResourceTool(
139 'CUDAManagedMemoryResourceMonitorTool',
140 MRTool=tool)
141 tool = monitorTool
142 pass
143 if flags.Device.Memory.Debug:
144 debugTool = CompFactory.AthDevice.DebugMemoryResourceTool(
145 'CUDAManagedMemoryResourceDebugTool',
146 MRTool=tool)
147 tool = debugTool
148 pass
149 if flags.Device.Memory.Cache:
150 cacheSvc = CompFactory.AthDevice.BinaryPageMemoryResourceSvc(
151 'CUDAManagedCachedMemoryResourceSvc',
152 MRTool=tool)
153 result.addService(cacheSvc)
154 cacheTool = CompFactory.AthDevice.MemoryResourceSvcAdaptorTool(
155 'CUDAManagedCachedMemoryResourceTool',
156 MRSvc=cacheSvc)
157 tool = cacheTool
158 if flags.Device.Memory.Debug:
159 debugTool = CompFactory.AthDevice.DebugMemoryResourceTool(
160 'CUDAManagedCachedMemoryResourceDebugTool',
161 MRTool=tool)
162 tool = debugTool
163 pass
164 pass
165 if flags.Device.Memory.Monitor and flags.Device.Memory.Cache:
166 monitorTool = CompFactory.AthDevice.MonitoredMemoryResourceTool(
167 'CUDAManagedCachedMemoryResourceMonitorTool',
168 MRTool=tool)
169 tool = monitorTool
170 pass
171 result.setPrivateTools(tool)
172
173
174 return result
175
176