1616#include " opencl/test/unit_test/fixtures/multi_root_device_fixture.h"
1717#include " opencl/test/unit_test/mocks/mock_context.h"
1818#include " opencl/test/unit_test/mocks/mock_kernel.h"
19+ #include " opencl/test/unit_test/mocks/mock_platform.h"
1920#include " opencl/test/unit_test/mocks/ult_cl_device_factory_with_platform.h"
2021#include " opencl/test/unit_test/test_macros/test_checks_ocl.h"
2122
@@ -702,51 +703,58 @@ TEST_F(ClUnifiedSharedMemoryTests, givenSVMAllocationPoolWhenClGetMemAllocInfoIN
702703 size_t paramValue = 0 ;
703704 size_t paramValueSizeRet = 0 ;
704705 const size_t allocationSize = 4u ;
706+ auto platform = static_cast <MockPlatform *>(device->getPlatform ());
707+ for (auto enablePoolManager : {false , true }) {
708+ debugManager.flags .EnableUsmAllocationPoolManager .set (enablePoolManager);
709+ platform->getHostMemAllocPool ().cleanup ();
710+ platform->usmPoolInitialized = false ;
711+ mockContext->getDeviceMemAllocPoolsManager ().cleanup ();
712+ mockContext->usmPoolInitialized = false ;
713+ {
714+ auto unifiedMemoryHostAllocation = clHostMemAllocINTEL (mockContext.get (), nullptr , allocationSize, 0 , &retVal);
715+ auto allocationsManager = mockContext->getSVMAllocsManager ();
716+ auto graphicsAllocation = allocationsManager->getSVMAlloc (unifiedMemoryHostAllocation);
717+
718+ retVal = clGetMemAllocInfoINTEL (mockContext.get (), unifiedMemoryHostAllocation, CL_MEM_ALLOC_SIZE_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
719+
720+ EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::hostUnifiedMemory);
721+ EXPECT_EQ (allocationSize, paramValue);
722+ EXPECT_EQ (sizeof (size_t ), paramValueSizeRet);
723+ EXPECT_EQ (CL_SUCCESS, retVal);
724+
725+ retVal = clGetMemAllocInfoINTEL (mockContext.get (), ptrOffset (unifiedMemoryHostAllocation, allocationSize - 1 ), CL_MEM_ALLOC_SIZE_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
726+
727+ EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::hostUnifiedMemory);
728+ EXPECT_EQ (allocationSize, paramValue);
729+ EXPECT_EQ (sizeof (size_t ), paramValueSizeRet);
730+ EXPECT_EQ (CL_SUCCESS, retVal);
731+
732+ retVal = clMemFreeINTEL (mockContext.get (), unifiedMemoryHostAllocation);
733+ EXPECT_EQ (CL_SUCCESS, retVal);
734+ }
705735
706- {
707- auto unifiedMemoryHostAllocation = clHostMemAllocINTEL (mockContext.get (), nullptr , allocationSize, 0 , &retVal);
708- auto allocationsManager = mockContext->getSVMAllocsManager ();
709- auto graphicsAllocation = allocationsManager->getSVMAlloc (unifiedMemoryHostAllocation);
710-
711- retVal = clGetMemAllocInfoINTEL (mockContext.get (), unifiedMemoryHostAllocation, CL_MEM_ALLOC_SIZE_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
712-
713- EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::hostUnifiedMemory);
714- EXPECT_EQ (allocationSize, paramValue);
715- EXPECT_EQ (sizeof (size_t ), paramValueSizeRet);
716- EXPECT_EQ (CL_SUCCESS, retVal);
717-
718- retVal = clGetMemAllocInfoINTEL (mockContext.get (), ptrOffset (unifiedMemoryHostAllocation, allocationSize - 1 ), CL_MEM_ALLOC_SIZE_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
719-
720- EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::hostUnifiedMemory);
721- EXPECT_EQ (allocationSize, paramValue);
722- EXPECT_EQ (sizeof (size_t ), paramValueSizeRet);
723- EXPECT_EQ (CL_SUCCESS, retVal);
724-
725- retVal = clMemFreeINTEL (mockContext.get (), unifiedMemoryHostAllocation);
726- EXPECT_EQ (CL_SUCCESS, retVal);
727- }
736+ {
737+ auto unifiedMemoryDeviceAllocation = clDeviceMemAllocINTEL (mockContext.get (), device, nullptr , 4 , 0 , &retVal);
738+ auto allocationsManager = mockContext->getSVMAllocsManager ();
739+ auto graphicsAllocation = allocationsManager->getSVMAlloc (unifiedMemoryDeviceAllocation);
728740
729- {
730- auto unifiedMemoryDeviceAllocation = clDeviceMemAllocINTEL (mockContext.get (), device, nullptr , 4 , 0 , &retVal);
731- auto allocationsManager = mockContext->getSVMAllocsManager ();
732- auto graphicsAllocation = allocationsManager->getSVMAlloc (unifiedMemoryDeviceAllocation);
741+ retVal = clGetMemAllocInfoINTEL (mockContext.get (), unifiedMemoryDeviceAllocation, CL_MEM_ALLOC_SIZE_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
733742
734- retVal = clGetMemAllocInfoINTEL (mockContext.get (), unifiedMemoryDeviceAllocation, CL_MEM_ALLOC_SIZE_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
743+ EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::deviceUnifiedMemory);
744+ EXPECT_EQ (allocationSize, paramValue);
745+ EXPECT_EQ (sizeof (size_t ), paramValueSizeRet);
746+ EXPECT_EQ (CL_SUCCESS, retVal);
735747
736- EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::deviceUnifiedMemory);
737- EXPECT_EQ (allocationSize, paramValue);
738- EXPECT_EQ (sizeof (size_t ), paramValueSizeRet);
739- EXPECT_EQ (CL_SUCCESS, retVal);
748+ retVal = clGetMemAllocInfoINTEL (mockContext.get (), ptrOffset (unifiedMemoryDeviceAllocation, allocationSize - 1 ), CL_MEM_ALLOC_SIZE_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
740749
741- retVal = clGetMemAllocInfoINTEL (mockContext.get (), ptrOffset (unifiedMemoryDeviceAllocation, allocationSize - 1 ), CL_MEM_ALLOC_SIZE_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
750+ EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::deviceUnifiedMemory);
751+ EXPECT_EQ (allocationSize, paramValue);
752+ EXPECT_EQ (sizeof (size_t ), paramValueSizeRet);
753+ EXPECT_EQ (CL_SUCCESS, retVal);
742754
743- EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::deviceUnifiedMemory);
744- EXPECT_EQ (allocationSize, paramValue);
745- EXPECT_EQ (sizeof (size_t ), paramValueSizeRet);
746- EXPECT_EQ (CL_SUCCESS, retVal);
747-
748- retVal = clMemFreeINTEL (mockContext.get (), unifiedMemoryDeviceAllocation);
749- EXPECT_EQ (CL_SUCCESS, retVal);
755+ retVal = clMemFreeINTEL (mockContext.get (), unifiedMemoryDeviceAllocation);
756+ EXPECT_EQ (CL_SUCCESS, retVal);
757+ }
750758 }
751759}
752760
@@ -762,50 +770,59 @@ TEST_F(ClUnifiedSharedMemoryTests, givenSVMAllocationPoolWhenClGetMemAllocInfoIN
762770 uint64_t paramValue = 0 ;
763771 size_t paramValueSizeRet = 0 ;
764772
765- {
766- auto unifiedMemoryHostAllocation = clHostMemAllocINTEL (mockContext.get (), nullptr , 4 , 0 , &retVal);
767- auto allocationsManager = mockContext->getSVMAllocsManager ();
768- auto graphicsAllocation = allocationsManager->getSVMAlloc (unifiedMemoryHostAllocation);
773+ auto platform = static_cast <MockPlatform *>(device->getPlatform ());
774+ for (auto enablePoolManager : {false , true }) {
775+ debugManager.flags .EnableUsmAllocationPoolManager .set (enablePoolManager);
776+ platform->getHostMemAllocPool ().cleanup ();
777+ platform->usmPoolInitialized = false ;
778+ mockContext->getDeviceMemAllocPoolsManager ().cleanup ();
779+ mockContext->usmPoolInitialized = false ;
769780
770- retVal = clGetMemAllocInfoINTEL (mockContext.get (), unifiedMemoryHostAllocation, CL_MEM_ALLOC_BASE_PTR_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
781+ {
782+ auto unifiedMemoryHostAllocation = clHostMemAllocINTEL (mockContext.get (), nullptr , 4 , 0 , &retVal);
783+ auto allocationsManager = mockContext->getSVMAllocsManager ();
784+ auto graphicsAllocation = allocationsManager->getSVMAlloc (unifiedMemoryHostAllocation);
771785
772- EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::hostUnifiedMemory);
773- EXPECT_EQ (unifiedMemoryHostAllocation, addrToPtr (paramValue));
774- EXPECT_EQ (sizeof (uint64_t ), paramValueSizeRet);
775- EXPECT_EQ (CL_SUCCESS, retVal);
786+ retVal = clGetMemAllocInfoINTEL (mockContext.get (), unifiedMemoryHostAllocation, CL_MEM_ALLOC_BASE_PTR_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
776787
777- retVal = clGetMemAllocInfoINTEL (mockContext.get (), ptrOffset (unifiedMemoryHostAllocation, 3 ), CL_MEM_ALLOC_BASE_PTR_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
788+ EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::hostUnifiedMemory);
789+ EXPECT_EQ (unifiedMemoryHostAllocation, addrToPtr (paramValue));
790+ EXPECT_EQ (sizeof (uint64_t ), paramValueSizeRet);
791+ EXPECT_EQ (CL_SUCCESS, retVal);
778792
779- EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::hostUnifiedMemory);
780- EXPECT_EQ (unifiedMemoryHostAllocation, addrToPtr (paramValue));
781- EXPECT_EQ (sizeof (uint64_t ), paramValueSizeRet);
782- EXPECT_EQ (CL_SUCCESS, retVal);
793+ retVal = clGetMemAllocInfoINTEL (mockContext.get (), ptrOffset (unifiedMemoryHostAllocation, 3 ), CL_MEM_ALLOC_BASE_PTR_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
783794
784- retVal = clMemFreeINTEL (mockContext.get (), unifiedMemoryHostAllocation);
785- EXPECT_EQ (CL_SUCCESS, retVal);
786- }
795+ EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::hostUnifiedMemory);
796+ EXPECT_EQ (unifiedMemoryHostAllocation, addrToPtr (paramValue));
797+ EXPECT_EQ (sizeof (uint64_t ), paramValueSizeRet);
798+ EXPECT_EQ (CL_SUCCESS, retVal);
787799
788- {
789- auto unifiedMemoryDeviceAllocation = clDeviceMemAllocINTEL (mockContext.get (), device, nullptr , 4 , 0 , &retVal);
790- auto allocationsManager = mockContext->getSVMAllocsManager ();
791- auto graphicsAllocation = allocationsManager->getSVMAlloc (unifiedMemoryDeviceAllocation);
800+ retVal = clMemFreeINTEL (mockContext.get (), unifiedMemoryHostAllocation);
801+ EXPECT_EQ (CL_SUCCESS, retVal);
802+ }
792803
793- retVal = clGetMemAllocInfoINTEL (mockContext.get (), unifiedMemoryDeviceAllocation, CL_MEM_ALLOC_BASE_PTR_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
804+ {
805+ auto unifiedMemoryDeviceAllocation = clDeviceMemAllocINTEL (mockContext.get (), device, nullptr , 4 , 0 , &retVal);
806+ auto allocationsManager = mockContext->getSVMAllocsManager ();
807+ auto graphicsAllocation = allocationsManager->getSVMAlloc (unifiedMemoryDeviceAllocation);
794808
795- EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::deviceUnifiedMemory);
796- EXPECT_EQ (unifiedMemoryDeviceAllocation, addrToPtr (paramValue));
797- EXPECT_EQ (sizeof (uint64_t ), paramValueSizeRet);
798- EXPECT_EQ (CL_SUCCESS, retVal);
809+ retVal = clGetMemAllocInfoINTEL (mockContext.get (), unifiedMemoryDeviceAllocation, CL_MEM_ALLOC_BASE_PTR_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
799810
800- retVal = clGetMemAllocInfoINTEL (mockContext.get (), ptrOffset (unifiedMemoryDeviceAllocation, 3 ), CL_MEM_ALLOC_BASE_PTR_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
811+ EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::deviceUnifiedMemory);
812+ EXPECT_EQ (unifiedMemoryDeviceAllocation, addrToPtr (paramValue));
813+ EXPECT_EQ (sizeof (uint64_t ), paramValueSizeRet);
814+ EXPECT_EQ (CL_SUCCESS, retVal);
801815
802- EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::deviceUnifiedMemory);
803- EXPECT_EQ (unifiedMemoryDeviceAllocation, addrToPtr (paramValue));
804- EXPECT_EQ (sizeof (uint64_t ), paramValueSizeRet);
805- EXPECT_EQ (CL_SUCCESS, retVal);
816+ retVal = clGetMemAllocInfoINTEL (mockContext.get (), ptrOffset (unifiedMemoryDeviceAllocation, 3 ), CL_MEM_ALLOC_BASE_PTR_INTEL, paramValueSize, ¶mValue, ¶mValueSizeRet);
806817
807- retVal = clMemFreeINTEL (mockContext.get (), unifiedMemoryDeviceAllocation);
808- EXPECT_EQ (CL_SUCCESS, retVal);
818+ EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::deviceUnifiedMemory);
819+ EXPECT_EQ (unifiedMemoryDeviceAllocation, addrToPtr (paramValue));
820+ EXPECT_EQ (sizeof (uint64_t ), paramValueSizeRet);
821+ EXPECT_EQ (CL_SUCCESS, retVal);
822+
823+ retVal = clMemFreeINTEL (mockContext.get (), unifiedMemoryDeviceAllocation);
824+ EXPECT_EQ (CL_SUCCESS, retVal);
825+ }
809826 }
810827}
811828
0 commit comments