CPU access disallowed mode and blitter amendments

Related-To: NEO-4876

Change-Id: I7d6de1a0530e9c4f8bcf302824242033d3ca724a
Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
Slawomir Milczarek 2020-10-30 09:02:18 +01:00 committed by sys_ocldev
parent 21aa8388bc
commit b7d5427f01
11 changed files with 134 additions and 14 deletions

View File

@ -637,11 +637,11 @@ bool CommandQueue::queueDependenciesClearRequired() const {
}
bool CommandQueue::blitEnqueueAllowed(cl_command_type cmdType) const {
auto blitterSupported = device->getHardwareInfo().capabilityTable.blitterOperationsSupported || this->isCopyOnly;
auto blitAllowed = device->getHardwareInfo().capabilityTable.blitterOperationsSupported || this->isCopyOnly;
bool blitEnqueueAllowed = getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled() || this->isCopyOnly;
if (DebugManager.flags.EnableBlitterForEnqueueOperations.get() != -1) {
blitAllowed &= static_cast<bool>(DebugManager.flags.EnableBlitterForEnqueueOperations.get());
blitEnqueueAllowed = DebugManager.flags.EnableBlitterForEnqueueOperations.get();
}
switch (cmdType) {
@ -654,7 +654,7 @@ bool CommandQueue::blitEnqueueAllowed(cl_command_type cmdType) const {
case CL_COMMAND_SVM_MEMCPY:
case CL_COMMAND_READ_IMAGE:
case CL_COMMAND_WRITE_IMAGE:
return blitAllowed;
return blitterSupported && blitEnqueueAllowed;
default:
return false;
}

View File

@ -1160,16 +1160,29 @@ TEST(CommandQueue, giveClCommandWhenCallingBlitEnqueueAllowedThenReturnCorrectVa
MockCommandQueue queue(&context, context.getDevice(0), 0);
hwInfo->capabilityTable.blitterOperationsSupported = true;
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_READ_BUFFER));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_BUFFER));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_BUFFER));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_READ_BUFFER_RECT));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_BUFFER_RECT));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_BUFFER_RECT));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_SVM_MEMCPY));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_READ_IMAGE));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_IMAGE));
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_IMAGE));
if (queue.getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) {
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_READ_BUFFER));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_BUFFER));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_BUFFER));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_READ_BUFFER_RECT));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_BUFFER_RECT));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_BUFFER_RECT));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_SVM_MEMCPY));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_READ_IMAGE));
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_IMAGE));
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_IMAGE));
} else {
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_READ_BUFFER));
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_BUFFER));
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_BUFFER));
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_READ_BUFFER_RECT));
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_BUFFER_RECT));
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_BUFFER_RECT));
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_SVM_MEMCPY));
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_READ_IMAGE));
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_IMAGE));
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_IMAGE));
}
}
TEST(CommandQueue, givenCopySizeAndOffsetWhenCallingBlitEnqueueImageAllowedThenReturnCorrectValue) {

View File

@ -433,6 +433,7 @@ HWTEST_F(EnqueueReadImageTest, GivenImage1DThatIsZeroCopyWhenReadImageWithTheSam
HWTEST_F(EnqueueReadImageTest, givenDeviceWithBlitterSupportWhenEnqueueReadImageThenBlitEnqueueImageAllowedReturnsCorrectResult) {
DebugManagerStateRestore restorer;
DebugManager.flags.OverrideInvalidEngineWithDefault.set(1);
DebugManager.flags.EnableBlitterForEnqueueOperations.set(1);
auto &capabilityTable = pClDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable;
capabilityTable.blitterOperationsSupported = true;

View File

@ -205,6 +205,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueWriteImageTest, WhenWritingImageThenMediaVfeS
HWTEST_F(EnqueueWriteImageTest, givenDeviceWithBlitterSupportWhenEnqueueWriteImageThenBlitEnqueueImageAllowedReturnsCorrectResult) {
DebugManagerStateRestore restorer;
DebugManager.flags.OverrideInvalidEngineWithDefault.set(1);
DebugManager.flags.EnableBlitterForEnqueueOperations.set(1);
auto &capabilityTable = pClDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable;
capabilityTable.blitterOperationsSupported = true;

View File

@ -111,3 +111,19 @@ DG1TEST_F(HwHelperTestDg1, givenDg1WhenSteppingB0ThenIntegerDivisionEmulationIsN
auto &helper = HwHelper::get(renderCoreFamily);
EXPECT_FALSE(helper.isForceEmuInt32DivRemSPWARequired(hardwareInfo));
}
DG1TEST_F(HwHelperTestDg1, givenDg1WhenObtainingBlitterPreferenceThenReturnFalse) {
auto &helper = HwHelper::get(renderCoreFamily);
EXPECT_FALSE(helper.obtainBlitterPreference(hardwareInfo));
}
DG1TEST_F(HwHelperTestDg1, givenDg1WhenGettingLocalMemoryAccessModeThenReturnCpuAccessDefault) {
struct MockHwHelper : HwHelperHw<FamilyType> {
using HwHelper::getDefaultLocalMemoryAccessMode;
};
auto hwHelper = static_cast<MockHwHelper &>(HwHelper::get(renderCoreFamily));
EXPECT_EQ(LocalMemoryAccessMode::Default, hwHelper.getDefaultLocalMemoryAccessMode(*defaultHwInfo));
}

View File

@ -12,6 +12,7 @@
#include "opencl/test/unit_test/gen12lp/special_ult_helper_gen12lp.h"
#include "opencl/test/unit_test/helpers/hw_helper_tests.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include "engine_node.h"
@ -426,6 +427,39 @@ GEN12LPTEST_F(HwHelperTestGen12Lp, givenL1ForceDisabledWhenRequestingMocsThenPro
EXPECT_EQ(mocsL3, helper.getMocsIndex(*gmmHelper, true, true));
}
GEN12LPTEST_F(HwHelperTestGen12Lp, givenAllocationTypeWithCpuAccessRequiredWhenCpuAccessIsDisallowedThenSystemMemoryIsRequested) {
DebugManagerStateRestore restore;
DebugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::CpuAccessDisallowed));
const GraphicsAllocation::AllocationType allocationTypesToUseSystemMemory[] = {
GraphicsAllocation::AllocationType::COMMAND_BUFFER,
GraphicsAllocation::AllocationType::CONSTANT_SURFACE,
GraphicsAllocation::AllocationType::GLOBAL_SURFACE,
GraphicsAllocation::AllocationType::INTERNAL_HEAP,
GraphicsAllocation::AllocationType::LINEAR_STREAM,
GraphicsAllocation::AllocationType::PIPE,
GraphicsAllocation::AllocationType::PRINTF_SURFACE,
GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER,
GraphicsAllocation::AllocationType::RING_BUFFER,
GraphicsAllocation::AllocationType::SEMAPHORE_BUFFER};
MockMemoryManager mockMemoryManager;
for (auto allocationType : allocationTypesToUseSystemMemory) {
AllocationData allocData{};
AllocationProperties properties(mockRootDeviceIndex, true, 10, allocationType, false, mockDeviceBitfield);
mockMemoryManager.getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties));
EXPECT_TRUE(allocData.flags.requiresCpuAccess);
EXPECT_TRUE(allocData.flags.useSystemMemory);
}
AllocationData allocData{};
AllocationProperties properties(mockRootDeviceIndex, true, 10, GraphicsAllocation::AllocationType::BUFFER, false, mockDeviceBitfield);
mockMemoryManager.getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties));
EXPECT_FALSE(allocData.flags.requiresCpuAccess);
EXPECT_FALSE(allocData.flags.useSystemMemory);
}
HWTEST2_F(HwHelperTestGen12Lp, givenRevisionEnumThenProperValueForIsWorkaroundRequiredIsReturned, IsRKL) {
std::vector<unsigned short> steppings;
HardwareInfo hardwareInfo = *defaultHwInfo;

View File

@ -75,3 +75,19 @@ TGLLPTEST_F(HwHelperTestGen12Lp, givenTgllpAndVariousSteppingsWhenGettingIsWorka
}
}
}
TGLLPTEST_F(HwHelperTestGen12Lp, givenTgllpWhenObtainingBlitterPreferenceThenReturnFalse) {
auto &helper = HwHelper::get(renderCoreFamily);
EXPECT_FALSE(helper.obtainBlitterPreference(hardwareInfo));
}
TGLLPTEST_F(HwHelperTestGen12Lp, givenTgllpWhenGettingLocalMemoryAccessModeThenReturnCpuAccessDefault) {
struct MockHwHelper : HwHelperHw<FamilyType> {
using HwHelper::getDefaultLocalMemoryAccessMode;
};
auto hwHelper = static_cast<MockHwHelper &>(HwHelper::get(renderCoreFamily));
EXPECT_EQ(LocalMemoryAccessMode::Default, hwHelper.getDefaultLocalMemoryAccessMode(*defaultHwInfo));
}

View File

@ -68,5 +68,13 @@ bool forceBlitterUseForGlobalBuffers(const HardwareInfo &hwInfo, GraphicsAllocat
return false;
}
bool obtainBlitterPreference(const HardwareInfo &hwInfo) {
return false;
}
LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) {
return LocalMemoryAccessMode::Default;
}
} // namespace Gen12LPHelpers
} // namespace NEO

View File

@ -20,6 +20,7 @@ class GraphicsAllocation;
struct HardwareInfo;
struct PipelineSelectArgs;
class Image;
enum class LocalMemoryAccessMode;
namespace Gen12LPHelpers {
bool pipeControlWaRequired(PRODUCT_FAMILY productFamily);
@ -38,6 +39,8 @@ bool isOffsetToSkipSetFFIDGPWARequired(const HardwareInfo &hwInfo);
bool isForceEmuInt32DivRemSPWARequired(const HardwareInfo &hwInfo);
bool is3DPipelineSelectWARequired(const HardwareInfo &hwInfo);
bool forceBlitterUseForGlobalBuffers(const HardwareInfo &hwInfo, GraphicsAllocation *allocation);
bool obtainBlitterPreference(const HardwareInfo &hwInfo);
LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo);
} // namespace Gen12LPHelpers
} // namespace NEO

View File

@ -98,5 +98,13 @@ bool forceBlitterUseForGlobalBuffers(const HardwareInfo &hwInfo, GraphicsAllocat
return false;
}
bool obtainBlitterPreference(const HardwareInfo &hwInfo) {
return false;
}
LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) {
return LocalMemoryAccessMode::Default;
}
} // namespace Gen12LPHelpers
} // namespace NEO

View File

@ -288,6 +288,26 @@ bool MemorySynchronizationCommands<TGLLPFamily>::isPipeControlPriorToPipelineSel
return MemorySynchronizationCommands<TGLLPFamily>::isPipeControlWArequired(hwInfo);
}
template <>
bool HwHelperHw<Family>::obtainBlitterPreference(const HardwareInfo &hwInfo) const {
return Gen12LPHelpers::obtainBlitterPreference(hwInfo);
}
template <>
inline LocalMemoryAccessMode HwHelperHw<Family>::getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const {
return Gen12LPHelpers::getDefaultLocalMemoryAccessMode(hwInfo);
}
template <>
void HwHelperHw<TGLLPFamily>::setExtraAllocationData(AllocationData &allocationData, const AllocationProperties &properties, const HardwareInfo &hwInfo) const {
HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
if (hwHelper.getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed) {
if (GraphicsAllocation::isCpuAccessRequired(properties.allocationType)) {
allocationData.flags.useSystemMemory = true;
}
}
}
template class HwHelperHw<Family>;
template class FlatBatchBufferHelperHw<Family>;
template struct MemorySynchronizationCommands<Family>;