@@ -274,12 +274,17 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
274274 unifiedMemoryProperties.allocationFlags .flags .resource48Bit = productHelper.is48bResourceNeededForRayTracing ();
275275 }
276276
277- if (false == lookupTable.exportMemory &&
278- neoDevice->getUsmMemAllocPoolsManager ()) {
279- neoDevice->getUsmMemAllocPoolsManager ()->ensureInitialized (this ->driverHandle ->svmAllocsManager );
280- if (auto usmPtrFromPool = neoDevice->getUsmMemAllocPoolsManager ()->createUnifiedMemoryAllocation (size, unifiedMemoryProperties)) {
281- *ptr = usmPtrFromPool;
282- return ZE_RESULT_SUCCESS;
277+ if (false == lookupTable.exportMemory ) {
278+ if (neoDevice->getUsmMemAllocPoolsManager ()) {
279+ if (auto usmPtrFromPool = neoDevice->getUsmMemAllocPoolsManager ()->createUnifiedMemoryAllocation (size, unifiedMemoryProperties)) {
280+ *ptr = usmPtrFromPool;
281+ return ZE_RESULT_SUCCESS;
282+ }
283+ } else if (neoDevice->getUsmMemAllocPool ()) {
284+ if (auto usmPtrFromPool = neoDevice->getUsmMemAllocPool ()->createUnifiedMemoryAllocation (size, unifiedMemoryProperties)) {
285+ *ptr = usmPtrFromPool;
286+ return ZE_RESULT_SUCCESS;
287+ }
283288 }
284289 }
285290
@@ -464,6 +469,10 @@ ze_result_t ContextImp::freeMem(const void *ptr, bool blocking) {
464469 blocking)) {
465470 return ZE_RESULT_SUCCESS;
466471 }
472+ } else if (auto deviceUsmPool = allocation->device ->getUsmMemAllocPool ()) {
473+ if (deviceUsmPool->freeSVMAlloc (ptr, blocking)) {
474+ return ZE_RESULT_SUCCESS;
475+ }
467476 }
468477 }
469478 this ->driverHandle ->svmAllocsManager ->freeSVMAlloc (const_cast <void *>(ptr), blocking);
@@ -487,6 +496,18 @@ ze_result_t ContextImp::freeMemExt(const ze_memory_free_ext_desc_t *pMemFreeDesc
487496 this ->freePeerAllocations (ptr, false , Device::fromHandle (pairDevice.second ));
488497 }
489498
499+ if (InternalMemoryType::hostUnifiedMemory == allocation->memoryType ) {
500+ if (this ->driverHandle ->usmHostMemAllocPool .freeSVMAlloc (ptr, false )) {
501+ return ZE_RESULT_SUCCESS;
502+ }
503+ } else if (InternalMemoryType::deviceUnifiedMemory == allocation->memoryType ) {
504+ if (auto deviceUsmPool = allocation->device ->getUsmMemAllocPool ()) {
505+ if (deviceUsmPool->freeSVMAlloc (ptr, false )) {
506+ return ZE_RESULT_SUCCESS;
507+ }
508+ }
509+ }
510+
490511 this ->driverHandle ->svmAllocsManager ->freeSVMAllocDefer (const_cast <void *>(ptr));
491512 return ZE_RESULT_SUCCESS;
492513 }
@@ -641,6 +662,11 @@ void ContextImp::setIPCHandleData(NEO::GraphicsAllocation *graphicsAllocation, u
641662 ipcData.poolOffset = poolOffset;
642663 break ;
643664 }
665+ } else if (auto deviceUsmMemAllocPool = neoDevice->getUsmMemAllocPool ()) {
666+ if (auto poolOffset = deviceUsmMemAllocPool->getOffsetInPool (addrToPtr (ptrAddress))) {
667+ ipcData.poolOffset = poolOffset;
668+ break ;
669+ }
644670 }
645671 }
646672 }
0 commit comments