@@ -177,115 +177,6 @@ ur_result_t urContextSetExtendedDeleter(
177
177
} // namespace ur::level_zero
178
178
179
179
ur_result_t ur_context_handle_t_::initialize () {
180
-
181
- // Helper lambda to create various USM allocators for a device.
182
- // Note that the CCS devices and their respective subdevices share a
183
- // common ze_device_handle and therefore, also share USM allocators.
184
- auto createUSMAllocators = [this ](ur_device_handle_t Device) {
185
- auto MemProvider = umf::memoryProviderMakeUnique<L0DeviceMemoryProvider>(
186
- reinterpret_cast <ur_context_handle_t >(this ), Device)
187
- .second ;
188
- auto UmfDeviceParamsHandle = getUmfParamsHandle (
189
- DisjointPoolConfigInstance.Configs [usm::DisjointPoolMemType::Device]);
190
- DeviceMemPools.emplace (
191
- std::piecewise_construct, std::make_tuple (Device->ZeDevice ),
192
- std::make_tuple (umf::poolMakeUniqueFromOps (umfDisjointPoolOps (),
193
- std::move (MemProvider),
194
- UmfDeviceParamsHandle.get ())
195
- .second ));
196
-
197
- MemProvider = umf::memoryProviderMakeUnique<L0SharedMemoryProvider>(
198
- reinterpret_cast <ur_context_handle_t >(this ), Device)
199
- .second ;
200
-
201
- auto UmfSharedParamsHandle = getUmfParamsHandle (
202
- DisjointPoolConfigInstance.Configs [usm::DisjointPoolMemType::Shared]);
203
- SharedMemPools.emplace (
204
- std::piecewise_construct, std::make_tuple (Device->ZeDevice ),
205
- std::make_tuple (umf::poolMakeUniqueFromOps (umfDisjointPoolOps (),
206
- std::move (MemProvider),
207
- UmfSharedParamsHandle.get ())
208
- .second ));
209
-
210
- MemProvider = umf::memoryProviderMakeUnique<L0SharedReadOnlyMemoryProvider>(
211
- reinterpret_cast <ur_context_handle_t >(this ), Device)
212
- .second ;
213
-
214
- auto UmfSharedROParamsHandle = getUmfParamsHandle (
215
- DisjointPoolConfigInstance
216
- .Configs [usm::DisjointPoolMemType::SharedReadOnly]);
217
- SharedReadOnlyMemPools.emplace (
218
- std::piecewise_construct, std::make_tuple (Device->ZeDevice ),
219
- std::make_tuple (umf::poolMakeUniqueFromOps (
220
- umfDisjointPoolOps (), std::move (MemProvider),
221
- UmfSharedROParamsHandle.get ())
222
- .second ));
223
-
224
- MemProvider = umf::memoryProviderMakeUnique<L0DeviceMemoryProvider>(
225
- reinterpret_cast <ur_context_handle_t >(this ), Device)
226
- .second ;
227
- DeviceMemProxyPools.emplace (
228
- std::piecewise_construct, std::make_tuple (Device->ZeDevice ),
229
- std::make_tuple (
230
- umf::poolMakeUnique<USMProxyPool>(std::move (MemProvider)).second ));
231
-
232
- MemProvider = umf::memoryProviderMakeUnique<L0SharedMemoryProvider>(
233
- reinterpret_cast <ur_context_handle_t >(this ), Device)
234
- .second ;
235
- SharedMemProxyPools.emplace (
236
- std::piecewise_construct, std::make_tuple (Device->ZeDevice ),
237
- std::make_tuple (
238
- umf::poolMakeUnique<USMProxyPool>(std::move (MemProvider)).second ));
239
-
240
- MemProvider = umf::memoryProviderMakeUnique<L0SharedReadOnlyMemoryProvider>(
241
- reinterpret_cast <ur_context_handle_t >(this ), Device)
242
- .second ;
243
- SharedReadOnlyMemProxyPools.emplace (
244
- std::piecewise_construct, std::make_tuple (Device->ZeDevice ),
245
- std::make_tuple (
246
- umf::poolMakeUnique<USMProxyPool>(std::move (MemProvider)).second ));
247
- };
248
-
249
- // Recursive helper to call createUSMAllocators for all sub-devices
250
- std::function<void (ur_device_handle_t )> createUSMAllocatorsRecursive;
251
- createUSMAllocatorsRecursive =
252
- [createUSMAllocators,
253
- &createUSMAllocatorsRecursive](ur_device_handle_t Device) -> void {
254
- createUSMAllocators (Device);
255
- for (auto &SubDevice : Device->SubDevices )
256
- createUSMAllocatorsRecursive (SubDevice);
257
- };
258
-
259
- // Create USM pool for each pair (device, context).
260
- //
261
- for (auto &Device : Devices) {
262
- createUSMAllocatorsRecursive (Device);
263
- }
264
- // Create USM pool for host. Device and Shared USM allocations
265
- // are device-specific. Host allocations are not device-dependent therefore
266
- // we don't need a map with device as key.
267
- auto MemProvider = umf::memoryProviderMakeUnique<L0HostMemoryProvider>(
268
- reinterpret_cast <ur_context_handle_t >(this ), nullptr )
269
- .second ;
270
- auto UmfHostParamsHandle = getUmfParamsHandle (
271
- DisjointPoolConfigInstance.Configs [usm::DisjointPoolMemType::Host]);
272
- HostMemPool =
273
- umf::poolMakeUniqueFromOps (umfDisjointPoolOps (), std::move (MemProvider),
274
- UmfHostParamsHandle.get ())
275
- .second ;
276
-
277
- MemProvider = umf::memoryProviderMakeUnique<L0HostMemoryProvider>(
278
- reinterpret_cast <ur_context_handle_t >(this ), nullptr )
279
- .second ;
280
- HostMemProxyPool =
281
- umf::poolMakeUnique<USMProxyPool>(std::move (MemProvider)).second ;
282
-
283
- // We may allocate memory to this root device so create allocators.
284
- if (SingleRootDevice &&
285
- DeviceMemPools.find (SingleRootDevice->ZeDevice ) == DeviceMemPools.end ()) {
286
- createUSMAllocators (SingleRootDevice);
287
- }
288
-
289
180
// Create the immediate command list to be used for initializations.
290
181
// Created as synchronous so level-zero performs implicit synchronization and
291
182
// there is no need to query for completion in the plugin
@@ -296,7 +187,7 @@ ur_result_t ur_context_handle_t_::initialize() {
296
187
// D2D migartion, if no P2P, is broken since it should use
297
188
// immediate command-list for the specfic devices, and this single one.
298
189
//
299
- ur_device_handle_t Device = SingleRootDevice ? SingleRootDevice : Devices[0 ];
190
+ ur_device_handle_t Device = Devices[0 ];
300
191
301
192
// Prefer to use copy engine for initialization copies,
302
193
// if available and allowed (main copy engine with index 0).
0 commit comments