Add BlitProperties to simplify properties passing

Change-Id: I4abf99d420487a237e5b465b9d4d121121f45a84
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
Related-To: NEO-3020
This commit is contained in:
Dunajski, Bartosz
2019-06-26 11:37:46 +02:00
committed by sys_ocldev
parent 373dd2021b
commit 56e77ca452
16 changed files with 172 additions and 87 deletions

View File

@@ -26,6 +26,7 @@
#include "runtime/command_queue/finish.h"
#include "runtime/command_queue/flush.h"
#include "runtime/command_queue/gpgpu_walker.h"
#include "runtime/helpers/blit_commands_helper.h"
namespace NEO {
template <typename Family>
@@ -106,17 +107,19 @@ cl_int CommandQueueHw<Family>::enqueueReadWriteBufferWithBlitTransfer(cl_command
auto blitCommandStreamReceiver = context->getCommandStreamReceiverForBlitOperation(*buffer);
EventsRequest eventsRequest(numEventsInWaitList, eventWaitList, event);
TimestampPacketContainer previousTimestampPacketNodes;
CsrDependencies csrDependencies;
csrDependencies.fillFromEventsRequestAndMakeResident(eventsRequest, *blitCommandStreamReceiver,
CsrDependencies::DependenciesType::All);
obtainNewTimestampPacketNodes(1, previousTimestampPacketNodes, queueDependenciesClearRequired());
csrDependencies.push_back(&previousTimestampPacketNodes);
auto copyDirection = (CL_COMMAND_WRITE_BUFFER == commandType) ? BlitterConstants::BlitWithHostPtrDirection::FromHostPtr
: BlitterConstants::BlitWithHostPtrDirection::ToHostPtr;
blitCommandStreamReceiver->blitWithHostPtr(*buffer, ptr, blocking, offset, size, copyDirection, csrDependencies, *timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(copyDirection, buffer, ptr, blocking, offset, size);
blitProperties.csrDependencies.fillFromEventsRequestAndMakeResident(eventsRequest, *blitCommandStreamReceiver,
CsrDependencies::DependenciesType::All);
obtainNewTimestampPacketNodes(1, previousTimestampPacketNodes, queueDependenciesClearRequired());
blitProperties.csrDependencies.push_back(&previousTimestampPacketNodes);
blitProperties.outputTimestampPacket = timestampPacketContainer.get();
blitCommandStreamReceiver->blitWithHostPtr(blitProperties);
MultiDispatchInfo multiDispatchInfo;

View File

@@ -27,6 +27,7 @@
#include "runtime/memory_manager/surface.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/platform/platform.h"
#include "runtime/utilities/tag_allocator.h"
namespace NEO {
@@ -418,23 +419,20 @@ cl_int CommandStreamReceiver::expectMemory(const void *gfxAddress, const void *s
return (isMemoryEqual == isEqualMemoryExpected) ? CL_SUCCESS : CL_INVALID_VALUE;
}
void CommandStreamReceiver::blitWithHostPtr(Buffer &buffer, void *hostPtr, bool blocking, size_t bufferOffset, uint64_t copySize,
BlitterConstants::BlitWithHostPtrDirection copyDirection, CsrDependencies &csrDependencies,
const TimestampPacketContainer &outputTimestampPacket) {
HostPtrSurface hostPtrSurface(hostPtr, static_cast<size_t>(copySize), true);
void CommandStreamReceiver::blitWithHostPtr(BlitProperties &blitProperites) {
HostPtrSurface hostPtrSurface(blitProperites.hostPtr, static_cast<size_t>(blitProperites.copySize), true);
bool success = createAllocationForHostSurface(hostPtrSurface, false);
UNRECOVERABLE_IF(!success);
auto hostPtrAllocation = hostPtrSurface.getAllocation();
auto device = buffer.getContext()->getDevice(0);
auto hostPtrBuffer = std::unique_ptr<Buffer>(Buffer::createBufferHwFromDevice(device, CL_MEM_READ_WRITE, static_cast<size_t>(copySize),
hostPtr, hostPtr, hostPtrAllocation,
auto device = platform()->getDevice(0);
auto hostPtrBuffer = std::unique_ptr<Buffer>(Buffer::createBufferHwFromDevice(device, CL_MEM_READ_WRITE,
static_cast<size_t>(blitProperites.copySize),
blitProperites.hostPtr, blitProperites.hostPtr, hostPtrAllocation,
true, false, true));
if (BlitterConstants::BlitWithHostPtrDirection::FromHostPtr == copyDirection) {
blitBuffer(buffer, *hostPtrBuffer, blocking, bufferOffset, 0, copySize, csrDependencies, outputTimestampPacket);
} else {
blitBuffer(*hostPtrBuffer, buffer, blocking, 0, bufferOffset, copySize, csrDependencies, outputTimestampPacket);
}
blitProperites.setHostPtrBuffer(hostPtrBuffer.get());
blitBuffer(blitProperites);
}
} // namespace NEO

View File

@@ -13,6 +13,7 @@
#include "runtime/command_stream/thread_arbitration_policy.h"
#include "runtime/helpers/address_patch.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/blit_commands_helper.h"
#include "runtime/helpers/completion_stamp.h"
#include "runtime/helpers/flat_batch_buffer_helper.h"
#include "runtime/helpers/options.h"
@@ -176,11 +177,8 @@ class CommandStreamReceiver {
this->latestSentTaskCount = latestSentTaskCount;
}
void blitWithHostPtr(Buffer &buffer, void *hostPtr, bool blocking, size_t bufferOffset, uint64_t copySize,
BlitterConstants::BlitWithHostPtrDirection copyDirection, CsrDependencies &csrDependencies,
const TimestampPacketContainer &outputTimestampPacket);
virtual void blitBuffer(Buffer &dstBuffer, Buffer &srcBuffer, bool blocking, uint64_t dstOffset, uint64_t srcOffset,
uint64_t copySize, CsrDependencies &csrDependencies, const TimestampPacketContainer &outputTimestampPacket) = 0;
void blitWithHostPtr(BlitProperties &blitProperites);
virtual void blitBuffer(BlitProperties &blitProperites) = 0;
ScratchSpaceController *getScratchSpaceController() const {
return scratchSpaceController.get();

View File

@@ -70,8 +70,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
return CommandStreamReceiverType::CSR_HW;
}
void blitBuffer(Buffer &dstBuffer, Buffer &srcBuffer, bool blocking, uint64_t dstOffset, uint64_t srcOffset,
uint64_t copySize, CsrDependencies &csrDependencies, const TimestampPacketContainer &outputTimestampPacket) override;
void blitBuffer(BlitProperties &blitProperites) override;
protected:
using CommandStreamReceiver::osContext;

View File

@@ -726,29 +726,30 @@ bool CommandStreamReceiverHw<GfxFamily>::detectInitProgrammingFlagsRequired(cons
}
template <typename GfxFamily>
void CommandStreamReceiverHw<GfxFamily>::blitBuffer(Buffer &dstBuffer, Buffer &srcBuffer, bool blocking, uint64_t dstOffset, uint64_t srcOffset,
uint64_t copySize, CsrDependencies &csrDependencies, const TimestampPacketContainer &outputTimestampPacket) {
void CommandStreamReceiverHw<GfxFamily>::blitBuffer(BlitProperties &blitProperites) {
using MI_BATCH_BUFFER_END = typename GfxFamily::MI_BATCH_BUFFER_END;
using MI_FLUSH_DW = typename GfxFamily::MI_FLUSH_DW;
UNRECOVERABLE_IF(osContext->getEngineType() != aub_stream::EngineType::ENGINE_BCS);
auto lock = obtainUniqueOwnership();
bool updateTimestampPacket = outputTimestampPacket.peekNodes().size() > 0;
auto &commandStream = getCS(BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(copySize, csrDependencies, updateTimestampPacket));
bool updateTimestampPacket = blitProperites.outputTimestampPacket != nullptr;
auto &commandStream = getCS(BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(blitProperites.copySize,
blitProperites.csrDependencies,
updateTimestampPacket));
auto commandStreamStart = commandStream.getUsed();
auto newTaskCount = taskCount + 1;
latestSentTaskCount = newTaskCount;
TimestampPacketHelper::programCsrDependencies<GfxFamily>(commandStream, csrDependencies);
TimestampPacketHelper::programCsrDependencies<GfxFamily>(commandStream, blitProperites.csrDependencies);
BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBuffer(dstBuffer, srcBuffer, commandStream, dstOffset, srcOffset, copySize);
BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBuffer(blitProperites, commandStream);
HardwareCommandsHelper<GfxFamily>::programMiFlushDw(commandStream, tagAllocation->getGpuAddress(), newTaskCount);
if (updateTimestampPacket) {
UNRECOVERABLE_IF(outputTimestampPacket.peekNodes().size() != 1);
auto timestampPacketGpuAddress = outputTimestampPacket.peekNodes().at(0)->getGpuAddress() + offsetof(TimestampPacketStorage, packets[0].contextEnd);
UNRECOVERABLE_IF(blitProperites.outputTimestampPacket->peekNodes().size() != 1);
auto timestampPacketGpuAddress = blitProperites.outputTimestampPacket->peekNodes().at(0)->getGpuAddress() + offsetof(TimestampPacketStorage, packets[0].contextEnd);
HardwareCommandsHelper<GfxFamily>::programMiFlushDw(commandStream, timestampPacketGpuAddress, 0);
}
@@ -757,8 +758,8 @@ void CommandStreamReceiverHw<GfxFamily>::blitBuffer(Buffer &dstBuffer, Buffer &s
alignToCacheLine(commandStream);
makeResident(*srcBuffer.getGraphicsAllocation());
makeResident(*dstBuffer.getGraphicsAllocation());
makeResident(*blitProperites.srcBuffer->getGraphicsAllocation());
makeResident(*blitProperites.dstBuffer->getGraphicsAllocation());
makeResident(*commandStream.getGraphicsAllocation());
makeResident(*tagAllocation);
@@ -773,7 +774,7 @@ void CommandStreamReceiverHw<GfxFamily>::blitBuffer(Buffer &dstBuffer, Buffer &s
auto flushStampToWait = flushStamp->peekStamp();
lock.unlock();
if (blocking) {
if (blitProperites.blocking) {
waitForTaskCountWithKmdNotifyFallback(newTaskCount, flushStampToWait, false, false);
internalAllocationStorage->cleanAllocationList(newTaskCount, TEMPORARY_ALLOCATION);
}

View File

@@ -15,6 +15,7 @@ set(RUNTIME_SRCS_HELPERS_BASE
${CMAKE_CURRENT_SOURCE_DIR}/base_object_allocator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_base.inl
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_bdw_plus.inl
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/built_ins_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.cpp

View File

@@ -0,0 +1,31 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/helpers/blit_commands_helper.h"
#include "runtime/helpers/timestamp_packet.h"
#include "CL/cl.h"
namespace NEO {
BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection copyDirection, Buffer *buffer, void *hostPtr, bool blocking, size_t offset, uint64_t copySize) {
if (BlitterConstants::BlitWithHostPtrDirection::FromHostPtr == copyDirection) {
return {nullptr, copyDirection, {}, buffer, nullptr, hostPtr, blocking, offset, 0, copySize};
} else {
return {nullptr, copyDirection, {}, nullptr, buffer, hostPtr, blocking, 0, offset, copySize};
}
}
void BlitProperties::setHostPtrBuffer(Buffer *hostPtrBuffer) {
if (BlitterConstants::BlitWithHostPtrDirection::FromHostPtr == copyDirection) {
srcBuffer = hostPtrBuffer;
} else {
dstBuffer = hostPtrBuffer;
}
}
} // namespace NEO

View File

@@ -6,18 +6,41 @@
*/
#pragma once
#include "runtime/helpers/csr_deps.h"
#include "runtime/memory_manager/memory_constants.h"
#include <cstdint>
namespace NEO {
class Buffer;
class GraphicsAllocation;
class LinearStream;
class TimestampPacketContainer;
struct BlitProperties {
BlitProperties() = delete;
static BlitProperties constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection copyDirection, Buffer *buffer,
void *hostPtr, bool blocking, size_t offset, uint64_t copySize);
void setHostPtrBuffer(Buffer *hostPtrBuffer);
TimestampPacketContainer *outputTimestampPacket = nullptr;
BlitterConstants::BlitWithHostPtrDirection copyDirection;
CsrDependencies csrDependencies;
Buffer *dstBuffer = nullptr;
Buffer *srcBuffer = nullptr;
void *hostPtr = nullptr;
bool blocking = false;
size_t dstOffset = 0;
size_t srcOffset = 0;
uint64_t copySize = 0;
};
template <typename GfxFamily>
struct BlitCommandsHelper {
static size_t estimateBlitCommandsSize(uint64_t copySize, CsrDependencies &csrDependencies, bool updateTimestampPacket);
static void dispatchBlitCommandsForBuffer(Buffer &dstBuffer, Buffer &srcBuffer, LinearStream &linearStream,
uint64_t dstOffset, uint64_t srcOffset, uint64_t copySize);
static void appendBlitCommandsForBuffer(Buffer &dstBuffer, Buffer &srcBuffer, typename GfxFamily::XY_COPY_BLT &blitCmd);
static void dispatchBlitCommandsForBuffer(BlitProperties &blitProperites, LinearStream &linearStream);
static void appendBlitCommandsForBuffer(BlitProperties &blitProperites, typename GfxFamily::XY_COPY_BLT &blitCmd);
};
} // namespace NEO

View File

@@ -40,9 +40,8 @@ size_t BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(uint64_t copySize
}
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBuffer(Buffer &dstBuffer, Buffer &srcBuffer, LinearStream &linearStream,
uint64_t dstOffset, uint64_t srcOffset, uint64_t copySize) {
uint64_t sizeToBlit = copySize;
void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBuffer(BlitProperties &blitProperites, LinearStream &linearStream) {
uint64_t sizeToBlit = blitProperites.copySize;
uint64_t width = 1;
uint64_t height = 1;
uint64_t offset = 0;
@@ -72,10 +71,10 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBuffer(Buffer &dstBuf
bltCmd->setDestinationPitch(static_cast<uint32_t>(width));
bltCmd->setSourcePitch(static_cast<uint32_t>(width));
bltCmd->setDestinationBaseAddress(dstBuffer.getGraphicsAllocation()->getGpuAddress() + dstOffset + offset);
bltCmd->setSourceBaseAddress(srcBuffer.getGraphicsAllocation()->getGpuAddress() + srcOffset + offset);
bltCmd->setDestinationBaseAddress(blitProperites.dstBuffer->getGraphicsAllocation()->getGpuAddress() + blitProperites.dstOffset + offset);
bltCmd->setSourceBaseAddress(blitProperites.srcBuffer->getGraphicsAllocation()->getGpuAddress() + blitProperites.srcOffset + offset);
appendBlitCommandsForBuffer(dstBuffer, srcBuffer, *bltCmd);
appendBlitCommandsForBuffer(blitProperites, *bltCmd);
auto blitSize = width * height;
sizeToBlit -= blitSize;

View File

@@ -10,6 +10,6 @@
namespace NEO {
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForBuffer(Buffer &dstBuffer, Buffer &srcBuffer, typename GfxFamily::XY_COPY_BLT &blitCmd) {}
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForBuffer(BlitProperties &blitProperites, typename GfxFamily::XY_COPY_BLT &blitCmd) {}
} // namespace NEO

View File

@@ -286,10 +286,9 @@ Buffer *Buffer::create(Context *context,
if (gpuCopyRequired) {
auto blitCommandStreamReceiver = context->getCommandStreamReceiverForBlitOperation(*pBuffer);
if (blitCommandStreamReceiver) {
CsrDependencies dependencies;
TimestampPacketContainer timestampPacketContainer;
blitCommandStreamReceiver->blitWithHostPtr(*pBuffer, hostPtr, true, 0, size, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
dependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
pBuffer, hostPtr, true, 0, size);
blitCommandStreamReceiver->blitWithHostPtr(blitProperties);
} else {
auto cmdQ = context->getSpecialQueue();
if (CL_SUCCESS != cmdQ->enqueueWriteBuffer(pBuffer, CL_TRUE, 0, size, hostPtr, nullptr, 0, nullptr, nullptr)) {

View File

@@ -269,6 +269,7 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsNotRequiredThenGshAddres
struct BcsTests : public CommandStreamReceiverHwTest {
void SetUp() override {
CommandStreamReceiverHwTest::SetUp();
platform()->initialize();
auto &csr = pDevice->getCommandStreamReceiver();
auto engine = csr.getMemoryManager()->getRegisteredEngineForCsr(&csr);
@@ -364,8 +365,10 @@ HWTEST_F(BcsTests, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredC
uint32_t newTaskCount = 19;
csr.taskCount = newTaskCount - 1;
EXPECT_EQ(0u, csr.recursiveLockCounter.load());
csr.blitWithHostPtr(*buffer, hostPtr, true, 0, bltSize, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
csrDependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
buffer.get(), hostPtr, true, 0, bltSize);
csr.blitWithHostPtr(blitProperties);
EXPECT_EQ(newTaskCount, csr.taskCount);
EXPECT_EQ(newTaskCount, csr.latestFlushedTaskCount);
EXPECT_EQ(newTaskCount, csr.latestSentTaskCount);
@@ -421,13 +424,15 @@ HWTEST_F(BcsTests, givenCsrDependenciesWhenProgrammingCommandStreamThenAddSemaph
uint32_t numberOfDependencyContainers = 2;
size_t numberNodesPerContainer = 5;
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
buffer.get(), hostPtr, true, 0, 1);
MockTimestampPacketContainer timestamp0(*csr.getTimestampPacketAllocator(), numberNodesPerContainer);
MockTimestampPacketContainer timestamp1(*csr.getTimestampPacketAllocator(), numberNodesPerContainer);
csrDependencies.push_back(&timestamp0);
csrDependencies.push_back(&timestamp1);
blitProperties.csrDependencies.push_back(&timestamp0);
blitProperties.csrDependencies.push_back(&timestamp1);
csr.blitWithHostPtr(*buffer, hostPtr, true, 0, 1, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
csrDependencies, timestampPacketContainer);
csr.blitWithHostPtr(blitProperties);
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(csr.commandStream);
@@ -467,8 +472,10 @@ HWTEST_F(BcsTests, givenInputAllocationsWhenBlitDispatchedThenMakeAllAllocations
EXPECT_EQ(0u, csr.makeSurfacePackNonResidentCalled);
csr.blitWithHostPtr(*buffer, hostPtr, true, 0, 1, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
csrDependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
buffer.get(), hostPtr, true, 0, 1);
csr.blitWithHostPtr(blitProperties);
EXPECT_TRUE(csr.isMadeResident(buffer->getGraphicsAllocation()));
EXPECT_TRUE(csr.isMadeResident(csr.commandStream.getGraphicsAllocation()));
@@ -492,8 +499,11 @@ HWTEST_F(BcsTests, givenBufferWhenBlitCalledThenFlushCommandBuffer) {
uint32_t newTaskCount = 17;
csr.taskCount = newTaskCount - 1;
csr.blitWithHostPtr(*buffer, hostPtr, true, 0, 1, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
csrDependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
buffer.get(), hostPtr, true, 0, 1);
csr.blitWithHostPtr(blitProperties);
EXPECT_EQ(commandStream.getGraphicsAllocation(), csr.latestFlushedBatchBuffer.commandBufferAllocation);
EXPECT_EQ(commandStreamOffset, csr.latestFlushedBatchBuffer.startOffset);
@@ -538,12 +548,16 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCallWaitWithKmdFallback) {
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
myMockCsr->blitWithHostPtr(*buffer, hostPtr, false, 0, 1, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
csrDependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
buffer.get(), hostPtr, false, 0, 1);
myMockCsr->blitWithHostPtr(blitProperties);
EXPECT_EQ(0u, myMockCsr->waitForTaskCountWithKmdNotifyFallbackCalled);
myMockCsr->blitWithHostPtr(*buffer, hostPtr, true, 0, 1, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
csrDependencies, timestampPacketContainer);
blitProperties.blocking = true;
myMockCsr->blitWithHostPtr(blitProperties);
EXPECT_EQ(1u, myMockCsr->waitForTaskCountWithKmdNotifyFallbackCalled);
EXPECT_EQ(myMockCsr->taskCount, myMockCsr->taskCountToWaitPassed);
EXPECT_EQ(myMockCsr->flushStamp->peekStamp(), myMockCsr->flushStampToWaitPassed);
@@ -564,12 +578,16 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCleanTemporaryAllocations) {
EXPECT_EQ(0u, mockInternalAllocationsStorage->cleanAllocationsCalled);
bcsCsr.blitWithHostPtr(*buffer, hostPtr, false, 0, 1, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
csrDependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
buffer.get(), hostPtr, false, 0, 1);
bcsCsr.blitWithHostPtr(blitProperties);
EXPECT_EQ(0u, mockInternalAllocationsStorage->cleanAllocationsCalled);
bcsCsr.blitWithHostPtr(*buffer, hostPtr, true, 0, 1, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
csrDependencies, timestampPacketContainer);
blitProperties.blocking = true;
bcsCsr.blitWithHostPtr(blitProperties);
EXPECT_EQ(1u, mockInternalAllocationsStorage->cleanAllocationsCalled);
EXPECT_EQ(bcsCsr.taskCount, mockInternalAllocationsStorage->lastCleanAllocationsTaskCount);
EXPECT_TRUE(TEMPORARY_ALLOCATION == mockInternalAllocationsStorage->lastCleanAllocationUsage);
@@ -586,8 +604,10 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
{
// from hostPtr
HardwareParse hwParser;
csr.blitWithHostPtr(*buffer1, hostPtr, true, 0, 1, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
csrDependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
buffer1.get(), hostPtr, true, 0, 1);
csr.blitWithHostPtr(blitProperties);
hwParser.parseCommands<FamilyType>(csr.commandStream);
@@ -602,8 +622,10 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
// to hostPtr
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
csr.blitWithHostPtr(*buffer1, hostPtr, true, 0, 1, BlitterConstants::BlitWithHostPtrDirection::ToHostPtr,
csrDependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::ToHostPtr,
buffer1.get(), hostPtr, true, 0, 1);
csr.blitWithHostPtr(blitProperties);
hwParser.parseCommands<FamilyType>(csr.commandStream, offset);
@@ -618,7 +640,11 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
// Buffer to Buffer
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
csr.blitBuffer(*buffer1, *buffer2, true, 0, 0, 1, csrDependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
buffer1.get(), hostPtr, true, 0, 1);
blitProperties.setHostPtrBuffer(buffer2.get());
csr.blitBuffer(blitProperties);
hwParser.parseCommands<FamilyType>(csr.commandStream, offset);
@@ -644,8 +670,10 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
// from hostPtr
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
csr.blitWithHostPtr(*buffer1, hostPtr, true, buffer1Offset, 1, BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
csrDependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
buffer1.get(), hostPtr, true, buffer1Offset, 1);
csr.blitWithHostPtr(blitProperties);
hwParser.parseCommands<FamilyType>(csr.commandStream, offset);
@@ -660,8 +688,10 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
// to hostPtr
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
csr.blitWithHostPtr(*buffer1, hostPtr, true, buffer1Offset, 1, BlitterConstants::BlitWithHostPtrDirection::ToHostPtr,
csrDependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::ToHostPtr,
buffer1.get(), hostPtr, true, buffer1Offset, 1);
csr.blitWithHostPtr(blitProperties);
hwParser.parseCommands<FamilyType>(csr.commandStream, offset);
@@ -677,7 +707,12 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
// Buffer to Buffer
HardwareParse hwParser;
auto offset = csr.commandStream.getUsed();
csr.blitBuffer(*buffer1, *buffer2, true, buffer1Offset, buffer2Offset, 1, csrDependencies, timestampPacketContainer);
auto blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitWithHostPtrDirection::FromHostPtr,
buffer1.get(), hostPtr, true, buffer1Offset, 1);
blitProperties.setHostPtrBuffer(buffer2.get());
blitProperties.srcOffset = buffer2Offset;
csr.blitBuffer(blitProperties);
hwParser.parseCommands<FamilyType>(csr.commandStream, offset);

View File

@@ -456,8 +456,7 @@ class CommandStreamReceiverMock : public CommandStreamReceiver {
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode) override {
}
void blitBuffer(Buffer &dstBuffer, Buffer &srcBuffer, bool blocking, uint64_t dstOffset, uint64_t srcOffset,
uint64_t copySize, CsrDependencies &csrDependencies, const TimestampPacketContainer &outputTimestampPacket) override{};
void blitBuffer(BlitProperties &blitProperites) override{};
CompletionStamp flushTask(
LinearStream &commandStream,

View File

@@ -166,10 +166,9 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
return CommandStreamReceiverHw<GfxFamily>::obtainUniqueOwnership();
}
void blitBuffer(Buffer &dstBuffer, Buffer &srcBuffer, bool blocking, uint64_t dstOffset, uint64_t srcOffset,
uint64_t copySize, CsrDependencies &csrDependencies, const TimestampPacketContainer &outputTimestampPacket) override {
void blitBuffer(BlitProperties &blitProperites) override {
blitBufferCalled++;
CommandStreamReceiverHw<GfxFamily>::blitBuffer(dstBuffer, srcBuffer, blocking, dstOffset, srcOffset, copySize, csrDependencies, outputTimestampPacket);
CommandStreamReceiverHw<GfxFamily>::blitBuffer(blitProperites);
}
std::atomic<uint32_t> recursiveLockCounter;

View File

@@ -666,6 +666,7 @@ struct BcsBufferTests : public ::testing::Test {
}
DebugManager.flags.EnableTimestampPacket.set(1);
DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.set(true);
platform()->initialize();
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
device->getExecutionEnvironment()->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true;
bcsMockContext = std::make_unique<BcsMockContext>(device.get());

View File

@@ -254,8 +254,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode) override {
}
void blitBuffer(Buffer &dstBuffer, Buffer &srcBuffer, bool blocking, uint64_t dstOffset, uint64_t srcOffset,
uint64_t copySize, CsrDependencies &csrDependencies, const TimestampPacketContainer &outputTimestampPacket) override{};
void blitBuffer(BlitProperties &blitProperites) override{};
void setOSInterface(OSInterface *osInterface);