fix: L0 Copy extensions validation

Signed-off-by: Radoslaw Jablonski <radoslaw.jablonski@intel.com>
This commit is contained in:
Radoslaw Jablonski
2025-09-30 11:05:17 +00:00
committed by Compute-Runtime-Automation
parent 393c4d0985
commit be3427a9e8
5 changed files with 62 additions and 6 deletions

View File

@@ -66,6 +66,12 @@ void CommandList::setAdditionalBlitPropertiesFromMemoryCopyParams(NEO::BlitPrope
}
ze_result_t CommandList::obtainMemoryCopyParamsFromExtensions(const ze_base_desc_t *desc, CmdListMemoryCopyParams &memoryCopyParams) const {
if (desc) {
PRINT_DEBUG_STRING(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Could not recognize provided extension, stype: 0x%x.\n",
desc->stype);
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
return ZE_RESULT_SUCCESS;
}

View File

@@ -2103,7 +2103,10 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopyWithParameters
uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents) {
CmdListMemoryCopyParams memoryCopyParams{};
obtainMemoryCopyParamsFromExtensions(static_cast<const ze_base_desc_t *>(pNext), memoryCopyParams);
ze_result_t ret = obtainMemoryCopyParamsFromExtensions(static_cast<const ze_base_desc_t *>(pNext), memoryCopyParams);
if (ret) {
return ret;
}
return appendMemoryCopy(dstptr, srcptr, size, hSignalEvent, numWaitEvents, phWaitEvents, memoryCopyParams);
}
@@ -2753,7 +2756,10 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryFillWithParameters
uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents) {
CmdListMemoryCopyParams memoryCopyParams{};
obtainMemoryCopyParamsFromExtensions(static_cast<const ze_base_desc_t *>(pNext), memoryCopyParams);
ze_result_t ret = obtainMemoryCopyParamsFromExtensions(static_cast<const ze_base_desc_t *>(pNext), memoryCopyParams);
if (ret) {
return ret;
}
return appendMemoryFill(ptr, pattern, patternSize, size, hSignalEvent, numWaitEvents, phWaitEvents, memoryCopyParams);
}

View File

@@ -484,15 +484,35 @@ HWTEST_F(CommandListTest, givenUnrecognizedDescriptorWhenObtainLaunchParamsFromE
EXPECT_EQ(std::string("Could not recognize provided extension, stype: 0x12.\n"), output);
}
HWTEST_F(CommandListTest, WhenObtainMemoryCopyParamsFromExtensionsIsCalledThenSuccessIsReturned) {
HWTEST_F(CommandListTest, givenEmptyExtWhenObtainMemoryCopyParamsFromExtensionsIsCalledThenSuccessIsReturned) {
CmdListMemoryCopyParams memoryCopyParams{};
ze_base_desc_t desc{};
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<FamilyType::gfxCoreFamily>>>();
commandList->initialize(device, NEO::EngineGroupType::renderCompute, 0u);
commandList->initialize(device, NEO::EngineGroupType::copy, 0u);
ze_result_t result = commandList->obtainMemoryCopyParamsFromExtensions(nullptr, memoryCopyParams);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
}
HWTEST_F(CommandListTest, givenUnrecognizedExtWhenObtainMemoryCopyParamsFromExtensionsIsCalledThenErrorIsReturned) {
CmdListMemoryCopyParams memoryCopyParams{};
ze_base_desc_t desc{
.stype = static_cast<ze_structure_type_t>(10),
};
StreamCapture capture;
capture.captureStderr();
DebugManagerStateRestore restorer{};
debugManager.flags.PrintDebugMessages.set(true);
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<FamilyType::gfxCoreFamily>>>();
commandList->initialize(device, NEO::EngineGroupType::copy, 0u);
ze_result_t result = commandList->obtainMemoryCopyParamsFromExtensions(&desc, memoryCopyParams);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
std::string output = capture.getCapturedStderr();
EXPECT_EQ(std::string("Could not recognize provided extension, stype: 0xa.\n"), output);
}
HWTEST_F(CommandListTest, givenComputeCommandListAnd2dRegionWhenMemoryCopyRegionInUsmHostAllocationCalledThenBuiltinFlagAndDestinationAllocSystemIsSet) {

View File

@@ -1396,6 +1396,18 @@ HWTEST2_F(AppendMemoryCopyTests, givenCopyCommandListImmediateWithDummyBlitWaWhe
context->freeMem(buffer);
}
HWTEST_F(AppendMemoryCopyTests, givenInvalidExtWhenAppendMemoryCopyWithParametersCalledThenErrorIsReturned) {
MockCommandListCoreFamily<FamilyType::gfxCoreFamily> cmdList;
cmdList.initialize(device, NEO::EngineGroupType::copy, 0u);
uint32_t srcBuffer = 1;
uint32_t dstBuffer = 0;
ze_base_desc_t desc{};
ze_result_t result = cmdList.appendMemoryCopyWithParameters(&dstBuffer, &srcBuffer, sizeof(srcBuffer), &desc, nullptr, 0, nullptr);
EXPECT_NE(ZE_RESULT_SUCCESS, result);
}
struct StagingBuffersFixture : public AppendMemoryCopyTests {
void SetUp() override {
debugManager.flags.EnableCopyWithStagingBuffers.set(1);

View File

@@ -536,5 +536,17 @@ HWTEST2_F(AppendFillTest,
true);
}
HWTEST_F(AppendFillTest, givenInvalidExtWhenAppendMemoryFillWithParametersCalledThenErrorIsReturned) {
MockCommandList<FamilyType::gfxCoreFamily> commandList;
commandList.initialize(device, NEO::EngineGroupType::copy, 0u);
uint32_t dstBuffer = 0;
uint8_t pattern = 1;
ze_base_desc_t desc{};
ze_result_t result = commandList.appendMemoryFillWithParameters(&dstBuffer, &pattern, sizeof(pattern), sizeof(dstBuffer), &desc, nullptr, 0, nullptr);
EXPECT_NE(ZE_RESULT_SUCCESS, result);
}
} // namespace ult
} // namespace L0