From 552a1268ebed3eb239d751dcd93bd5837d943b0b Mon Sep 17 00:00:00 2001 From: Filip Hazubski Date: Tue, 6 Aug 2019 18:01:26 +0200 Subject: [PATCH] Refactor blit buffer call Resolves: NEO-3241 Change-Id: I726135ae55d1e0fcbacd80620e827ee5c7c0c8dc Signed-off-by: Filip Hazubski --- common/helpers/bit_helpers.h | 11 ++++ .../cpu_data_transfer_handler.cpp | 4 +- .../aub_command_stream_receiver_hw_base.inl | 9 +-- ...mand_stream_receiver_simulated_common_hw.h | 5 ++ .../command_stream_receiver_with_aub_dump.inl | 2 +- .../create_command_stream_impl.cpp | 2 +- .../command_stream_receiver_simulated_hw.h | 13 ++++ .../tbx_command_stream_receiver_hw.inl | 7 +- runtime/context/context.h | 7 ++ runtime/context/context_extra.cpp | 4 ++ .../gen9/command_stream_receiver_hw_gen9.cpp | 2 +- .../helpers/flat_batch_buffer_helper_hw.inl | 2 +- runtime/mem_obj/buffer.cpp | 10 +-- runtime/memory_manager/CMakeLists.txt | 1 + .../memory_manager/allocation_properties.h | 3 +- runtime/memory_manager/graphics_allocation.h | 15 +++-- .../graphics_allocation_extra.cpp | 17 +++++ ...nqueue_with_timestamp_packet_aub_tests.cpp | 2 +- .../enqueue_command_without_kernel_tests.cpp | 2 +- .../enqueue_unmap_memobject_tests.cpp | 8 +-- .../aub_command_stream_receiver_1_tests.cpp | 43 ++++++++----- .../aub_command_stream_receiver_2_tests.cpp | 2 +- .../tbx_command_stream_tests.cpp | 8 +-- unit_tests/context/CMakeLists.txt | 3 +- .../context_extra_properties_tests.cpp | 19 ++++++ unit_tests/helpers/bit_helpers_tests.cpp | 64 +++++++++++++++++++ unit_tests/libult/CMakeLists.txt | 11 ++-- unit_tests/libult/create_command_stream.cpp | 19 +++--- .../libult/ult_aub_command_stream_receiver.h | 48 ++++++++++++++ unit_tests/mem_obj/buffer_tests.cpp | 7 ++ unit_tests/mocks/mock_aub_csr.h | 1 + unit_tests/mocks/mock_device.h | 1 + unit_tests/mocks/mock_execution_environment.h | 9 +-- unit_tests/mocks/mock_graphics_allocation.h | 1 + .../windows/driver_info_tests.cpp | 2 +- unit_tests/platform/platform_tests.cpp | 2 +- 36 files changed, 290 insertions(+), 76 deletions(-) create mode 100644 runtime/memory_manager/graphics_allocation_extra.cpp create mode 100644 unit_tests/context/context_extra_properties_tests.cpp create mode 100644 unit_tests/libult/ult_aub_command_stream_receiver.h diff --git a/common/helpers/bit_helpers.h b/common/helpers/bit_helpers.h index 595530e3bb..c02b317c6a 100644 --- a/common/helpers/bit_helpers.h +++ b/common/helpers/bit_helpers.h @@ -17,6 +17,10 @@ constexpr bool isBitSet(uint64_t field, uint64_t bitPosition) { return (field & (1ull << bitPosition)); } +constexpr bool isAnyBitSet(uint64_t field, uint64_t checkedBits) { + return ((field & checkedBits) != 0); +} + constexpr bool isValueSet(uint64_t field, uint64_t value) { assert(value != 0); return ((field & value) == value); @@ -26,4 +30,11 @@ constexpr bool isFieldValid(uint64_t field, uint64_t acceptedBits) { return ((field & (~acceptedBits)) == 0); } +constexpr uint64_t setBits(uint64_t field, bool newValue, uint64_t bitsToModify) { + if (newValue) { + return (field | bitsToModify); + } + return (field & (~bitsToModify)); +} + } // namespace NEO diff --git a/runtime/command_queue/cpu_data_transfer_handler.cpp b/runtime/command_queue/cpu_data_transfer_handler.cpp index d00adbd6d8..dbb2ad3724 100644 --- a/runtime/command_queue/cpu_data_transfer_handler.cpp +++ b/runtime/command_queue/cpu_data_transfer_handler.cpp @@ -124,8 +124,8 @@ void *CommandQueue::cpuDataTransferHandler(TransferProperties &transferPropertie } if (!unmapInfo.readOnly) { auto graphicsAllocation = transferProperties.memObj->getGraphicsAllocation(); - graphicsAllocation->setAubWritable(true); - graphicsAllocation->setTbxWritable(true); + graphicsAllocation->setAubWritable(true, GraphicsAllocation::defaultBank); + graphicsAllocation->setTbxWritable(true, GraphicsAllocation::defaultBank); } break; case CL_COMMAND_READ_BUFFER: diff --git a/runtime/command_stream/aub_command_stream_receiver_hw_base.inl b/runtime/command_stream/aub_command_stream_receiver_hw_base.inl index 780f0f8df5..ac6737292d 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw_base.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw_base.inl @@ -624,7 +624,7 @@ void AUBCommandStreamReceiverHw::writeMemory(uint64_t gpuAddress, voi template bool AUBCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxAllocation) { - if (!gfxAllocation.isAubWritable()) { + if (!this->isAubWritable(gfxAllocation)) { return false; } @@ -651,7 +651,7 @@ bool AUBCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxA } if (AubHelper::isOneTimeAubWritableAllocationType(gfxAllocation.getAllocationType())) { - gfxAllocation.setAubWritable(false); + this->setAubWritable(false, gfxAllocation); } return true; @@ -714,10 +714,11 @@ void AUBCommandStreamReceiverHw::processResidency(ResidencyContainer for (auto &gfxAllocation : allocationsForResidency) { if (dumpAubNonWritable) { - gfxAllocation->setAubWritable(true); + this->setAubWritable(true, *gfxAllocation); } if (!writeMemory(*gfxAllocation)) { - DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || !gfxAllocation->isAubWritable())); + DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || + !this->isAubWritable(*gfxAllocation))); } gfxAllocation->updateResidencyTaskCount(this->taskCount + 1, this->osContext->getContextId()); } diff --git a/runtime/command_stream/command_stream_receiver_simulated_common_hw.h b/runtime/command_stream/command_stream_receiver_simulated_common_hw.h index dd1fab0774..6ac187a02d 100644 --- a/runtime/command_stream/command_stream_receiver_simulated_common_hw.h +++ b/runtime/command_stream/command_stream_receiver_simulated_common_hw.h @@ -54,6 +54,11 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw CommandStreamReceiverWithAUBDump::CommandStreamReceiverWithAUBDump(const std::string &baseName, ExecutionEnvironment &executionEnvironment) diff --git a/runtime/command_stream/create_command_stream_impl.cpp b/runtime/command_stream/create_command_stream_impl.cpp index 1f326edfa0..51de164369 100644 --- a/runtime/command_stream/create_command_stream_impl.cpp +++ b/runtime/command_stream/create_command_stream_impl.cpp @@ -15,7 +15,7 @@ namespace NEO { -extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE]; +extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[IGFX_MAX_CORE]; CommandStreamReceiver *createCommandStreamImpl(ExecutionEnvironment &executionEnvironment) { auto funcCreate = commandStreamReceiverFactory[executionEnvironment.getHardwareInfo()->platform.eRenderCoreFamily]; diff --git a/runtime/command_stream/definitions/command_stream_receiver_simulated_hw.h b/runtime/command_stream/definitions/command_stream_receiver_simulated_hw.h index df3c4134bc..478553fee4 100644 --- a/runtime/command_stream/definitions/command_stream_receiver_simulated_hw.h +++ b/runtime/command_stream/definitions/command_stream_receiver_simulated_hw.h @@ -29,5 +29,18 @@ class CommandStreamReceiverSimulatedHw : public CommandStreamReceiverSimulatedCo return new PhysicalAddressAllocator(); } void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation) override{}; + + void setAubWritable(bool writable, GraphicsAllocation &graphicsAllocation) override { + graphicsAllocation.setAubWritable(writable, getMemoryBank(&graphicsAllocation)); + } + bool isAubWritable(GraphicsAllocation &graphicsAllocation) const override { + return graphicsAllocation.isAubWritable(getMemoryBank(&graphicsAllocation)); + } + void setTbxWritable(bool writable, GraphicsAllocation &graphicsAllocation) override { + graphicsAllocation.setTbxWritable(writable, getMemoryBank(&graphicsAllocation)); + } + bool isTbxWritable(GraphicsAllocation &graphicsAllocation) const override { + return graphicsAllocation.isTbxWritable(getMemoryBank(&graphicsAllocation)); + } }; } // namespace NEO diff --git a/runtime/command_stream/tbx_command_stream_receiver_hw.inl b/runtime/command_stream/tbx_command_stream_receiver_hw.inl index 7cc36e4d88..bd2c1a6c46 100644 --- a/runtime/command_stream/tbx_command_stream_receiver_hw.inl +++ b/runtime/command_stream/tbx_command_stream_receiver_hw.inl @@ -363,7 +363,7 @@ void TbxCommandStreamReceiverHw::writeMemory(uint64_t gpuAddress, voi template bool TbxCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxAllocation) { - if (!gfxAllocation.isTbxWritable()) { + if (!this->isTbxWritable(gfxAllocation)) { return false; } @@ -381,7 +381,7 @@ bool TbxCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxA } if (AubHelper::isOneTimeAubWritableAllocationType(gfxAllocation.getAllocationType())) { - gfxAllocation.setTbxWritable(false); + this->setTbxWritable(false, gfxAllocation); } return true; @@ -413,7 +413,8 @@ template void TbxCommandStreamReceiverHw::processResidency(ResidencyContainer &allocationsForResidency) { for (auto &gfxAllocation : allocationsForResidency) { if (!writeMemory(*gfxAllocation)) { - DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || !gfxAllocation->isTbxWritable())); + DEBUG_BREAK_IF(!((gfxAllocation->getUnderlyingBufferSize() == 0) || + !this->isTbxWritable(*gfxAllocation))); } gfxAllocation->updateResidencyTaskCount(this->taskCount + 1, this->osContext->getContextId()); } diff --git a/runtime/context/context.h b/runtime/context/context.h index 32b76c0374..d3ce432a37 100644 --- a/runtime/context/context.h +++ b/runtime/context/context.h @@ -25,6 +25,12 @@ class MemoryManager; class SharingFunctions; class SVMAllocsManager; +enum class BlitOperationResult { + Unsupported, + Fail, + Success +}; + template <> struct OpenCLObjectMapper<_cl_context> { typedef class Context DerivedType; @@ -127,6 +133,7 @@ class Context : public BaseObject<_cl_context> { ContextType peekContextType() { return this->contextType; } MOCKABLE_VIRTUAL CommandStreamReceiver *getCommandStreamReceiverForBlitOperation(MemObj &memObj) const; + MOCKABLE_VIRTUAL BlitOperationResult blitMemoryToAllocation(MemObj &memObj, GraphicsAllocation *memory, void *hostPtr, size_t size) const; protected: Context(void(CL_CALLBACK *pfnNotify)(const char *, const void *, size_t, void *) = nullptr, diff --git a/runtime/context/context_extra.cpp b/runtime/context/context_extra.cpp index 9c71c08828..4091a33c0e 100644 --- a/runtime/context/context_extra.cpp +++ b/runtime/context/context_extra.cpp @@ -18,4 +18,8 @@ cl_int Context::processExtraProperties(cl_context_properties propertyType, cl_co CommandStreamReceiver *Context::getCommandStreamReceiverForBlitOperation(MemObj &memObj) const { return nullptr; } + +BlitOperationResult Context::blitMemoryToAllocation(MemObj &memObj, GraphicsAllocation *memory, void *hostPtr, size_t size) const { + return BlitOperationResult::Unsupported; +} } // namespace NEO diff --git a/runtime/gen9/command_stream_receiver_hw_gen9.cpp b/runtime/gen9/command_stream_receiver_hw_gen9.cpp index 6e77056d24..e83337432d 100644 --- a/runtime/gen9/command_stream_receiver_hw_gen9.cpp +++ b/runtime/gen9/command_stream_receiver_hw_gen9.cpp @@ -27,7 +27,7 @@ void CommandStreamReceiverHw::programComputeMode(LinearStream &stream, D template <> void populateFactoryTable>() { - extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE]; + extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[IGFX_MAX_CORE]; commandStreamReceiverFactory[gfxCore] = DeviceCommandStreamReceiver::create; } diff --git a/runtime/helpers/flat_batch_buffer_helper_hw.inl b/runtime/helpers/flat_batch_buffer_helper_hw.inl index b9bc0ffdf3..cbb531e379 100644 --- a/runtime/helpers/flat_batch_buffer_helper_hw.inl +++ b/runtime/helpers/flat_batch_buffer_helper_hw.inl @@ -28,7 +28,7 @@ GraphicsAllocation *FlatBatchBufferHelperHw::flattenBatchBuffer(Batch if (dispatchMode == DispatchMode::ImmediateDispatch) { if (batchBuffer.chainedBatchBuffer) { - batchBuffer.chainedBatchBuffer->setAubWritable(false); + batchBuffer.chainedBatchBuffer->setAubWritable(false, GraphicsAllocation::defaultBank); auto sizeMainBatchBuffer = batchBuffer.chainedBatchBufferStartOffset - batchBuffer.startOffset; auto alignedMainBatchBufferSize = alignUp(sizeMainBatchBuffer + indirectPatchCommandsSize + batchBuffer.chainedBatchBuffer->getUnderlyingBufferSize(), MemoryConstants::pageSize); AllocationProperties flatBatchBufferProperties(alignedMainBatchBufferSize, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY); diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index b89a9e4913..76f97e24fc 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -292,13 +292,9 @@ Buffer *Buffer::create(Context *context, bool gpuCopyRequired = (gmm && gmm->isRenderCompressed) || !MemoryPool::isSystemMemoryPool(memory->getMemoryPool()); if (gpuCopyRequired) { - auto blitCommandStreamReceiver = context->getCommandStreamReceiverForBlitOperation(*pBuffer); - if (blitCommandStreamReceiver) { - auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer, - *blitCommandStreamReceiver, memory, - hostPtr, true, 0, size); - blitCommandStreamReceiver->blitBuffer(blitProperties); - } else { + auto blitMemoryToAllocationResult = context->blitMemoryToAllocation(*pBuffer, memory, hostPtr, size); + + if (blitMemoryToAllocationResult != BlitOperationResult::Success) { auto cmdQ = context->getSpecialQueue(); if (CL_SUCCESS != cmdQ->enqueueWriteBuffer(pBuffer, CL_TRUE, 0, size, hostPtr, nullptr, 0, nullptr, nullptr)) { errcodeRet = CL_OUT_OF_RESOURCES; diff --git a/runtime/memory_manager/CMakeLists.txt b/runtime/memory_manager/CMakeLists.txt index 1fd11ba355..643d149ec1 100644 --- a/runtime/memory_manager/CMakeLists.txt +++ b/runtime/memory_manager/CMakeLists.txt @@ -22,6 +22,7 @@ set(RUNTIME_SRCS_MEMORY_MANAGER ${CMAKE_CURRENT_SOURCE_DIR}/gfx_partition.h ${CMAKE_CURRENT_SOURCE_DIR}/graphics_allocation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/graphics_allocation.h + ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/graphics_allocation_extra.cpp ${CMAKE_CURRENT_SOURCE_DIR}/host_ptr_defines.h ${CMAKE_CURRENT_SOURCE_DIR}/host_ptr_manager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/host_ptr_manager.h diff --git a/runtime/memory_manager/allocation_properties.h b/runtime/memory_manager/allocation_properties.h index b955d7ef57..bf57e2d0b3 100644 --- a/runtime/memory_manager/allocation_properties.h +++ b/runtime/memory_manager/allocation_properties.h @@ -20,7 +20,8 @@ struct AllocationProperties { uint32_t forcePin : 1; uint32_t uncacheable : 1; uint32_t multiOsContextCapable : 1; - uint32_t reserved : 26; + uint32_t readOnlyMultiStorage : 1; + uint32_t reserved : 25; } flags; uint32_t allFlags = 0; }; diff --git a/runtime/memory_manager/graphics_allocation.h b/runtime/memory_manager/graphics_allocation.h index 2b4f89bbb1..09c54a7cba 100644 --- a/runtime/memory_manager/graphics_allocation.h +++ b/runtime/memory_manager/graphics_allocation.h @@ -10,6 +10,7 @@ #include "core/helpers/ptr_math.h" #include "runtime/helpers/debug_helpers.h" #include "runtime/memory_manager/host_ptr_defines.h" +#include "runtime/memory_manager/memory_constants.h" #include "runtime/memory_manager/memory_pool.h" #include "runtime/utilities/idlist.h" @@ -130,10 +131,10 @@ class GraphicsAllocation : public IDNode { bool is32BitAllocation() const { return allocationInfo.flags.is32BitAllocation; } void set32BitAllocation(bool is32BitAllocation) { allocationInfo.flags.is32BitAllocation = is32BitAllocation; } - void setAubWritable(bool writable) { aubInfo.aubWritable = writable; } - bool isAubWritable() const { return aubInfo.aubWritable; } - void setTbxWritable(bool writable) { aubInfo.tbxWritable = writable; } - bool isTbxWritable() const { return aubInfo.tbxWritable; } + void setAubWritable(bool writable, uint32_t banks); + bool isAubWritable(uint32_t banks) const; + void setTbxWritable(bool writable, uint32_t banks); + bool isTbxWritable(uint32_t banks) const; void setAllocDumpable(bool dumpable) { aubInfo.allocDumpable = dumpable; } bool isAllocDumpable() const { return aubInfo.allocDumpable; } bool isMemObjectsAllocationWithWritableFlags() const { return aubInfo.memObjectsAllocationWithWritableFlags; } @@ -205,6 +206,8 @@ class GraphicsAllocation : public IDNode { OsHandleStorage fragmentsStorage; StorageInfo storageInfo = {}; + static constexpr uint32_t defaultBank = 0b1u; + protected: constexpr static uint32_t objectNotResident = std::numeric_limits::max(); constexpr static uint32_t objectNotUsed = std::numeric_limits::max(); @@ -215,8 +218,8 @@ class GraphicsAllocation : public IDNode { uint32_t inspectionId = 0u; }; struct AubInfo { - bool aubWritable = true; - bool tbxWritable = true; + uint32_t aubWritable = maxNBitValue<32>; + uint32_t tbxWritable = maxNBitValue<32>; bool allocDumpable = false; bool memObjectsAllocationWithWritableFlags = false; }; diff --git a/runtime/memory_manager/graphics_allocation_extra.cpp b/runtime/memory_manager/graphics_allocation_extra.cpp new file mode 100644 index 0000000000..b6d7e5f0b7 --- /dev/null +++ b/runtime/memory_manager/graphics_allocation_extra.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/memory_manager/graphics_allocation.h" + +namespace NEO { + +void GraphicsAllocation::setAubWritable(bool writable, uint32_t banks) { aubInfo.aubWritable = writable; } +bool GraphicsAllocation::isAubWritable(uint32_t banks) const { return (aubInfo.aubWritable != 0); } +void GraphicsAllocation::setTbxWritable(bool writable, uint32_t banks) { aubInfo.tbxWritable = writable; } +bool GraphicsAllocation::isTbxWritable(uint32_t banks) const { return (aubInfo.tbxWritable != 0); } + +} // namespace NEO diff --git a/unit_tests/aub_tests/command_queue/enqueue_with_timestamp_packet_aub_tests.cpp b/unit_tests/aub_tests/command_queue/enqueue_with_timestamp_packet_aub_tests.cpp index 183d39840d..0d59e282cf 100644 --- a/unit_tests/aub_tests/command_queue/enqueue_with_timestamp_packet_aub_tests.cpp +++ b/unit_tests/aub_tests/command_queue/enqueue_with_timestamp_packet_aub_tests.cpp @@ -46,7 +46,7 @@ HWTEST_F(TimestampPacketAubTests, givenTwoBatchedEnqueuesWhenDependencyIsResolve pCmdQ->enqueueWriteBuffer(buffer.get(), CL_FALSE, 0, bufferSize, writePattern1, nullptr, 0, nullptr, &outEvent1); auto node1 = castToObject(outEvent1)->getTimestampPacketNodes()->peekNodes().at(0); - node1->getBaseGraphicsAllocation()->setAubWritable(true); // allow to write again after Buffer::create + node1->getBaseGraphicsAllocation()->setAubWritable(true, GraphicsAllocation::defaultBank); // allow to write again after Buffer::create pCmdQ->enqueueWriteBuffer(buffer.get(), CL_TRUE, 0, bufferSize, writePattern2, nullptr, 0, nullptr, &outEvent2); auto node2 = castToObject(outEvent2)->getTimestampPacketNodes()->peekNodes().at(0); diff --git a/unit_tests/command_queue/enqueue_command_without_kernel_tests.cpp b/unit_tests/command_queue/enqueue_command_without_kernel_tests.cpp index d4635ba69e..83d81f281e 100644 --- a/unit_tests/command_queue/enqueue_command_without_kernel_tests.cpp +++ b/unit_tests/command_queue/enqueue_command_without_kernel_tests.cpp @@ -50,7 +50,7 @@ HWTEST_F(EnqueueHandlerTest, GivenCommandStreamWithoutKernelWhenCommandEnqueuedT struct DispatchFlagsTests : public ::testing::Test { template void SetUpImpl() { - auto executionEnvironment = new MockExecutionEnvironmentWithCsr(**platformDevices); + auto executionEnvironment = new MockExecutionEnvironmentWithCsr(**platformDevices, 1u); device.reset(MockDevice::createWithExecutionEnvironment(*platformDevices, executionEnvironment, 0)); context = std::make_unique(device.get()); } diff --git a/unit_tests/command_queue/enqueue_unmap_memobject_tests.cpp b/unit_tests/command_queue/enqueue_unmap_memobject_tests.cpp index 48f818d1e3..a9ff864b09 100644 --- a/unit_tests/command_queue/enqueue_unmap_memobject_tests.cpp +++ b/unit_tests/command_queue/enqueue_unmap_memobject_tests.cpp @@ -193,8 +193,8 @@ TEST_F(EnqueueUnmapMemObjTest, UnmapMemObjWaitEvent) { HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBufferObjectMappedToHostPtrForWritingThenItShouldBeResetToAubAndTbxWritable) { auto buffer = std::unique_ptr(BufferHelper<>::create()); ASSERT_NE(nullptr, buffer); - buffer->getGraphicsAllocation()->setAubWritable(false); - buffer->getGraphicsAllocation()->setTbxWritable(false); + buffer->getGraphicsAllocation()->setAubWritable(false, GraphicsAllocation::defaultBank); + buffer->getGraphicsAllocation()->setTbxWritable(false, GraphicsAllocation::defaultBank); auto mappedForWritingPtr = pCmdQ->enqueueMapBuffer(buffer.get(), CL_TRUE, CL_MAP_WRITE, 0, 8, 0, nullptr, nullptr, retVal); ASSERT_NE(nullptr, mappedForWritingPtr); @@ -207,6 +207,6 @@ HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBuf nullptr); ASSERT_EQ(CL_SUCCESS, retVal); - EXPECT_TRUE(buffer->getGraphicsAllocation()->isAubWritable()); - EXPECT_TRUE(buffer->getGraphicsAllocation()->isTbxWritable()); + EXPECT_TRUE(buffer->getGraphicsAllocation()->isAubWritable(GraphicsAllocation::defaultBank)); + EXPECT_TRUE(buffer->getGraphicsAllocation()->isTbxWritable(GraphicsAllocation::defaultBank)); } diff --git a/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp index 343e9253f8..d4a5b50b85 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp @@ -15,6 +15,7 @@ #include "unit_tests/fixtures/aub_command_stream_receiver_fixture.h" #include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/fixtures/mock_aub_center_fixture.h" +#include "unit_tests/libult/ult_aub_command_stream_receiver.h" #include "unit_tests/mocks/mock_aub_center.h" #include "unit_tests/mocks/mock_aub_csr.h" #include "unit_tests/mocks/mock_aub_manager.h" @@ -693,7 +694,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - EXPECT_TRUE(gfxAllocation->isAubWritable()); + EXPECT_TRUE(gfxAllocation->isAubWritable(GraphicsAllocation::defaultBank)); memoryManager->freeGraphicsMemory(gfxAllocation); } @@ -708,7 +709,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess ResidencyContainer allocationsForResidency = {gfxDefaultAllocation}; aubCsr->processResidency(allocationsForResidency); - EXPECT_TRUE(gfxDefaultAllocation->isAubWritable()); + EXPECT_TRUE(aubCsr->isAubWritable(*gfxDefaultAllocation)); memoryManager->freeGraphicsMemory(gfxDefaultAllocation); } @@ -730,11 +731,11 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER}; for (auto allocationType : onlyOneTimeAubWritableTypes) { - gfxAllocation->setAubWritable(true); + gfxAllocation->setAubWritable(true, GraphicsAllocation::defaultBank); gfxAllocation->setAllocationType(allocationType); aubCsr->writeMemory(*gfxAllocation); - EXPECT_FALSE(gfxAllocation->isAubWritable()); + EXPECT_FALSE(aubCsr->isAubWritable(*gfxAllocation)); } memoryManager->freeGraphicsMemory(gfxAllocation); } @@ -752,8 +753,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation}; aubCsr->processResidency(allocationsForResidency); - EXPECT_FALSE(gfxBufferAllocation->isAubWritable()); - EXPECT_FALSE(gfxImageAllocation->isAubWritable()); + EXPECT_FALSE(aubCsr->isAubWritable(*gfxBufferAllocation)); + EXPECT_FALSE(aubCsr->isAubWritable(*gfxImageAllocation)); memoryManager->freeGraphicsMemory(gfxBufferAllocation); memoryManager->freeGraphicsMemory(gfxImageAllocation); @@ -767,18 +768,18 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur aubCsr->setupContext(*pDevice->getDefaultEngine().osContext); auto gfxBufferAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER}); - gfxBufferAllocation->setAubWritable(false); + aubCsr->setAubWritable(false, *gfxBufferAllocation); auto gfxImageAllocation = MockGmm::allocateImage2d(*memoryManager); - gfxImageAllocation->setAubWritable(false); + aubCsr->setAubWritable(false, *gfxImageAllocation); aubCsr->dumpAubNonWritable = true; ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation}; aubCsr->processResidency(allocationsForResidency); - EXPECT_TRUE(gfxBufferAllocation->isAubWritable()); - EXPECT_TRUE(gfxImageAllocation->isAubWritable()); + EXPECT_TRUE(aubCsr->isAubWritable(*gfxBufferAllocation)); + EXPECT_TRUE(aubCsr->isAubWritable(*gfxImageAllocation)); memoryManager->freeGraphicsMemory(gfxBufferAllocation); memoryManager->freeGraphicsMemory(gfxImageAllocation); @@ -792,18 +793,18 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess aubCsr->setupContext(*pDevice->getDefaultEngine().osContext); auto gfxBufferAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER}); - gfxBufferAllocation->setAubWritable(false); + aubCsr->setAubWritable(false, *gfxBufferAllocation); auto gfxImageAllocation = MockGmm::allocateImage2d(*memoryManager); - gfxImageAllocation->setAubWritable(false); + aubCsr->setAubWritable(false, *gfxImageAllocation); aubCsr->dumpAubNonWritable = false; ResidencyContainer allocationsForResidency = {gfxBufferAllocation, gfxImageAllocation}; aubCsr->processResidency(allocationsForResidency); - EXPECT_FALSE(gfxBufferAllocation->isAubWritable()); - EXPECT_FALSE(gfxImageAllocation->isAubWritable()); + EXPECT_FALSE(aubCsr->isAubWritable(*gfxBufferAllocation)); + EXPECT_FALSE(aubCsr->isAubWritable(*gfxImageAllocation)); memoryManager->freeGraphicsMemory(gfxBufferAllocation); memoryManager->freeGraphicsMemory(gfxImageAllocation); @@ -838,7 +839,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - gfxAllocation->setAubWritable(false); + aubCsr->setAubWritable(false, *gfxAllocation); EXPECT_FALSE(aubCsr->writeMemory(*gfxAllocation)); memoryManager->freeGraphicsMemory(gfxAllocation); @@ -1144,6 +1145,18 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon EXPECT_FALSE(aubCsr->initProgrammingFlagsCalled); } +HWTEST_F(AubCommandStreamReceiverTests, WhenBlitBufferIsCalledThenCounterIsCorrectlyIncremented) { + auto aubExecutionEnvironment = getEnvironment>(true, true, true); + auto aubCsr = aubExecutionEnvironment->template getCsr>(); + aubCsr->osContext->getEngineType() = aub_stream::ENGINE_BCS; + EXPECT_EQ(0u, aubCsr->blitBufferCalled); + + MockGraphicsAllocation allocation(reinterpret_cast(0x1000), 0); + BlitProperties blitProperties = BlitProperties::constructPropertiesForCopyBuffer(&allocation, &allocation, true, 0, 0, 0); + aubCsr->blitBuffer(blitProperties); + EXPECT_EQ(1u, aubCsr->blitBufferCalled); +} + using HardwareContextContainerTests = ::testing::Test; TEST_F(HardwareContextContainerTests, givenOsContextWithMultipleDevicesSupportedThenInitialzeHwContextsWithValidIndexes) { diff --git a/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp index 2ba03ae1ad..75e46406b8 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp @@ -664,7 +664,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe aubCsr->ppgtt.reset(ppgttMock); auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - gfxAllocation->setAubWritable(true); + aubCsr->setAubWritable(true, *gfxAllocation); auto gmm = new Gmm(nullptr, 1, false); gfxAllocation->setDefaultGmm(gmm); diff --git a/unit_tests/command_stream/tbx_command_stream_tests.cpp b/unit_tests/command_stream/tbx_command_stream_tests.cpp index b877d7117a..7008c88969 100644 --- a/unit_tests/command_stream/tbx_command_stream_tests.cpp +++ b/unit_tests/command_stream/tbx_command_stream_tests.cpp @@ -217,9 +217,9 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenWriteMemoryIsCa auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER}); ASSERT_NE(nullptr, graphicsAllocation); - EXPECT_TRUE(graphicsAllocation->isTbxWritable()); + EXPECT_TRUE(tbxCsr->isTbxWritable(*graphicsAllocation)); EXPECT_TRUE(tbxCsr->writeMemory(*graphicsAllocation)); - EXPECT_FALSE(graphicsAllocation->isTbxWritable()); + EXPECT_FALSE(tbxCsr->isTbxWritable(*graphicsAllocation)); memoryManager->freeGraphicsMemory(graphicsAllocation); } @@ -232,9 +232,9 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenWriteMemoryIsCa auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize, GraphicsAllocation::AllocationType::BUFFER}); ASSERT_NE(nullptr, graphicsAllocation); - graphicsAllocation->setTbxWritable(false); + tbxCsr->setTbxWritable(false, *graphicsAllocation); EXPECT_FALSE(tbxCsr->writeMemory(*graphicsAllocation)); - EXPECT_FALSE(graphicsAllocation->isTbxWritable()); + EXPECT_FALSE(tbxCsr->isTbxWritable(*graphicsAllocation)); memoryManager->freeGraphicsMemory(graphicsAllocation); } diff --git a/unit_tests/context/CMakeLists.txt b/unit_tests/context/CMakeLists.txt index 5471329e5f..13eac3268d 100644 --- a/unit_tests/context/CMakeLists.txt +++ b/unit_tests/context/CMakeLists.txt @@ -1,11 +1,12 @@ # -# Copyright (C) 2017-2018 Intel Corporation +# Copyright (C) 2017-2019 Intel Corporation # # SPDX-License-Identifier: MIT # set(IGDRCL_SRCS_tests_context ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/context_extra_properties_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/context_get_info_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/context_multi_device_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/context_negative_tests.cpp diff --git a/unit_tests/context/context_extra_properties_tests.cpp b/unit_tests/context/context_extra_properties_tests.cpp new file mode 100644 index 0000000000..180f6dde92 --- /dev/null +++ b/unit_tests/context/context_extra_properties_tests.cpp @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "test.h" +#include "unit_tests/mocks/mock_buffer.h" +#include "unit_tests/mocks/mock_context.h" + +using namespace NEO; + +TEST(ContextExtraPropertiesTests, givenAnyBufferWhenGettingCsrForBlitOperationThenNullIsReturned) { + MockContext context; + MockBuffer buffer; + auto csr = context.getCommandStreamReceiverForBlitOperation(buffer); + EXPECT_EQ(nullptr, csr); +} diff --git a/unit_tests/helpers/bit_helpers_tests.cpp b/unit_tests/helpers/bit_helpers_tests.cpp index 2e88d9b332..ed2b9955ef 100644 --- a/unit_tests/helpers/bit_helpers_tests.cpp +++ b/unit_tests/helpers/bit_helpers_tests.cpp @@ -38,6 +38,50 @@ TEST(IsBitSetTests, givenDifferentValuesWhenTestingIsBitSetThenCorrectValueIsRet EXPECT_TRUE(isBitSet(field4, 3)); } +TEST(IsAnyBitSetTests, givenDifferentValuesWhenTestingIsAnyBitSetThenCorrectValueIsReturned) { + EXPECT_FALSE(isAnyBitSet(0, 0)); + EXPECT_FALSE(isAnyBitSet(0, 0b1)); + EXPECT_FALSE(isAnyBitSet(0, 0b10)); + EXPECT_FALSE(isAnyBitSet(0, 0b1000)); + EXPECT_FALSE(isAnyBitSet(0, 0b1010)); + EXPECT_FALSE(isAnyBitSet(0, 0b1111)); + + EXPECT_FALSE(isAnyBitSet(0b1, 0)); + EXPECT_TRUE(isAnyBitSet(0b1, 0b1)); + EXPECT_FALSE(isAnyBitSet(0b1, 0b10)); + EXPECT_FALSE(isAnyBitSet(0b1, 0b1000)); + EXPECT_FALSE(isAnyBitSet(0b1, 0b1010)); + EXPECT_TRUE(isAnyBitSet(0b1, 0b1111)); + + EXPECT_FALSE(isAnyBitSet(0b10, 0)); + EXPECT_FALSE(isAnyBitSet(0b10, 0b1)); + EXPECT_TRUE(isAnyBitSet(0b10, 0b10)); + EXPECT_FALSE(isAnyBitSet(0b10, 0b1000)); + EXPECT_TRUE(isAnyBitSet(0b10, 0b1010)); + EXPECT_TRUE(isAnyBitSet(0b10, 0b1111)); + + EXPECT_FALSE(isAnyBitSet(0b1000, 0)); + EXPECT_FALSE(isAnyBitSet(0b1000, 0b1)); + EXPECT_FALSE(isAnyBitSet(0b1000, 0b10)); + EXPECT_TRUE(isAnyBitSet(0b1000, 0b1000)); + EXPECT_TRUE(isAnyBitSet(0b1000, 0b1010)); + EXPECT_TRUE(isAnyBitSet(0b1000, 0b1111)); + + EXPECT_FALSE(isAnyBitSet(0b1010, 0)); + EXPECT_FALSE(isAnyBitSet(0b1010, 0b1)); + EXPECT_TRUE(isAnyBitSet(0b1010, 0b10)); + EXPECT_TRUE(isAnyBitSet(0b1010, 0b1000)); + EXPECT_TRUE(isAnyBitSet(0b1010, 0b1010)); + EXPECT_TRUE(isAnyBitSet(0b1010, 0b1111)); + + EXPECT_FALSE(isAnyBitSet(0b1111, 0)); + EXPECT_TRUE(isAnyBitSet(0b1111, 0b1)); + EXPECT_TRUE(isAnyBitSet(0b1111, 0b10)); + EXPECT_TRUE(isAnyBitSet(0b1111, 0b1000)); + EXPECT_TRUE(isAnyBitSet(0b1111, 0b1010)); + EXPECT_TRUE(isAnyBitSet(0b1111, 0b1111)); +} + TEST(IsValueSetTests, givenDifferentValuesWhenTestingIsValueSetThenCorrectValueIsReturned) { size_t field1 = 0; size_t field2 = 0b1; @@ -133,3 +177,23 @@ TEST(IsFieldValidTests, givenDifferentValuesWhenTestingIsFieldValidThenCorrectVa EXPECT_FALSE(isFieldValid(field6, field5)); EXPECT_TRUE(isFieldValid(field6, field6)); } + +TEST(SetBitsTests, givenDifferentValuesWhenTestingSetBitsThenCorrectValueIsReturned) { + EXPECT_EQ(0b0u, setBits(0b0, false, 0b0)); + EXPECT_EQ(0b0u, setBits(0b0, false, 0b1)); + EXPECT_EQ(0b1u, setBits(0b1, false, 0b0)); + EXPECT_EQ(0b0u, setBits(0b1, false, 0b1)); + + EXPECT_EQ(0b0u, setBits(0b0, true, 0b0)); + EXPECT_EQ(0b1u, setBits(0b0, true, 0b1)); + EXPECT_EQ(0b1u, setBits(0b1, true, 0b0)); + EXPECT_EQ(0b1u, setBits(0b1, true, 0b1)); + + EXPECT_EQ(0b1010u, setBits(0b1010, false, 0b101)); + EXPECT_EQ(0b1111u, setBits(0b1010, true, 0b101)); + EXPECT_EQ(0b101u, setBits(0b101, false, 0b1010)); + EXPECT_EQ(0b1111u, setBits(0b101, true, 0b1010)); + + EXPECT_EQ(0b0u, setBits(0b1010, false, 0b1010)); + EXPECT_EQ(0b1010u, setBits(0b1010, true, 0b1010)); +} diff --git a/unit_tests/libult/CMakeLists.txt b/unit_tests/libult/CMakeLists.txt index 7af108a62b..6a196db537 100644 --- a/unit_tests/libult/CMakeLists.txt +++ b/unit_tests/libult/CMakeLists.txt @@ -20,24 +20,23 @@ set(IGDRCL_SRCS_LIB_ULT ${IGDRCL_SOURCE_DIR}/core/unit_tests/utilities/clflush.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/abort.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/helpers/built_ins_helper.cpp + ${IGDRCL_SOURCE_DIR}/unit_tests/helpers/debug_helpers.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/helpers/execution_environment_helper.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/helpers/execution_environment_helper.h - ${IGDRCL_SOURCE_DIR}/unit_tests/libult/create_tbx_sockets.cpp - ${IGDRCL_SOURCE_DIR}/unit_tests/libult/ult_command_stream_receiver.h - ${IGDRCL_SOURCE_DIR}/unit_tests/helpers/debug_helpers.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/helpers/test_files.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/helpers/test_files.h ${IGDRCL_SOURCE_DIR}/unit_tests/libult/create_tbx_sockets.cpp - ${IGDRCL_SOURCE_DIR}/unit_tests/libult/ult_command_stream_receiver.h ${IGDRCL_SOURCE_DIR}/unit_tests/libult/source_level_debugger.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/libult/source_level_debugger_library.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/libult/source_level_debugger_library.h + ${IGDRCL_SOURCE_DIR}/unit_tests/libult/ult_aub_command_stream_receiver.h + ${IGDRCL_SOURCE_DIR}/unit_tests/libult/ult_command_stream_receiver.h ${IGDRCL_SOURCE_DIR}/unit_tests/program/evaluate_unhandled_token_ult.cpp ${IGDRCL_SOURCE_DIR}/unit_tests/utilities/debug_settings_reader_creator.cpp - ${NEO_CORE_DIRECTORY}/unit_tests/helpers/memory_management.h - ${NEO_CORE_DIRECTORY}/unit_tests/helpers/memory_management.cpp ${NEO_CORE_DIRECTORY}/unit_tests/helpers/memory_leak_listener.cpp ${NEO_CORE_DIRECTORY}/unit_tests/helpers/memory_leak_listener.h + ${NEO_CORE_DIRECTORY}/unit_tests/helpers/memory_management.cpp + ${NEO_CORE_DIRECTORY}/unit_tests/helpers/memory_management.h ) set(IGDRCL_SRCS_LIB_ULT_WINDOWS diff --git a/unit_tests/libult/create_command_stream.cpp b/unit_tests/libult/create_command_stream.cpp index 86a9ded4b9..04cdba0c6b 100644 --- a/unit_tests/libult/create_command_stream.cpp +++ b/unit_tests/libult/create_command_stream.cpp @@ -23,18 +23,17 @@ bool overrideCommandStreamReceiverCreation = false; bool overrideDeviceWithDefaultHardwareInfo = true; CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executionEnvironment) { - CommandStreamReceiver *commandStreamReceiver = nullptr; auto hwInfo = executionEnvironment.getHardwareInfo(); - auto offset = !overrideCommandStreamReceiverCreation ? IGFX_MAX_CORE : 0; - if (offset != 0) { - auto funcCreate = commandStreamReceiverFactory[offset + hwInfo->platform.eRenderCoreFamily]; - if (funcCreate) { - commandStreamReceiver = funcCreate(false, executionEnvironment); - } - } else { - commandStreamReceiver = createCommandStreamImpl(executionEnvironment); + + if (overrideCommandStreamReceiverCreation) { + return createCommandStreamImpl(executionEnvironment); } - return commandStreamReceiver; + + auto funcCreate = commandStreamReceiverFactory[IGFX_MAX_CORE + hwInfo->platform.eRenderCoreFamily]; + if (funcCreate) { + return funcCreate(false, executionEnvironment); + } + return nullptr; } bool getDevices(size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment) { diff --git a/unit_tests/libult/ult_aub_command_stream_receiver.h b/unit_tests/libult/ult_aub_command_stream_receiver.h new file mode 100644 index 0000000000..3c8a337049 --- /dev/null +++ b/unit_tests/libult/ult_aub_command_stream_receiver.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2017-2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "runtime/command_stream/aub_command_stream_receiver_hw.h" +#include "runtime/execution_environment/execution_environment.h" +#include "runtime/memory_manager/os_agnostic_memory_manager.h" +#include "unit_tests/mocks/mock_experimental_command_buffer.h" + +namespace NEO { + +template +class UltAubCommandStreamReceiver : public AUBCommandStreamReceiverHw, public NonCopyableOrMovableClass { + using BaseClass = AUBCommandStreamReceiverHw; + + public: + using BaseClass::osContext; + + UltAubCommandStreamReceiver(const std::string &fileName, bool standalone, ExecutionEnvironment &executionEnvironment) + : BaseClass(fileName, standalone, executionEnvironment) { + } + + UltAubCommandStreamReceiver(ExecutionEnvironment &executionEnvironment) + : BaseClass("aubfile", true, executionEnvironment) { + } + + static CommandStreamReceiver *create(bool withAubDump, ExecutionEnvironment &executionEnvironment) { + auto csr = new UltAubCommandStreamReceiver("aubfile", true, executionEnvironment); + + if (!csr->subCaptureManager->isSubCaptureMode()) { + csr->openFile("aubfile"); + } + + return csr; + } + + void blitBuffer(const BlitProperties &blitProperites) override { + blitBufferCalled++; + BaseClass::blitBuffer(blitProperites); + } + + uint32_t blitBufferCalled = 0; +}; +} // namespace NEO diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index bbfbac8a7e..8bc9ada9fc 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -656,6 +656,13 @@ struct BcsBufferTests : public ::testing::Test { CommandStreamReceiver *getCommandStreamReceiverForBlitOperation(MemObj &memObj) const override { return bcsCsr.get(); } + BlitOperationResult blitMemoryToAllocation(MemObj &memObj, GraphicsAllocation *memory, void *hostPtr, size_t size) const override { + auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection::HostPtrToBuffer, + *bcsCsr, memory, + hostPtr, true, 0, size); + bcsCsr->blitBuffer(blitProperties); + return BlitOperationResult::Success; + } std::unique_ptr bcsOsContext; std::unique_ptr bcsCsr; }; diff --git a/unit_tests/mocks/mock_aub_csr.h b/unit_tests/mocks/mock_aub_csr.h index 6bf0dd9746..4d5dc6e16e 100644 --- a/unit_tests/mocks/mock_aub_csr.h +++ b/unit_tests/mocks/mock_aub_csr.h @@ -12,6 +12,7 @@ #include "runtime/execution_environment/execution_environment.h" #include "runtime/helpers/hw_info.h" #include "runtime/platform/platform.h" +#include "unit_tests/mocks/mock_allocation_properties.h" #include "gmock/gmock.h" diff --git a/unit_tests/mocks/mock_device.h b/unit_tests/mocks/mock_device.h index 948ac1f779..fb1409db7f 100644 --- a/unit_tests/mocks/mock_device.h +++ b/unit_tests/mocks/mock_device.h @@ -20,6 +20,7 @@ extern CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executio class MockDevice : public Device { public: + using Device::createDeviceInternals; using Device::createEngine; using Device::enabledClVersion; using Device::engines; diff --git a/unit_tests/mocks/mock_execution_environment.h b/unit_tests/mocks/mock_execution_environment.h index b1d83f25ef..c87c460a90 100644 --- a/unit_tests/mocks/mock_execution_environment.h +++ b/unit_tests/mocks/mock_execution_environment.h @@ -41,14 +41,15 @@ struct MockExecutionEnvironment : ExecutionEnvironment { template struct MockExecutionEnvironmentWithCsr : public ExecutionEnvironment { MockExecutionEnvironmentWithCsr() = delete; - MockExecutionEnvironmentWithCsr(const HardwareInfo &hwInfo) { + MockExecutionEnvironmentWithCsr(const HardwareInfo &hwInfo, uint32_t devicesCount) { setHwInfo(&hwInfo); - auto &gpgpuEngines = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(); - commandStreamReceivers.resize(1); + commandStreamReceivers.resize(devicesCount); for (uint32_t csrIndex = 0; csrIndex < gpgpuEngines.size(); csrIndex++) { - commandStreamReceivers[0].push_back(std::unique_ptr(new CsrType(*this))); + for (auto &csr : commandStreamReceivers) { + csr.push_back(std::unique_ptr(new CsrType(*this))); + } } } }; diff --git a/unit_tests/mocks/mock_graphics_allocation.h b/unit_tests/mocks/mock_graphics_allocation.h index 2ee322f918..f9577c5c3d 100644 --- a/unit_tests/mocks/mock_graphics_allocation.h +++ b/unit_tests/mocks/mock_graphics_allocation.h @@ -12,6 +12,7 @@ namespace NEO { class MockGraphicsAllocation : public MemoryAllocation { public: + using MemoryAllocation::aubInfo; using MemoryAllocation::MemoryAllocation; using MemoryAllocation::objectNotResident; using MemoryAllocation::objectNotUsed; diff --git a/unit_tests/os_interface/windows/driver_info_tests.cpp b/unit_tests/os_interface/windows/driver_info_tests.cpp index 9467deaa43..93ba706ce2 100644 --- a/unit_tests/os_interface/windows/driver_info_tests.cpp +++ b/unit_tests/os_interface/windows/driver_info_tests.cpp @@ -25,7 +25,7 @@ namespace NEO { -extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE]; +extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[IGFX_MAX_CORE]; CommandStreamReceiver *createMockCommandStreamReceiver(bool withAubDump, ExecutionEnvironment &executionEnvironment); diff --git a/unit_tests/platform/platform_tests.cpp b/unit_tests/platform/platform_tests.cpp index a51a619c5d..f684a8b122 100644 --- a/unit_tests/platform/platform_tests.cpp +++ b/unit_tests/platform/platform_tests.cpp @@ -176,7 +176,7 @@ TEST(PlatformTestSimple, shutdownClosesAsyncEventHandlerThread) { } namespace NEO { -extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE]; +extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[IGFX_MAX_CORE]; } CommandStreamReceiver *createMockCommandStreamReceiver(bool withAubDump, ExecutionEnvironment &executionEnvironment) {