66 */
77
88#include " shared/source/execution_environment/execution_environment.h"
9+ #include " shared/test/unit_test/mocks/ult_device_factory.h"
910
1011#include " opencl/source/memory_manager/os_agnostic_memory_manager.h"
1112#include " opencl/source/program/kernel_arg_info.h"
1213#include " opencl/source/program/kernel_info.h"
1314#include " opencl/test/unit_test/fixtures/multi_root_device_fixture.h"
1415#include " opencl/test/unit_test/mocks/mock_execution_environment.h"
16+ #include " opencl/test/unit_test/mocks/mock_graphics_allocation.h"
1517
1618#include " gtest/gtest.h"
1719
@@ -106,8 +108,8 @@ TEST(KernelInfo, decodeImageKernelArgument) {
106108
107109TEST (KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationThenCopyWholeKernelHeapToKernelAllocation) {
108110 KernelInfo kernelInfo;
109- MockExecutionEnvironment executionEnvironment (defaultHwInfo. get ()) ;
110- OsAgnosticMemoryManager memoryManager (executionEnvironment) ;
111+ auto factory = UltDeviceFactory{ 1 , 0 } ;
112+ auto device = factory. rootDevices [ 0 ] ;
111113 const size_t heapSize = 0x40 ;
112114 char heap[heapSize];
113115 kernelInfo.heapInfo .KernelHeapSize = heapSize;
@@ -117,12 +119,12 @@ TEST(KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationThenCopyWholeKerne
117119 heap[i] = static_cast <char >(i);
118120 }
119121
120- auto retVal = kernelInfo.createKernelAllocation (0 , &memoryManager );
122+ auto retVal = kernelInfo.createKernelAllocation (*device );
121123 EXPECT_TRUE (retVal);
122124 auto allocation = kernelInfo.kernelAllocation ;
123125 EXPECT_EQ (0 , memcmp (allocation->getUnderlyingBuffer (), heap, heapSize));
124126 EXPECT_EQ (heapSize, allocation->getUnderlyingBufferSize ());
125- memoryManager. checkGpuUsageAndDestroyGraphicsAllocations (allocation);
127+ device-> getMemoryManager ()-> checkGpuUsageAndDestroyGraphicsAllocations (allocation);
126128}
127129
128130class MyMemoryManager : public OsAgnosticMemoryManager {
@@ -133,9 +135,10 @@ class MyMemoryManager : public OsAgnosticMemoryManager {
133135
134136TEST (KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationAndCannotAllocateMemoryThenReturnsFalse) {
135137 KernelInfo kernelInfo;
136- MockExecutionEnvironment executionEnvironment (defaultHwInfo.get ());
137- MyMemoryManager memoryManager (executionEnvironment);
138- auto retVal = kernelInfo.createKernelAllocation (0 , &memoryManager);
138+ auto executionEnvironment = new MockExecutionEnvironment (defaultHwInfo.get ());
139+ executionEnvironment->memoryManager .reset (new MyMemoryManager (*executionEnvironment));
140+ auto device = std::unique_ptr<Device>(Device::create<RootDevice>(executionEnvironment, mockRootDeviceIndex));
141+ auto retVal = kernelInfo.createKernelAllocation (*device);
139142 EXPECT_FALSE (retVal);
140143}
141144
@@ -234,7 +237,7 @@ TEST_F(KernelInfoMultiRootDeviceTests, kernelAllocationHasCorrectRootDeviceIndex
234237 kernelInfo.heapInfo .KernelHeapSize = heapSize;
235238 kernelInfo.heapInfo .pKernelHeap = &heap;
236239
237- auto retVal = kernelInfo.createKernelAllocation (expectedRootDeviceIndex, mockMemoryManager );
240+ auto retVal = kernelInfo.createKernelAllocation (device-> getDevice () );
238241 EXPECT_TRUE (retVal);
239242 auto allocation = kernelInfo.kernelAllocation ;
240243 ASSERT_NE (nullptr , allocation);
0 commit comments