mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Refactor BlitProperties
Related-To: NEO-4215 Change-Id: Ieacf424cd4eebee22b45557e432271093644443b Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
ca5baf6d89
commit
d4c75e09c6
@ -24,6 +24,7 @@
|
||||
#include "runtime/event/event_builder.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "runtime/gtpin/gtpin_notify.h"
|
||||
#include "runtime/helpers/cl_blit_properties.h"
|
||||
#include "runtime/helpers/dispatch_info_builder.h"
|
||||
#include "runtime/helpers/enqueue_properties.h"
|
||||
#include "runtime/helpers/hardware_commands_helper.h"
|
||||
@ -451,12 +452,12 @@ BlitProperties CommandQueueHw<GfxFamily>::processDispatchForBlitEnqueue(const Mu
|
||||
TimestampPacketDependencies ×tampPacketDependencies,
|
||||
const EventsRequest &eventsRequest, LinearStream &commandStream,
|
||||
uint32_t commandType, bool queueBlocked) {
|
||||
auto blitDirection = BlitProperties::obtainBlitDirection(commandType);
|
||||
auto blitDirection = ClBlitProperties::obtainBlitDirection(commandType);
|
||||
|
||||
auto blitCommandStreamReceiver = getBcsCommandStreamReceiver();
|
||||
|
||||
auto blitProperties = BlitProperties::constructProperties(blitDirection, *blitCommandStreamReceiver,
|
||||
multiDispatchInfo.peekBuiltinOpParams());
|
||||
auto blitProperties = ClBlitProperties::constructProperties(blitDirection, *blitCommandStreamReceiver,
|
||||
multiDispatchInfo.peekBuiltinOpParams());
|
||||
if (!queueBlocked) {
|
||||
eventsRequest.fillCsrDependencies(blitProperties.csrDependencies, *blitCommandStreamReceiver,
|
||||
CsrDependencies::DependenciesType::All);
|
||||
|
@ -13,6 +13,7 @@ set(RUNTIME_SRCS_HELPERS_BASE
|
||||
${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}/cl_blit_properties.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cl_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/convert_color.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/device_helpers.cpp
|
||||
|
@ -8,12 +8,8 @@
|
||||
#include "runtime/helpers/blit_commands_helper.h"
|
||||
|
||||
#include "core/helpers/timestamp_packet.h"
|
||||
#include "runtime/built_ins/builtins_dispatch_builder.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/memory_manager/surface.h"
|
||||
|
||||
#include "CL/cl.h"
|
||||
|
||||
namespace NEO {
|
||||
BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterConstants::BlitDirection blitDirection,
|
||||
CommandStreamReceiver &commandStreamReceiver,
|
||||
@ -65,75 +61,6 @@ BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterCons
|
||||
}
|
||||
}
|
||||
|
||||
BlitProperties BlitProperties::constructProperties(BlitterConstants::BlitDirection blitDirection,
|
||||
CommandStreamReceiver &commandStreamReceiver,
|
||||
const BuiltinOpParams &builtinOpParams) {
|
||||
|
||||
if (BlitterConstants::BlitDirection::BufferToBuffer == blitDirection) {
|
||||
auto dstOffset = builtinOpParams.dstOffset.x + builtinOpParams.dstMemObj->getOffset();
|
||||
auto srcOffset = builtinOpParams.srcOffset.x + builtinOpParams.srcMemObj->getOffset();
|
||||
|
||||
return constructPropertiesForCopyBuffer(builtinOpParams.dstMemObj->getGraphicsAllocation(),
|
||||
builtinOpParams.srcMemObj->getGraphicsAllocation(),
|
||||
dstOffset, srcOffset, builtinOpParams.size.x);
|
||||
}
|
||||
|
||||
GraphicsAllocation *gpuAllocation = nullptr;
|
||||
size_t copyOffset = 0;
|
||||
|
||||
void *hostPtr = nullptr;
|
||||
size_t hostPtrOffset = 0;
|
||||
|
||||
uint64_t memObjGpuVa = 0;
|
||||
uint64_t hostAllocGpuVa = 0;
|
||||
|
||||
GraphicsAllocation *hostAllocation = builtinOpParams.transferAllocation;
|
||||
|
||||
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) {
|
||||
// write buffer
|
||||
hostPtr = builtinOpParams.srcPtr;
|
||||
hostPtrOffset = builtinOpParams.srcOffset.x;
|
||||
copyOffset = builtinOpParams.dstOffset.x;
|
||||
|
||||
memObjGpuVa = castToUint64(builtinOpParams.dstPtr);
|
||||
hostAllocGpuVa = castToUint64(builtinOpParams.srcPtr);
|
||||
|
||||
if (builtinOpParams.dstSvmAlloc) {
|
||||
gpuAllocation = builtinOpParams.dstSvmAlloc;
|
||||
hostAllocation = builtinOpParams.srcSvmAlloc;
|
||||
} else {
|
||||
gpuAllocation = builtinOpParams.dstMemObj->getGraphicsAllocation();
|
||||
memObjGpuVa = (gpuAllocation->getGpuAddress() + builtinOpParams.dstMemObj->getOffset());
|
||||
}
|
||||
}
|
||||
|
||||
if (BlitterConstants::BlitDirection::BufferToHostPtr == blitDirection) {
|
||||
// read buffer
|
||||
hostPtr = builtinOpParams.dstPtr;
|
||||
|
||||
hostPtrOffset = builtinOpParams.dstOffset.x;
|
||||
copyOffset = builtinOpParams.srcOffset.x;
|
||||
|
||||
memObjGpuVa = castToUint64(builtinOpParams.srcPtr);
|
||||
hostAllocGpuVa = castToUint64(builtinOpParams.dstPtr);
|
||||
|
||||
if (builtinOpParams.srcSvmAlloc) {
|
||||
gpuAllocation = builtinOpParams.srcSvmAlloc;
|
||||
hostAllocation = builtinOpParams.dstSvmAlloc;
|
||||
} else {
|
||||
gpuAllocation = builtinOpParams.srcMemObj->getGraphicsAllocation();
|
||||
memObjGpuVa = (gpuAllocation->getGpuAddress() + builtinOpParams.srcMemObj->getOffset());
|
||||
}
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(BlitterConstants::BlitDirection::HostPtrToBuffer != blitDirection &&
|
||||
BlitterConstants::BlitDirection::BufferToHostPtr != blitDirection);
|
||||
|
||||
return constructPropertiesForReadWriteBuffer(blitDirection, commandStreamReceiver, gpuAllocation,
|
||||
hostAllocation, hostPtr, memObjGpuVa, hostAllocGpuVa,
|
||||
hostPtrOffset, copyOffset, builtinOpParams.size.x);
|
||||
}
|
||||
|
||||
BlitProperties BlitProperties::constructPropertiesForCopyBuffer(GraphicsAllocation *dstAllocation, GraphicsAllocation *srcAllocation,
|
||||
size_t dstOffset, size_t srcOffset, uint64_t copySize) {
|
||||
|
||||
@ -170,17 +97,6 @@ BlitProperties BlitProperties::constructPropertiesForAuxTranslation(AuxTranslati
|
||||
};
|
||||
}
|
||||
|
||||
BlitterConstants::BlitDirection BlitProperties::obtainBlitDirection(uint32_t commandType) {
|
||||
if (CL_COMMAND_WRITE_BUFFER == commandType) {
|
||||
return BlitterConstants::BlitDirection::HostPtrToBuffer;
|
||||
} else if (CL_COMMAND_READ_BUFFER == commandType) {
|
||||
return BlitterConstants::BlitDirection::BufferToHostPtr;
|
||||
} else {
|
||||
UNRECOVERABLE_IF(CL_COMMAND_COPY_BUFFER != commandType);
|
||||
return BlitterConstants::BlitDirection::BufferToBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
void BlitProperties::setupDependenciesForAuxTranslation(BlitPropertiesContainer &blitPropertiesContainer, TimestampPacketDependencies ×tampPacketDependencies,
|
||||
TimestampPacketContainer &kernelTimestamps, const CsrDependencies &depsFromEvents,
|
||||
CommandStreamReceiver &gpguCsr, CommandStreamReceiver &bcsCsr) {
|
||||
|
@ -14,8 +14,6 @@
|
||||
#include <cstdint>
|
||||
|
||||
namespace NEO {
|
||||
struct BuiltinOpParams;
|
||||
class Context;
|
||||
class CommandStreamReceiver;
|
||||
class GraphicsAllocation;
|
||||
class LinearStream;
|
||||
@ -37,10 +35,6 @@ struct BlitProperties {
|
||||
uint64_t hostAllocGpuVa, size_t hostPtrOffset,
|
||||
size_t copyOffset, uint64_t copySize);
|
||||
|
||||
static BlitProperties constructProperties(BlitterConstants::BlitDirection blitDirection,
|
||||
CommandStreamReceiver &commandStreamReceiver,
|
||||
const BuiltinOpParams &builtinOpParams);
|
||||
|
||||
static BlitProperties constructPropertiesForCopyBuffer(GraphicsAllocation *dstAllocation, GraphicsAllocation *srcAllocation,
|
||||
size_t dstOffset, size_t srcOffset, uint64_t copySize);
|
||||
|
||||
|
97
runtime/helpers/cl_blit_properties.h
Normal file
97
runtime/helpers/cl_blit_properties.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/built_ins/builtins_dispatch_builder.h"
|
||||
#include "runtime/helpers/blit_commands_helper.h"
|
||||
|
||||
#include "CL/cl.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
struct ClBlitProperties {
|
||||
static BlitProperties constructProperties(BlitterConstants::BlitDirection blitDirection,
|
||||
CommandStreamReceiver &commandStreamReceiver,
|
||||
const BuiltinOpParams &builtinOpParams) {
|
||||
if (BlitterConstants::BlitDirection::BufferToBuffer == blitDirection) {
|
||||
auto dstOffset = builtinOpParams.dstOffset.x + builtinOpParams.dstMemObj->getOffset();
|
||||
auto srcOffset = builtinOpParams.srcOffset.x + builtinOpParams.srcMemObj->getOffset();
|
||||
|
||||
return BlitProperties::constructPropertiesForCopyBuffer(builtinOpParams.dstMemObj->getGraphicsAllocation(),
|
||||
builtinOpParams.srcMemObj->getGraphicsAllocation(),
|
||||
dstOffset, srcOffset, builtinOpParams.size.x);
|
||||
}
|
||||
|
||||
GraphicsAllocation *gpuAllocation = nullptr;
|
||||
size_t copyOffset = 0;
|
||||
|
||||
void *hostPtr = nullptr;
|
||||
size_t hostPtrOffset = 0;
|
||||
|
||||
uint64_t memObjGpuVa = 0;
|
||||
uint64_t hostAllocGpuVa = 0;
|
||||
|
||||
GraphicsAllocation *hostAllocation = builtinOpParams.transferAllocation;
|
||||
|
||||
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) {
|
||||
// write buffer
|
||||
hostPtr = builtinOpParams.srcPtr;
|
||||
hostPtrOffset = builtinOpParams.srcOffset.x;
|
||||
copyOffset = builtinOpParams.dstOffset.x;
|
||||
|
||||
memObjGpuVa = castToUint64(builtinOpParams.dstPtr);
|
||||
hostAllocGpuVa = castToUint64(builtinOpParams.srcPtr);
|
||||
|
||||
if (builtinOpParams.dstSvmAlloc) {
|
||||
gpuAllocation = builtinOpParams.dstSvmAlloc;
|
||||
hostAllocation = builtinOpParams.srcSvmAlloc;
|
||||
} else {
|
||||
gpuAllocation = builtinOpParams.dstMemObj->getGraphicsAllocation();
|
||||
memObjGpuVa = (gpuAllocation->getGpuAddress() + builtinOpParams.dstMemObj->getOffset());
|
||||
}
|
||||
}
|
||||
|
||||
if (BlitterConstants::BlitDirection::BufferToHostPtr == blitDirection) {
|
||||
// read buffer
|
||||
hostPtr = builtinOpParams.dstPtr;
|
||||
|
||||
hostPtrOffset = builtinOpParams.dstOffset.x;
|
||||
copyOffset = builtinOpParams.srcOffset.x;
|
||||
|
||||
memObjGpuVa = castToUint64(builtinOpParams.srcPtr);
|
||||
hostAllocGpuVa = castToUint64(builtinOpParams.dstPtr);
|
||||
|
||||
if (builtinOpParams.srcSvmAlloc) {
|
||||
gpuAllocation = builtinOpParams.srcSvmAlloc;
|
||||
hostAllocation = builtinOpParams.dstSvmAlloc;
|
||||
} else {
|
||||
gpuAllocation = builtinOpParams.srcMemObj->getGraphicsAllocation();
|
||||
memObjGpuVa = (gpuAllocation->getGpuAddress() + builtinOpParams.srcMemObj->getOffset());
|
||||
}
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(BlitterConstants::BlitDirection::HostPtrToBuffer != blitDirection &&
|
||||
BlitterConstants::BlitDirection::BufferToHostPtr != blitDirection);
|
||||
|
||||
return BlitProperties::constructPropertiesForReadWriteBuffer(blitDirection, commandStreamReceiver, gpuAllocation,
|
||||
hostAllocation, hostPtr, memObjGpuVa, hostAllocGpuVa,
|
||||
hostPtrOffset, copyOffset, builtinOpParams.size.x);
|
||||
}
|
||||
|
||||
static BlitterConstants::BlitDirection obtainBlitDirection(uint32_t commandType) {
|
||||
if (CL_COMMAND_WRITE_BUFFER == commandType) {
|
||||
return BlitterConstants::BlitDirection::HostPtrToBuffer;
|
||||
} else if (CL_COMMAND_READ_BUFFER == commandType) {
|
||||
return BlitterConstants::BlitDirection::BufferToHostPtr;
|
||||
} else {
|
||||
UNRECOVERABLE_IF(CL_COMMAND_COPY_BUFFER != commandType);
|
||||
return BlitterConstants::BlitDirection::BufferToBuffer;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace NEO
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -12,7 +12,7 @@
|
||||
#include "runtime/mem_obj/mem_obj.h"
|
||||
|
||||
namespace NEO {
|
||||
class CommandQueue;
|
||||
|
||||
class Surface {
|
||||
public:
|
||||
Surface(bool isCoherent = false) : IsCoherent(isCoherent) {}
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "runtime/command_queue/gpgpu_walker.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "runtime/helpers/blit_commands_helper.h"
|
||||
#include "runtime/helpers/cl_blit_properties.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
#include "runtime/mem_obj/mem_obj_helper.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
@ -811,7 +811,7 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
|
||||
builtinOpParams.srcMemObj = subBuffer1.get();
|
||||
builtinOpParams.size.x = 1;
|
||||
|
||||
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::BufferToBuffer, csr, builtinOpParams);
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::BufferToBuffer, csr, builtinOpParams);
|
||||
|
||||
auto offset = csr.commandStream.getUsed();
|
||||
blitBuffer(&csr, blitProperties, true);
|
||||
@ -909,8 +909,8 @@ HWTEST_F(BcsTests, givenMapAllocationInBuiltinOpParamsWhenConstructingThenUseItA
|
||||
builtinOpParams.size.x = 1;
|
||||
builtinOpParams.transferAllocation = mapAllocation;
|
||||
|
||||
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToBuffer,
|
||||
csr, builtinOpParams);
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToBuffer,
|
||||
csr, builtinOpParams);
|
||||
EXPECT_EQ(mapAllocation, blitProperties.srcAllocation);
|
||||
}
|
||||
{
|
||||
@ -921,8 +921,8 @@ HWTEST_F(BcsTests, givenMapAllocationInBuiltinOpParamsWhenConstructingThenUseItA
|
||||
builtinOpParams.size.x = 1;
|
||||
builtinOpParams.transferAllocation = mapAllocation;
|
||||
|
||||
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::BufferToHostPtr,
|
||||
csr, builtinOpParams);
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::BufferToHostPtr,
|
||||
csr, builtinOpParams);
|
||||
EXPECT_EQ(mapAllocation, blitProperties.dstAllocation);
|
||||
}
|
||||
|
||||
@ -950,8 +950,8 @@ HWTEST_F(BcsTests, givenNonZeroCopySvmAllocationWhenConstructingBlitPropertiesFo
|
||||
builtinOpParams.srcPtr = reinterpret_cast<void *>(svmData->cpuAllocation->getGpuAddress());
|
||||
builtinOpParams.size.x = 1;
|
||||
|
||||
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToBuffer,
|
||||
csr, builtinOpParams);
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToBuffer,
|
||||
csr, builtinOpParams);
|
||||
EXPECT_EQ(svmData->cpuAllocation, blitProperties.srcAllocation);
|
||||
EXPECT_EQ(svmData->gpuAllocation, blitProperties.dstAllocation);
|
||||
}
|
||||
@ -963,8 +963,8 @@ HWTEST_F(BcsTests, givenNonZeroCopySvmAllocationWhenConstructingBlitPropertiesFo
|
||||
builtinOpParams.dstPtr = reinterpret_cast<void *>(svmData->cpuAllocation->getGpuAddress());
|
||||
builtinOpParams.size.x = 1;
|
||||
|
||||
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::BufferToHostPtr,
|
||||
csr, builtinOpParams);
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::BufferToHostPtr,
|
||||
csr, builtinOpParams);
|
||||
EXPECT_EQ(svmData->cpuAllocation, blitProperties.dstAllocation);
|
||||
EXPECT_EQ(svmData->gpuAllocation, blitProperties.srcAllocation);
|
||||
}
|
||||
@ -997,8 +997,8 @@ HWTEST_F(BcsTests, givenSvmAllocationWhenBlitCalledThenUsePassedPointers) {
|
||||
builtinOpParams.dstPtr = reinterpret_cast<void *>(svmData->cpuAllocation->getGpuAddress() + dstOffset);
|
||||
builtinOpParams.size.x = 1;
|
||||
|
||||
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToBuffer,
|
||||
csr, builtinOpParams);
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToBuffer,
|
||||
csr, builtinOpParams);
|
||||
EXPECT_EQ(svmData->gpuAllocation, blitProperties.srcAllocation);
|
||||
EXPECT_EQ(svmData->cpuAllocation, blitProperties.dstAllocation);
|
||||
|
||||
@ -1021,8 +1021,8 @@ HWTEST_F(BcsTests, givenSvmAllocationWhenBlitCalledThenUsePassedPointers) {
|
||||
builtinOpParams.srcPtr = reinterpret_cast<void *>(svmData->gpuAllocation + srcOffset);
|
||||
builtinOpParams.size.x = 1;
|
||||
|
||||
auto blitProperties = BlitProperties::constructProperties(BlitterConstants::BlitDirection::BufferToHostPtr,
|
||||
csr, builtinOpParams);
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::BufferToHostPtr,
|
||||
csr, builtinOpParams);
|
||||
|
||||
auto offset = csr.commandStream.getUsed();
|
||||
blitBuffer(&csr, blitProperties, true);
|
||||
|
Reference in New Issue
Block a user