diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index 42332b3fb1..55a5412ae5 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -644,7 +644,7 @@ bool AUBCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxA template bool AUBCommandStreamReceiverHw::writeMemory(AllocationView &allocationView) { - GraphicsAllocation gfxAllocation(reinterpret_cast(allocationView.first), allocationView.second); + GraphicsAllocation gfxAllocation(reinterpret_cast(allocationView.first), allocationView.first, 0llu, allocationView.second); return writeMemory(gfxAllocation); } diff --git a/runtime/memory_manager/graphics_allocation.h b/runtime/memory_manager/graphics_allocation.h index 1441028d30..199bd27b9a 100644 --- a/runtime/memory_manager/graphics_allocation.h +++ b/runtime/memory_manager/graphics_allocation.h @@ -84,10 +84,6 @@ class GraphicsAllocation : public IDNode { virtual ~GraphicsAllocation() = default; GraphicsAllocation &operator=(const GraphicsAllocation &) = delete; GraphicsAllocation(const GraphicsAllocation &) = delete; - GraphicsAllocation(void *cpuPtrIn, size_t sizeIn) : size(sizeIn), - cpuPtr(cpuPtrIn), - gpuAddress(castToUint64(cpuPtrIn)), - sharedHandle(Sharing::nonSharedResource) {} GraphicsAllocation(void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn) : size(sizeIn), cpuPtr(cpuPtrIn), diff --git a/runtime/os_interface/linux/drm_allocation.h b/runtime/os_interface/linux/drm_allocation.h index bb5130c652..65ff12a9b0 100644 --- a/runtime/os_interface/linux/drm_allocation.h +++ b/runtime/os_interface/linux/drm_allocation.h @@ -17,7 +17,7 @@ struct OsHandle { class DrmAllocation : public GraphicsAllocation { public: - DrmAllocation(BufferObject *bo, void *ptrIn, size_t sizeIn, MemoryPool::Type pool) : GraphicsAllocation(ptrIn, sizeIn), bo(bo) { + DrmAllocation(BufferObject *bo, void *ptrIn, size_t sizeIn, MemoryPool::Type pool) : GraphicsAllocation(ptrIn, castToUint64(ptrIn), 0llu, sizeIn), bo(bo) { this->memoryPool = pool; } DrmAllocation(BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool) : GraphicsAllocation(ptrIn, sizeIn, sharedHandle), bo(bo) { diff --git a/runtime/os_interface/windows/wddm_allocation.h b/runtime/os_interface/windows/wddm_allocation.h index 605549bc05..ef5a92adb0 100644 --- a/runtime/os_interface/windows/wddm_allocation.h +++ b/runtime/os_interface/windows/wddm_allocation.h @@ -32,7 +32,7 @@ class WddmAllocation : public GraphicsAllocation { D3DGPU_VIRTUAL_ADDRESS gpuPtr; // set by mapGpuVA WddmAllocation(void *cpuPtrIn, size_t sizeIn, void *alignedCpuPtr, void *reservedAddr, MemoryPool::Type pool, size_t osContextsCount) - : GraphicsAllocation(cpuPtrIn, sizeIn), + : GraphicsAllocation(cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn), handle(0), gpuPtr(0), alignedCpuPtr(alignedCpuPtr), diff --git a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp index 189d3b86ff..2b0012e8ed 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp @@ -21,6 +21,7 @@ #include "unit_tests/mocks/mock_aub_subcapture_manager.h" #include "unit_tests/mocks/mock_csr.h" #include "unit_tests/mocks/mock_gmm.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" #include "unit_tests/mocks/mock_kernel.h" #include "unit_tests/mocks/mock_mdi.h" @@ -728,7 +729,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationSizeIsZeroThenWriteMemoryIsNotAllowed) { std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], "", true, *pDevice->executionEnvironment)); - GraphicsAllocation gfxAllocation((void *)0x1234, 0); + MockGraphicsAllocation gfxAllocation((void *)0x1234, 0); EXPECT_FALSE(aubCsr->writeMemory(gfxAllocation)); } diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp index c6d5db1478..29d7b0ff74 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp @@ -821,7 +821,7 @@ HWTEST_F(CommandStreamReceiverCQFlushTaskTests, getCSShouldReturnACSWithEnoughSi EXPECT_GE(commandStream.getAvailableSpace(), sizeRequested); commandStream.getSpace(sizeRequested - sizeCQReserves); - GraphicsAllocation allocation((void *)MemoryConstants::pageSize, 1); + MockGraphicsAllocation allocation((void *)MemoryConstants::pageSize, 1); IndirectHeap linear(&allocation); auto blocking = true; @@ -2136,7 +2136,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeAndThreeReco mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator); auto memorySize = (size_t)pDevice->getDeviceInfo().globalMemSize; - GraphicsAllocation largeAllocation(nullptr, memorySize); + MockGraphicsAllocation largeAllocation(nullptr, memorySize); DispatchFlags dispatchFlags; dispatchFlags.guardCommandBufferWithPipeControl = true; @@ -2565,7 +2565,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenSusbsequ auto additionalSize = 1234; - GraphicsAllocation graphicsAllocation(nullptr, additionalSize); + MockGraphicsAllocation graphicsAllocation(nullptr, additionalSize); mockCsr->makeResident(graphicsAllocation); mockCsr->flushTask(commandStream, @@ -2627,7 +2627,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenTotalRes EXPECT_EQ(expectedUsed, mockCsr->peekTotalMemoryUsed()); auto budgetSize = (size_t)pDevice->getDeviceInfo().globalMemSize; - GraphicsAllocation hugeAllocation(nullptr, budgetSize / 4); + MockGraphicsAllocation hugeAllocation(nullptr, budgetSize / 4); mockCsr->makeResident(hugeAllocation); mockCsr->flushTask(commandStream, diff --git a/unit_tests/command_stream/command_stream_receiver_tests.cpp b/unit_tests/command_stream/command_stream_receiver_tests.cpp index 4666c2daad..0d2aac90aa 100644 --- a/unit_tests/command_stream/command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_tests.cpp @@ -23,6 +23,7 @@ #include "unit_tests/mocks/mock_builtins.h" #include "unit_tests/mocks/mock_context.h" #include "unit_tests/mocks/mock_csr.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" #include "unit_tests/mocks/mock_memory_manager.h" #include "unit_tests/mocks/mock_program.h" @@ -279,21 +280,21 @@ HWTEST_F(CommandStreamReceiverTest, whenCsrIsCreatedThenUseTimestampPacketWriteI TEST(CommandStreamReceiverSimpleTest, givenCSRWithTagAllocationSetWhenGetTagAllocationIsCalledThenCorrectAllocationIsReturned) { ExecutionEnvironment executionEnvironment; MockCommandStreamReceiver csr(executionEnvironment); - GraphicsAllocation allocation(reinterpret_cast(0x1000), 0x1000); + MockGraphicsAllocation allocation(reinterpret_cast(0x1000), 0x1000); csr.setTagAllocation(&allocation); EXPECT_EQ(&allocation, csr.getTagAllocation()); } TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroyedThenItDestroysTagAllocation) { - struct MockGraphicsAllocation : public GraphicsAllocation { + struct MockGraphicsAllocationWithDestructorTracing : public GraphicsAllocation { using GraphicsAllocation::GraphicsAllocation; - ~MockGraphicsAllocation() override { *destructorCalled = true; } + ~MockGraphicsAllocationWithDestructorTracing() override { *destructorCalled = true; } bool *destructorCalled = nullptr; }; bool destructorCalled = false; - auto mockGraphicsAllocation = new MockGraphicsAllocation(nullptr, 1u); + auto mockGraphicsAllocation = new MockGraphicsAllocationWithDestructorTracing(nullptr, 0llu, 0llu, 1u); mockGraphicsAllocation->destructorCalled = &destructorCalled; ExecutionEnvironment executionEnvironment; executionEnvironment.commandStreamReceivers.push_back(std::make_unique(executionEnvironment)); @@ -337,7 +338,7 @@ TEST(CommandStreamReceiverSimpleTest, givenCSRWhenWaitBeforeMakingNonResidentWhe ExecutionEnvironment executionEnvironment; MockCommandStreamReceiver csr(executionEnvironment); uint32_t tag = 0; - GraphicsAllocation allocation(&tag, sizeof(tag)); + MockGraphicsAllocation allocation(&tag, sizeof(tag)); csr.latestFlushedTaskCount = 3; csr.setTagAllocation(&allocation); csr.waitBeforeMakingNonResidentWhenRequired(); diff --git a/unit_tests/command_stream/linear_stream_tests.cpp b/unit_tests/command_stream/linear_stream_tests.cpp index a397fb583c..61dfe48dbc 100644 --- a/unit_tests/command_stream/linear_stream_tests.cpp +++ b/unit_tests/command_stream/linear_stream_tests.cpp @@ -8,6 +8,7 @@ #include "runtime/command_stream/linear_stream.h" #include "runtime/memory_manager/graphics_allocation.h" #include "unit_tests/command_stream/linear_stream_fixture.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" using namespace OCLRT; @@ -93,8 +94,8 @@ TEST_F(LinearStreamTest, givenNewGraphicsAllocationWhenReplaceIsCalledThenLinear auto graphicsAllocation = linearStream.getGraphicsAllocation(); EXPECT_NE(nullptr, graphicsAllocation); auto address = (void *)0x100000; - GraphicsAllocation newGraphicsAllocation(address, 4096); + MockGraphicsAllocation newGraphicsAllocation(address, 4096); EXPECT_NE(&newGraphicsAllocation, graphicsAllocation); linearStream.replaceGraphicsAllocation(&newGraphicsAllocation); EXPECT_EQ(&newGraphicsAllocation, linearStream.getGraphicsAllocation()); -} \ No newline at end of file +} diff --git a/unit_tests/command_stream/submissions_aggregator_tests.cpp b/unit_tests/command_stream/submissions_aggregator_tests.cpp index 35ce57bb32..759029c521 100644 --- a/unit_tests/command_stream/submissions_aggregator_tests.cpp +++ b/unit_tests/command_stream/submissions_aggregator_tests.cpp @@ -14,6 +14,7 @@ #include "unit_tests/mocks/mock_kernel.h" #include "unit_tests/mocks/mock_csr.h" #include "unit_tests/mocks/mock_command_queue.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" using namespace OCLRT; @@ -49,12 +50,12 @@ TEST(SubmissionsAggregator, givenTwoCommandBuffersWhenMergeResourcesIsCalledThen CommandBuffer *cmdBuffer = new CommandBuffer(*device); CommandBuffer *cmdBuffer2 = new CommandBuffer(*device); - GraphicsAllocation alloc1(nullptr, 1); - GraphicsAllocation alloc2(nullptr, 2); - GraphicsAllocation alloc3(nullptr, 3); - GraphicsAllocation alloc4(nullptr, 4); - GraphicsAllocation alloc5(nullptr, 5); - GraphicsAllocation alloc6(nullptr, 6); + MockGraphicsAllocation alloc1(nullptr, 1); + MockGraphicsAllocation alloc2(nullptr, 2); + MockGraphicsAllocation alloc3(nullptr, 3); + MockGraphicsAllocation alloc4(nullptr, 4); + MockGraphicsAllocation alloc5(nullptr, 5); + MockGraphicsAllocation alloc6(nullptr, 6); cmdBuffer->surfaces.push_back(&alloc1); cmdBuffer->surfaces.push_back(&alloc6); @@ -109,13 +110,13 @@ TEST(SubmissionsAggregator, givenSubmissionAggregatorWhenThreeCommandBuffersAreS CommandBuffer *cmdBuffer2 = new CommandBuffer(*device); CommandBuffer *cmdBuffer3 = new CommandBuffer(*device); - GraphicsAllocation alloc1(nullptr, 1); - GraphicsAllocation alloc2(nullptr, 2); - GraphicsAllocation alloc3(nullptr, 3); - GraphicsAllocation alloc4(nullptr, 4); - GraphicsAllocation alloc5(nullptr, 5); - GraphicsAllocation alloc6(nullptr, 6); - GraphicsAllocation alloc7(nullptr, 7); + MockGraphicsAllocation alloc1(nullptr, 1); + MockGraphicsAllocation alloc2(nullptr, 2); + MockGraphicsAllocation alloc3(nullptr, 3); + MockGraphicsAllocation alloc4(nullptr, 4); + MockGraphicsAllocation alloc5(nullptr, 5); + MockGraphicsAllocation alloc6(nullptr, 6); + MockGraphicsAllocation alloc7(nullptr, 7); cmdBuffer->surfaces.push_back(&alloc5); cmdBuffer->surfaces.push_back(&alloc6); @@ -173,13 +174,13 @@ TEST(SubmissionsAggregator, givenMultipleCommandBuffersWhenTheyAreAggreagateWith CommandBuffer *cmdBuffer2 = new CommandBuffer(*device); CommandBuffer *cmdBuffer3 = new CommandBuffer(*device); - GraphicsAllocation alloc1(nullptr, 1); - GraphicsAllocation alloc2(nullptr, 2); - GraphicsAllocation alloc3(nullptr, 3); - GraphicsAllocation alloc4(nullptr, 4); - GraphicsAllocation alloc5(nullptr, 5); - GraphicsAllocation alloc6(nullptr, 6); - GraphicsAllocation alloc7(nullptr, 7); + MockGraphicsAllocation alloc1(nullptr, 1); + MockGraphicsAllocation alloc2(nullptr, 2); + MockGraphicsAllocation alloc3(nullptr, 3); + MockGraphicsAllocation alloc4(nullptr, 4); + MockGraphicsAllocation alloc5(nullptr, 5); + MockGraphicsAllocation alloc6(nullptr, 6); + MockGraphicsAllocation alloc7(nullptr, 7); //14 bytes consumed cmdBuffer->surfaces.push_back(&alloc5); @@ -229,13 +230,13 @@ TEST(SubmissionsAggregator, givenMultipleCommandBuffersWhenAggregateIsCalledMult CommandBuffer *cmdBuffer2 = new CommandBuffer(*device); CommandBuffer *cmdBuffer3 = new CommandBuffer(*device); - GraphicsAllocation alloc1(nullptr, 1); - GraphicsAllocation alloc2(nullptr, 2); - GraphicsAllocation alloc3(nullptr, 3); - GraphicsAllocation alloc4(nullptr, 4); - GraphicsAllocation alloc5(nullptr, 5); - GraphicsAllocation alloc6(nullptr, 6); - GraphicsAllocation alloc7(nullptr, 7); + MockGraphicsAllocation alloc1(nullptr, 1); + MockGraphicsAllocation alloc2(nullptr, 2); + MockGraphicsAllocation alloc3(nullptr, 3); + MockGraphicsAllocation alloc4(nullptr, 4); + MockGraphicsAllocation alloc5(nullptr, 5); + MockGraphicsAllocation alloc6(nullptr, 6); + MockGraphicsAllocation alloc7(nullptr, 7); //14 bytes consumed cmdBuffer->surfaces.push_back(&alloc5); @@ -292,10 +293,10 @@ TEST(SubmissionsAggregator, givenMultipleCommandBuffersWithDifferentGraphicsAllo CommandBuffer *cmdBuffer = new CommandBuffer(*device); CommandBuffer *cmdBuffer2 = new CommandBuffer(*device); - GraphicsAllocation alloc1(nullptr, 1); - GraphicsAllocation alloc2(nullptr, 2); - GraphicsAllocation alloc5(nullptr, 5); - GraphicsAllocation alloc7(nullptr, 7); + MockGraphicsAllocation alloc1(nullptr, 1); + MockGraphicsAllocation alloc2(nullptr, 2); + MockGraphicsAllocation alloc5(nullptr, 5); + MockGraphicsAllocation alloc7(nullptr, 7); //5 bytes consumed cmdBuffer->surfaces.push_back(&alloc5); @@ -325,10 +326,10 @@ TEST(SubmissionsAggregator, givenTwoCommandBufferWhereSecondContainsFirstOnResou CommandBuffer *cmdBuffer = new CommandBuffer(*device); CommandBuffer *cmdBuffer2 = new CommandBuffer(*device); - GraphicsAllocation cmdBufferAllocation1(nullptr, 1); - GraphicsAllocation cmdBufferAllocation2(nullptr, 2); - GraphicsAllocation alloc5(nullptr, 5); - GraphicsAllocation alloc7(nullptr, 7); + MockGraphicsAllocation cmdBufferAllocation1(nullptr, 1); + MockGraphicsAllocation cmdBufferAllocation2(nullptr, 2); + MockGraphicsAllocation alloc5(nullptr, 5); + MockGraphicsAllocation alloc7(nullptr, 7); cmdBuffer->batchBuffer.commandBufferAllocation = &cmdBufferAllocation1; cmdBuffer2->batchBuffer.commandBufferAllocation = &cmdBufferAllocation2; @@ -360,9 +361,9 @@ TEST(SubmissionsAggregator, givenTwoCommandBufferWhereSecondContainsTheFirstComm CommandBuffer *cmdBuffer = new CommandBuffer(*device); CommandBuffer *cmdBuffer2 = new CommandBuffer(*device); - GraphicsAllocation cmdBufferAllocation1(nullptr, 1); - GraphicsAllocation alloc5(nullptr, 5); - GraphicsAllocation alloc7(nullptr, 7); + MockGraphicsAllocation cmdBufferAllocation1(nullptr, 1); + MockGraphicsAllocation alloc5(nullptr, 5); + MockGraphicsAllocation alloc7(nullptr, 7); cmdBuffer->batchBuffer.commandBufferAllocation = &cmdBufferAllocation1; cmdBuffer2->batchBuffer.commandBufferAllocation = &cmdBufferAllocation1; @@ -392,8 +393,8 @@ TEST(SubmissionsAggregator, givenCommandBuffersRequiringDifferentCoherencySettin CommandBuffer *cmdBuffer = new CommandBuffer(*device); CommandBuffer *cmdBuffer2 = new CommandBuffer(*device); - GraphicsAllocation alloc1(nullptr, 1); - GraphicsAllocation alloc7(nullptr, 7); + MockGraphicsAllocation alloc1(nullptr, 1); + MockGraphicsAllocation alloc7(nullptr, 7); cmdBuffer->batchBuffer.requiresCoherency = true; cmdBuffer2->batchBuffer.requiresCoherency = false; @@ -421,8 +422,8 @@ TEST(SubmissionsAggregator, givenCommandBuffersRequiringDifferentThrottleSetting CommandBuffer *cmdBuffer = new CommandBuffer(*device); CommandBuffer *cmdBuffer2 = new CommandBuffer(*device); - GraphicsAllocation alloc1(nullptr, 1); - GraphicsAllocation alloc7(nullptr, 7); + MockGraphicsAllocation alloc1(nullptr, 1); + MockGraphicsAllocation alloc7(nullptr, 7); cmdBuffer->batchBuffer.throttle = QueueThrottle::LOW; cmdBuffer2->batchBuffer.throttle = QueueThrottle::MEDIUM; @@ -450,8 +451,8 @@ TEST(SubmissionsAggregator, givenCommandBuffersRequiringDifferentPrioritySetting CommandBuffer *cmdBuffer = new CommandBuffer(*device); CommandBuffer *cmdBuffer2 = new CommandBuffer(*device); - GraphicsAllocation alloc1(nullptr, 1); - GraphicsAllocation alloc7(nullptr, 7); + MockGraphicsAllocation alloc1(nullptr, 1); + MockGraphicsAllocation alloc7(nullptr, 7); cmdBuffer->batchBuffer.low_priority = true; cmdBuffer2->batchBuffer.low_priority = false; diff --git a/unit_tests/command_stream/tbx_command_stream_tests.cpp b/unit_tests/command_stream/tbx_command_stream_tests.cpp index ec8ed08af8..c1f023a2b4 100644 --- a/unit_tests/command_stream/tbx_command_stream_tests.cpp +++ b/unit_tests/command_stream/tbx_command_stream_tests.cpp @@ -16,6 +16,7 @@ #include "unit_tests/command_queue/command_queue_fixture.h" #include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/helpers/debug_manager_state_restore.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" #include "test.h" #include @@ -79,7 +80,7 @@ TEST_F(TbxCommandStreamTests, DISABLED_makeResident) { } TEST_F(TbxCommandStreamTests, DISABLED_makeResidentOnZeroSizedBufferShouldDoNothing) { - GraphicsAllocation graphicsAllocation(nullptr, 0); + MockGraphicsAllocation graphicsAllocation(nullptr, 0); pCommandStreamReceiver->makeResident(graphicsAllocation); pCommandStreamReceiver->makeNonResident(graphicsAllocation); @@ -213,7 +214,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenWriteMemoryIsCa HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenWriteMemoryIsCalledForGraphicsAllocationWithZeroSizeThenItShouldReturnFalse) { TbxCommandStreamReceiverHw *tbxCsr = (TbxCommandStreamReceiverHw *)pCommandStreamReceiver; - GraphicsAllocation graphicsAllocation((void *)0x1234, 0); + MockGraphicsAllocation graphicsAllocation((void *)0x1234, 0); EXPECT_FALSE(tbxCsr->writeMemory(graphicsAllocation)); } diff --git a/unit_tests/event/event_tests.cpp b/unit_tests/event/event_tests.cpp index 8866b78096..55471b0a1f 100644 --- a/unit_tests/event/event_tests.cpp +++ b/unit_tests/event/event_tests.cpp @@ -472,7 +472,7 @@ TEST_F(InternalsEventTest, processBlockedCommandsKernelOperation) { auto &csr = pDevice->getCommandStreamReceiver(); std::vector v; SurfaceMock *surface = new SurfaceMock; - surface->graphicsAllocation = new GraphicsAllocation((void *)0x1234, 100u); + surface->graphicsAllocation = new MockGraphicsAllocation((void *)0x1234, 100u); PreemptionMode preemptionMode = pDevice->getPreemptionMode(); v.push_back(surface); auto cmd = new CommandComputeKernel(cmdQ, std::unique_ptr(blockedCommandsData), v, false, false, false, nullptr, preemptionMode, pKernel, 1); diff --git a/unit_tests/fixtures/ult_command_stream_receiver_fixture.h b/unit_tests/fixtures/ult_command_stream_receiver_fixture.h index 45e8e2940a..366cb3a254 100644 --- a/unit_tests/fixtures/ult_command_stream_receiver_fixture.h +++ b/unit_tests/fixtures/ult_command_stream_receiver_fixture.h @@ -14,6 +14,7 @@ #include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/helpers/hw_parse.h" #include "unit_tests/libult/ult_command_stream_receiver.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" namespace OCLRT { @@ -38,20 +39,20 @@ struct UltCommandStreamReceiverTest ASSERT_NE(nullptr, sshBuffer); commandStream.replaceBuffer(cmdBuffer, sizeStream); - auto graphicsAllocation = new GraphicsAllocation(cmdBuffer, sizeStream); + auto graphicsAllocation = new MockGraphicsAllocation(cmdBuffer, sizeStream); commandStream.replaceGraphicsAllocation(graphicsAllocation); dsh.replaceBuffer(dshBuffer, sizeStream); - graphicsAllocation = new GraphicsAllocation(dshBuffer, sizeStream); + graphicsAllocation = new MockGraphicsAllocation(dshBuffer, sizeStream); dsh.replaceGraphicsAllocation(graphicsAllocation); ioh.replaceBuffer(iohBuffer, sizeStream); - graphicsAllocation = new GraphicsAllocation(iohBuffer, sizeStream); + graphicsAllocation = new MockGraphicsAllocation(iohBuffer, sizeStream); ioh.replaceGraphicsAllocation(graphicsAllocation); ssh.replaceBuffer(sshBuffer, sizeStream); - graphicsAllocation = new GraphicsAllocation(sshBuffer, sizeStream); + graphicsAllocation = new MockGraphicsAllocation(sshBuffer, sizeStream); ssh.replaceGraphicsAllocation(graphicsAllocation); } diff --git a/unit_tests/gen10/test_preamble_gen10.cpp b/unit_tests/gen10/test_preamble_gen10.cpp index 5a6ab3c319..f2b2d7b2a6 100644 --- a/unit_tests/gen10/test_preamble_gen10.cpp +++ b/unit_tests/gen10/test_preamble_gen10.cpp @@ -50,7 +50,7 @@ struct CnlPreambleWaCmds : public PreambleFixture { DeviceFixture::SetUpImpl(pHwInfo); HardwareParse::SetUp(); if (pDevice->getPreemptionMode() == PreemptionMode::MidThread) { - preemptionLocation.reset(new GraphicsAllocation(nullptr, 0)); + preemptionLocation.reset(new GraphicsAllocation(nullptr, 0llu, 0llu, 0)); } } diff --git a/unit_tests/gmm_helper/gmm_helper_tests.cpp b/unit_tests/gmm_helper/gmm_helper_tests.cpp index 6fd843294c..34914d97a3 100644 --- a/unit_tests/gmm_helper/gmm_helper_tests.cpp +++ b/unit_tests/gmm_helper/gmm_helper_tests.cpp @@ -19,6 +19,7 @@ #include "unit_tests/libult/mock_gfx_family.h" #include "unit_tests/mocks/mock_device.h" #include "unit_tests/mocks/mock_gmm.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" #include "runtime/platform/platform.h" #include "GL/gl.h" @@ -253,7 +254,7 @@ TEST_F(GmmTests, givenTilableImageWhenEnableForceLinearImagesThenYTilingIsDisabl } TEST_F(GmmTests, givenZeroRowPitchWhenQueryImgFromBufferParamsThenCalculate) { - GraphicsAllocation bufferAllocation(nullptr, 4096); + MockGraphicsAllocation bufferAllocation(nullptr, 4096); cl_image_desc imgDesc{}; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; @@ -269,7 +270,7 @@ TEST_F(GmmTests, givenZeroRowPitchWhenQueryImgFromBufferParamsThenCalculate) { } TEST_F(GmmTests, givenNonZeroRowPitchWhenQueryImgFromBufferParamsThenUseUserValue) { - GraphicsAllocation bufferAllocation(nullptr, 4096); + MockGraphicsAllocation bufferAllocation(nullptr, 4096); cl_image_desc imgDesc{}; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; diff --git a/unit_tests/helpers/dirty_state_helpers_tests.cpp b/unit_tests/helpers/dirty_state_helpers_tests.cpp index 271809d1a6..13185707aa 100644 --- a/unit_tests/helpers/dirty_state_helpers_tests.cpp +++ b/unit_tests/helpers/dirty_state_helpers_tests.cpp @@ -10,6 +10,7 @@ #include "runtime/indirect_heap/indirect_heap.h" #include "runtime/memory_manager/graphics_allocation.h" #include "gtest/gtest.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" #include namespace DirtyStateHelpers { @@ -33,7 +34,7 @@ struct HeapDirtyStateTests : ::testing::Test { ASSERT_EQ(heapAllocation.getUnderlyingBufferSize(), stream->getMaxAvailableSpace()); } - GraphicsAllocation heapAllocation = {buffer, bufferSize}; + MockGraphicsAllocation heapAllocation = {buffer, bufferSize}; std::unique_ptr stream; MockHeapDirtyState mockHeapDirtyState; @@ -109,8 +110,8 @@ TEST_F(HeapDirtyStateTests, givenNonDirtyObjectWhenSizeAndBufferChangedThenRetur } TEST(DirtyStateHelpers, givenDirtyStateHelperWhenTwoDifferentIndirectHeapsAreCheckedButWithTheSame4GBbaseThenStateIsNotDirty) { - GraphicsAllocation firstHeapAllocation(reinterpret_cast(0x1234), 4192); - GraphicsAllocation secondHeapAllocation(reinterpret_cast(0x9345), 1234); + MockGraphicsAllocation firstHeapAllocation(reinterpret_cast(0x1234), 4192); + MockGraphicsAllocation secondHeapAllocation(reinterpret_cast(0x9345), 1234); uint64_t commonBase = 0x8123456; firstHeapAllocation.gpuBaseAddress = commonBase; secondHeapAllocation.gpuBaseAddress = commonBase; diff --git a/unit_tests/helpers/dispatch_info_builder_tests.cpp b/unit_tests/helpers/dispatch_info_builder_tests.cpp index f743fc50b3..6e3d3a8e88 100644 --- a/unit_tests/helpers/dispatch_info_builder_tests.cpp +++ b/unit_tests/helpers/dispatch_info_builder_tests.cpp @@ -879,7 +879,7 @@ TEST_F(DispatchInfoBuilderTest, setKernelArg) { char data[128]; void *svmPtr = &data; EXPECT_EQ(CL_SUCCESS, diBuilder->setArgSvm(1, sizeof(svmPtr), svmPtr)); - GraphicsAllocation svmAlloc(svmPtr, 128); + MockGraphicsAllocation svmAlloc(svmPtr, 128); EXPECT_EQ(CL_SUCCESS, diBuilder->setArgSvmAlloc(2, svmPtr, &svmAlloc)); for (auto &dispatchInfo : multiDispatchInfo) { @@ -990,7 +990,7 @@ TEST_F(DispatchInfoBuilderTest, setKernelArgNullKernel) { auto pVal = &val; char data[128]; void *svmPtr = &data; - GraphicsAllocation svmAlloc(svmPtr, 128); + MockGraphicsAllocation svmAlloc(svmPtr, 128); DispatchInfoBuilder *diBuilder = new DispatchInfoBuilder(); ASSERT_NE(nullptr, diBuilder); diff --git a/unit_tests/helpers/kernel_commands_tests.cpp b/unit_tests/helpers/kernel_commands_tests.cpp index c859bcd681..0fdf5c5a77 100644 --- a/unit_tests/helpers/kernel_commands_tests.cpp +++ b/unit_tests/helpers/kernel_commands_tests.cpp @@ -700,12 +700,12 @@ HWCMDTEST_F(IGFX_GEN8_CORE, KernelCommandsTest, usedBindingTableStatePointersFor // setup global memory char globalBuffer[16]; - GraphicsAllocation gfxGlobalAlloc(globalBuffer, sizeof(globalBuffer)); + GraphicsAllocation gfxGlobalAlloc(globalBuffer, castToUint64(globalBuffer), 0llu, sizeof(globalBuffer)); program.setGlobalSurface(&gfxGlobalAlloc); // setup constant memory char constBuffer[16]; - GraphicsAllocation gfxConstAlloc(constBuffer, sizeof(constBuffer)); + GraphicsAllocation gfxConstAlloc(constBuffer, castToUint64(constBuffer), 0llu, sizeof(constBuffer)); program.setConstantSurface(&gfxConstAlloc); // create kernel diff --git a/unit_tests/indirect_heap/indirect_heap_tests.cpp b/unit_tests/indirect_heap/indirect_heap_tests.cpp index dc028a174c..3678d98af3 100644 --- a/unit_tests/indirect_heap/indirect_heap_tests.cpp +++ b/unit_tests/indirect_heap/indirect_heap_tests.cpp @@ -88,7 +88,7 @@ TEST_F(IndirectHeapTest, givenIndirectHeapWhenGetCpuBaseIsCalledThenCpuAddressIs TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhenAskedForHeapGpuStartOffsetThenZeroIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x3000); - GraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); + MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); graphicsAllocation.gpuBaseAddress = 4096u; IndirectHeap indirectHeap(&graphicsAllocation, false); @@ -97,7 +97,7 @@ TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhen TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapSupporting4GbModeWhenAskedForHeapGpuStartOffsetThenZeroIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x3000); - GraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); + MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); graphicsAllocation.gpuBaseAddress = 4096u; IndirectHeap indirectHeap(&graphicsAllocation, true); @@ -106,7 +106,7 @@ TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapSupporting4GbModeWhenAsk TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapSupporting4GbModeWhenAskedForHeapBaseThenGpuBaseIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x2000); - GraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); + MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); graphicsAllocation.gpuBaseAddress = 4096u; IndirectHeap indirectHeap(&graphicsAllocation, true); @@ -115,7 +115,7 @@ TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapSupporting4GbModeWhenAsk TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhenAskedForHeapBaseThenGpuAddressIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x2000); - GraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); + MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); graphicsAllocation.gpuBaseAddress = 4096u; IndirectHeap indirectHeap(&graphicsAllocation, false); @@ -124,7 +124,7 @@ TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhen TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhenAskedForHeapSizeThenGraphicsAllocationSizeInPagesIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x2000); - GraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); + MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); graphicsAllocation.gpuBaseAddress = 4096u; IndirectHeap indirectHeap(&graphicsAllocation, false); @@ -133,9 +133,9 @@ TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapNotSupporting4GbModeWhen TEST(IndirectHeapWith4GbAllocatorTest, givenIndirectHeapSupporting4GbModeWhenAskedForHeapSizeThen4GbSizeInPagesIsReturned) { auto cpuBaseAddress = reinterpret_cast(0x2000); - GraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); + MockGraphicsAllocation graphicsAllocation(cpuBaseAddress, 4096u); graphicsAllocation.gpuBaseAddress = 4096u; IndirectHeap indirectHeap(&graphicsAllocation, true); EXPECT_EQ(MemoryConstants::sizeOf4GBinPageEntities, indirectHeap.getHeapSizeInPages()); -} \ No newline at end of file +} diff --git a/unit_tests/kernel/clone_kernel_tests.cpp b/unit_tests/kernel/clone_kernel_tests.cpp index bf864b358d..5b57aa4464 100644 --- a/unit_tests/kernel/clone_kernel_tests.cpp +++ b/unit_tests/kernel/clone_kernel_tests.cpp @@ -449,7 +449,7 @@ TEST_F(CloneKernelTest, cloneKernelWithArgSvm) { TEST_F(CloneKernelTest, cloneKernelWithArgSvmAlloc) { char *svmPtr = new char[256]; - GraphicsAllocation svmAlloc(svmPtr, 256); + MockGraphicsAllocation svmAlloc(svmPtr, 256); retVal = pSourceKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc); ASSERT_EQ(CL_SUCCESS, retVal); diff --git a/unit_tests/kernel/kernel_arg_svm_tests.cpp b/unit_tests/kernel/kernel_arg_svm_tests.cpp index f11c62223f..1546324c13 100644 --- a/unit_tests/kernel/kernel_arg_svm_tests.cpp +++ b/unit_tests/kernel/kernel_arg_svm_tests.cpp @@ -131,7 +131,7 @@ HWTEST_F(KernelArgSvmTest, SetKernelArgValidSvmPtrStateful) { TEST_F(KernelArgSvmTest, SetKernelArgValidSvmAlloc) { char *svmPtr = new char[256]; - GraphicsAllocation svmAlloc(svmPtr, 256); + MockGraphicsAllocation svmAlloc(svmPtr, 256); auto retVal = pKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc); EXPECT_EQ(CL_SUCCESS, retVal); @@ -146,7 +146,7 @@ TEST_F(KernelArgSvmTest, SetKernelArgValidSvmAlloc) { TEST_F(KernelArgSvmTest, SetKernelArgValidSvmAllocStateless) { char *svmPtr = new char[256]; - GraphicsAllocation svmAlloc(svmPtr, 256); + MockGraphicsAllocation svmAlloc(svmPtr, 256); pKernelInfo->usesSsh = false; pKernelInfo->requiresSshForBuffers = false; @@ -162,7 +162,7 @@ TEST_F(KernelArgSvmTest, SetKernelArgValidSvmAllocStateless) { HWTEST_F(KernelArgSvmTest, SetKernelArgValidSvmAllocStateful) { char *svmPtr = new char[256]; - GraphicsAllocation svmAlloc(svmPtr, 256); + MockGraphicsAllocation svmAlloc(svmPtr, 256); pKernelInfo->usesSsh = true; pKernelInfo->requiresSshForBuffers = true; @@ -188,7 +188,7 @@ HWTEST_F(KernelArgSvmTest, givenOffsetedSvmPointerWhenSetArgSvmAllocIsCalledThen auto offsetedPtr = svmPtr.get() + 4; - GraphicsAllocation svmAlloc(svmPtr.get(), 256); + MockGraphicsAllocation svmAlloc(svmPtr.get(), 256); pKernelInfo->usesSsh = true; pKernelInfo->requiresSshForBuffers = true; @@ -220,7 +220,7 @@ HWTEST_F(KernelArgSvmTest, PatchWithImplicitSurface) { pKernelInfo->requiresSshForBuffers = true; pKernelInfo->usesSsh = true; { - GraphicsAllocation svmAlloc(svmPtr.data(), svmPtr.size()); + MockGraphicsAllocation svmAlloc(svmPtr.data(), svmPtr.size()); SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization patch; memset(&patch, 0, sizeof(patch)); @@ -270,7 +270,7 @@ TEST_F(KernelArgSvmTest, patchBufferOffset) { constexpr uint32_t initVal = 7U; constexpr uint32_t svmOffset = 13U; - GraphicsAllocation svmAlloc(svmPtr.data(), 256); + MockGraphicsAllocation svmAlloc(svmPtr.data(), 256); uint32_t *expectedPatchPtr = reinterpret_cast(pKernel->getCrossThreadData()); KernelArgInfo kai; @@ -371,7 +371,7 @@ HWTEST_TYPED_TEST(KernelArgSvmTestTyped, GivenBufferKernelArgWhenBufferOffsetIsN this->pKernelInfo->requiresSshForBuffers = true; this->pKernelInfo->usesSsh = true; { - GraphicsAllocation svmAlloc(svmPtr, svmSize); + MockGraphicsAllocation svmAlloc(svmPtr, svmSize); constexpr size_t patchOffset = 16; void *ptrToPatch = svmPtr + patchOffset; diff --git a/unit_tests/kernel/kernel_tests.cpp b/unit_tests/kernel/kernel_tests.cpp index 79b9951eba..b09c7856ee 100644 --- a/unit_tests/kernel/kernel_tests.cpp +++ b/unit_tests/kernel/kernel_tests.cpp @@ -21,6 +21,7 @@ #include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/helpers/gtest_helpers.h" #include "test.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" #include "unit_tests/mocks/mock_kernel.h" #include "unit_tests/mocks/mock_program.h" #include "unit_tests/mocks/mock_context.h" @@ -744,7 +745,7 @@ TEST_F(KernelPrivateSurfaceTest, givenStatelessKernelWhenKernelIsCreatedThenPriv // setup global memory char buffer[16]; - GraphicsAllocation gfxAlloc(buffer, sizeof(buffer)); + MockGraphicsAllocation gfxAlloc(buffer, sizeof(buffer)); MockContext context; MockProgram program(*pDevice->getExecutionEnvironment(), &context, false); @@ -942,7 +943,7 @@ HWTEST_F(KernelGlobalSurfaceTest, givenStatefulKernelWhenKernelIsCreatedThenGlob pKernelInfo->patchInfo.pAllocateStatelessGlobalMemorySurfaceWithInitialization = &AllocateStatelessGlobalMemorySurfaceWithInitialization; char buffer[16]; - GraphicsAllocation gfxAlloc(buffer, sizeof(buffer)); + MockGraphicsAllocation gfxAlloc(buffer, sizeof(buffer)); void *bufferAddress = gfxAlloc.getUnderlyingBuffer(); MockContext context; @@ -993,7 +994,7 @@ TEST_F(KernelGlobalSurfaceTest, givenStatelessKernelWhenKernelIsCreatedThenGloba // setup global memory char buffer[16]; - GraphicsAllocation gfxAlloc(buffer, sizeof(buffer)); + MockGraphicsAllocation gfxAlloc(buffer, sizeof(buffer)); MockProgram program(*pDevice->getExecutionEnvironment()); program.setGlobalSurface(&gfxAlloc); @@ -1116,7 +1117,7 @@ HWTEST_F(KernelConstantSurfaceTest, givenStatefulKernelWhenKernelIsCreatedThenCo pKernelInfo->patchInfo.pAllocateStatelessConstantMemorySurfaceWithInitialization = &AllocateStatelessConstantMemorySurfaceWithInitialization; char buffer[16]; - GraphicsAllocation gfxAlloc(buffer, sizeof(buffer)); + MockGraphicsAllocation gfxAlloc(buffer, sizeof(buffer)); void *bufferAddress = gfxAlloc.getUnderlyingBuffer(); MockContext context; @@ -1167,7 +1168,7 @@ TEST_F(KernelConstantSurfaceTest, givenStatelessKernelWhenKernelIsCreatedThenCon // setup global memory char buffer[16]; - GraphicsAllocation gfxAlloc(buffer, sizeof(buffer)); + MockGraphicsAllocation gfxAlloc(buffer, sizeof(buffer)); MockProgram program(*pDevice->getExecutionEnvironment()); program.setConstantSurface(&gfxAlloc); diff --git a/unit_tests/libult/ult_command_stream_receiver.h b/unit_tests/libult/ult_command_stream_receiver.h index 9e7d458094..e03b2a78f4 100644 --- a/unit_tests/libult/ult_command_stream_receiver.h +++ b/unit_tests/libult/ult_command_stream_receiver.h @@ -65,7 +65,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw { UltCommandStreamReceiver(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment) : BaseClass(hwInfoIn, executionEnvironment) { this->storeMakeResidentAllocations = false; if (hwInfoIn.capabilityTable.defaultPreemptionMode == PreemptionMode::MidThread) { - tempPreemptionLocation = new GraphicsAllocation(nullptr, 0); + tempPreemptionLocation = new GraphicsAllocation(nullptr, 0llu, 0, 0llu); this->preemptionCsrAllocation = tempPreemptionLocation; } } diff --git a/unit_tests/mem_obj/mem_obj_tests.cpp b/unit_tests/mem_obj/mem_obj_tests.cpp index 3d82fd52dc..56b2b40f7b 100644 --- a/unit_tests/mem_obj/mem_obj_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_tests.cpp @@ -488,7 +488,7 @@ TEST(MemObj, givenNotSharedMemObjectWhenChangingGfxAllocationThenOldAllocationIs } TEST(MemObj, givenGraphicsAllocationWhenCallingIsAllocDumpableThenItReturnsTheCorrectValue) { - GraphicsAllocation gfxAllocation(nullptr, 0); + MockGraphicsAllocation gfxAllocation(nullptr, 0); EXPECT_FALSE(gfxAllocation.isAllocDumpable()); gfxAllocation.setAllocDumpable(true); EXPECT_TRUE(gfxAllocation.isAllocDumpable()); diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 79beed4573..197a4d9f6f 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -62,7 +62,7 @@ TEST(GraphicsAllocationTest, Ctor) { void *cpuPtr = (void *)0x30000; size_t size = 0x1000; - GraphicsAllocation gfxAllocation(cpuPtr, size); + MockGraphicsAllocation gfxAllocation(cpuPtr, size); uint64_t expectedGpuAddr = static_cast(reinterpret_cast(gfxAllocation.getUnderlyingBuffer())); EXPECT_EQ(expectedGpuAddr, gfxAllocation.getGpuAddress()); @@ -153,7 +153,7 @@ TEST_F(MemoryAllocatorTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationToH void *cpuPtr = (void *)0x30000; size_t size = 0x1000; - GraphicsAllocation gfxAllocation(cpuPtr, size); + MockGraphicsAllocation gfxAllocation(cpuPtr, size); memoryManager->addAllocationToHostPtrManager(&gfxAllocation); auto fragment = memoryManager->getHostPtrManager()->getFragment(gfxAllocation.getUnderlyingBuffer()); EXPECT_NE(fragment, nullptr); @@ -1369,7 +1369,7 @@ TEST(GraphicsAllocation, givenCpuPointerBasedConstructorWhenGraphicsAllocationIs uintptr_t address = 0xf0000000; void *addressWithTrailingBitSet = reinterpret_cast(address); uint64_t expectedGpuAddress = 0xf0000000; - GraphicsAllocation graphicsAllocation(addressWithTrailingBitSet, 1u); + MockGraphicsAllocation graphicsAllocation(addressWithTrailingBitSet, 1u); EXPECT_EQ(expectedGpuAddress, graphicsAllocation.getGpuAddress()); } @@ -1383,7 +1383,7 @@ TEST(GraphicsAllocation, givenSharedHandleBasedConstructorWhenGraphicsAllocation } TEST(GraphicsAllocation, givenGraphicsAllocationCreatedWithDefaultConstructorThenItIsNotResidentInAllContexts) { - GraphicsAllocation graphicsAllocation(nullptr, 1u); + MockGraphicsAllocation graphicsAllocation(nullptr, 1u); for (uint32_t index = 0u; index < maxOsContextCount; index++) { EXPECT_EQ(ObjectNotResident, graphicsAllocation.residencyTaskCount[index]); } diff --git a/unit_tests/memory_manager/surface_tests.cpp b/unit_tests/memory_manager/surface_tests.cpp index 19822dbee8..637958044b 100644 --- a/unit_tests/memory_manager/surface_tests.cpp +++ b/unit_tests/memory_manager/surface_tests.cpp @@ -48,7 +48,7 @@ class SurfaceTest : public ::testing::Test { public: char data[10]; MockBuffer buffer; - GraphicsAllocation gfxAllocation{nullptr, 0}; + MockGraphicsAllocation gfxAllocation{nullptr, 0}; }; TYPED_TEST_CASE(SurfaceTest, SurfaceTypes); diff --git a/unit_tests/mocks/mock_graphics_allocation.h b/unit_tests/mocks/mock_graphics_allocation.h index 2cdf1a15b8..e947f67581 100644 --- a/unit_tests/mocks/mock_graphics_allocation.h +++ b/unit_tests/mocks/mock_graphics_allocation.h @@ -13,7 +13,7 @@ class MockGraphicsAllocation : public GraphicsAllocation { using GraphicsAllocation::GraphicsAllocation; public: - MockGraphicsAllocation(void *buffer, size_t sizeIn) : GraphicsAllocation(buffer, sizeIn) { + MockGraphicsAllocation(void *buffer, size_t sizeIn) : GraphicsAllocation(buffer, castToUint64(buffer), 0llu, sizeIn) { } void resetInspectionId() { this->inspectionId = 0; diff --git a/unit_tests/program/block_kernel_manager_tests.cpp b/unit_tests/program/block_kernel_manager_tests.cpp index 9bd0e15724..e581c6374c 100644 --- a/unit_tests/program/block_kernel_manager_tests.cpp +++ b/unit_tests/program/block_kernel_manager_tests.cpp @@ -1,36 +1,22 @@ /* -* Copyright (c) 2017, Intel Corporation -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included -* in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -*/ + * Copyright (C) 2017-2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ #include "runtime/memory_manager/graphics_allocation.h" #include "runtime/program/kernel_info.h" #include "unit_tests/mocks/mock_block_kernel_manager.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" #include "gtest/gtest.h" using namespace OCLRT; TEST(BlockKernelManagerTest, pushPrivateSurfaceResizesArray) { - GraphicsAllocation allocation(0, 0); + MockGraphicsAllocation allocation(0, 0); KernelInfo *blockInfo = new KernelInfo; MockBlockKernelManager blockManager; @@ -44,8 +30,8 @@ TEST(BlockKernelManagerTest, pushPrivateSurfaceResizesArray) { } TEST(BlockKernelManagerTest, pushPrivateSurfacePlacesAllocationInCorrectPosition) { - GraphicsAllocation allocation1(0, 0); - GraphicsAllocation allocation2(0, 0); + MockGraphicsAllocation allocation1(0, 0); + MockGraphicsAllocation allocation2(0, 0); KernelInfo *blockInfo = new KernelInfo; KernelInfo *blockInfo2 = new KernelInfo; MockBlockKernelManager blockManager; @@ -63,7 +49,7 @@ TEST(BlockKernelManagerTest, pushPrivateSurfacePlacesAllocationInCorrectPosition } TEST(BlockKernelManagerTest, pushPrivateSurfaceSetsPrivateSurfaceArrayToNullptrOnFirstCall) { - GraphicsAllocation allocation(0, 0); + MockGraphicsAllocation allocation(0, 0); KernelInfo *blockInfo = new KernelInfo; KernelInfo *blockInfo2 = new KernelInfo; KernelInfo *blockInfo3 = new KernelInfo; @@ -82,7 +68,7 @@ TEST(BlockKernelManagerTest, pushPrivateSurfaceSetsPrivateSurfaceArrayToNullptrO } TEST(BlockKernelManagerTest, getPrivateSurface) { - GraphicsAllocation allocation(0, 0); + MockGraphicsAllocation allocation(0, 0); KernelInfo *blockInfo = new KernelInfo; MockBlockKernelManager blockManager; @@ -100,4 +86,4 @@ TEST(BlockKernelManagerTest, getPrivateSurfaceWithOutOfBoundOrdinalRetunrsNullpt MockBlockKernelManager blockManager; EXPECT_EQ(nullptr, blockManager.getPrivateSurface(0)); EXPECT_EQ(nullptr, blockManager.getPrivateSurface(10)); -} \ No newline at end of file +} diff --git a/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp b/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp index 56af669297..a350620103 100644 --- a/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp +++ b/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp @@ -11,6 +11,7 @@ #include "unit_tests/mocks/mock_builtins.h" #include "unit_tests/mocks/mock_csr.h" #include "unit_tests/mocks/mock_device.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" #include "test.h" #include @@ -33,7 +34,7 @@ HWTEST_F(CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebugger void *buffer = alignedMalloc(MemoryConstants::pageSize, MemoryConstants::pageSize64k); - std::unique_ptr allocation(new GraphicsAllocation(buffer, MemoryConstants::pageSize)); + std::unique_ptr allocation(new MockGraphicsAllocation(buffer, MemoryConstants::pageSize)); std::unique_ptr heap(new IndirectHeap(allocation.get())); mockCsr->flushTask(commandStream,