From 695ef4877aa26c8a1dd37e2d6353a5f2fefac9e8 Mon Sep 17 00:00:00 2001 From: Arek G Date: Wed, 4 Jun 2025 10:09:27 +0000 Subject: [PATCH] feature: Add interface for Ext area regarding payload args in zebin spec Related-To: NEO-14899, IGC-11358 Signed-off-by: Arek G --- .../device_binary_format/zebin/zeinfo.h | 14 ++++++++++++- .../zebin/zeinfo_decoder.cpp | 6 +++++- .../zebin/zeinfo_decoder.h | 1 + .../zebin/zeinfo_decoder_ext.cpp | 16 ++++++++++++++ .../zebin/zeinfo_decoder_ext.h | 4 ++++ .../device_binary_format/CMakeLists.txt | 3 ++- .../zebin_decoder_exclusive_tests.cpp | 21 +++++++++++++++++++ .../zebin_decoder_tests.cpp | 12 +++++++++++ 8 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 shared/test/unit_test/device_binary_format/zebin_decoder_exclusive_tests.cpp diff --git a/shared/source/device_binary_format/zebin/zeinfo.h b/shared/source/device_binary_format/zebin/zeinfo.h index abbdfe6d9d..343159f0fa 100644 --- a/shared/source/device_binary_format/zebin/zeinfo.h +++ b/shared/source/device_binary_format/zebin/zeinfo.h @@ -663,7 +663,19 @@ inline constexpr OffsetT offset = -1; inline constexpr BtiValueT btiValue = -1; } // namespace Defaults -struct PayloadArgumentBaseT { +struct PayloadArgumentExtT; +PayloadArgumentExtT *allocatePayloadArgumentExt(); +void freePayloadArgumentExt(PayloadArgumentExtT *); + +struct PayloadArgumentBaseT final { + PayloadArgumentBaseT() { + pPayArgExt = allocatePayloadArgumentExt(); + } + ~PayloadArgumentBaseT() { + freePayloadArgumentExt(pPayArgExt); + } + PayloadArgumentExtT *pPayArgExt = nullptr; + ArgTypeT argType = argTypeUnknown; OffsetT offset = Defaults::offset; SourceOffseT sourceOffset = Defaults::sourceOffset; diff --git a/shared/source/device_binary_format/zebin/zeinfo_decoder.cpp b/shared/source/device_binary_format/zebin/zeinfo_decoder.cpp index 8ba553c1b5..64980c2fee 100644 --- a/shared/source/device_binary_format/zebin/zeinfo_decoder.cpp +++ b/shared/source/device_binary_format/zebin/zeinfo_decoder.cpp @@ -1107,7 +1107,8 @@ DecodeError readZeInfoPayloadArguments(const Yaml::YamlParser &parser, const Yam for (const auto &payloadArgumentMemberNd : parser.createChildrenRange(payloadArgumentNd)) { auto key = parser.readKey(payloadArgumentMemberNd); if (Tags::Kernel::PayloadArgument::argType == key) { - validPayload &= readZeInfoEnumChecked(parser, payloadArgumentMemberNd, payloadArgMetadata.argType, context, outErrReason); + validPayload &= readZeInfoArgTypeNameCheckedExt(parser, payloadArgumentMemberNd, payloadArgMetadata) || + readZeInfoEnumChecked(parser, payloadArgumentMemberNd, payloadArgMetadata.argType, context, outErrReason); } else if (Tags::Kernel::PayloadArgument::argIndex == key) { validPayload &= parser.readValueChecked(payloadArgumentMemberNd, payloadArgMetadata.argIndex); outMaxPayloadArgumentIndex = std::max(outMaxPayloadArgumentIndex, payloadArgMetadata.argIndex); @@ -1207,6 +1208,9 @@ DecodeError populateKernelPayloadArgument(NEO::KernelDescriptor &dst, const Kern switch (src.argType) { default: + if (DecodeError::success == populateKernelPayloadArgumentExt(dst, src, outErrReason)) { + return DecodeError::success; + } outErrReason.append("DeviceBinaryFormat::zebin : Invalid arg type in cross thread data section in context of : " + kernelName + ".\n"); return DecodeError::invalidBinary; // unsupported diff --git a/shared/source/device_binary_format/zebin/zeinfo_decoder.h b/shared/source/device_binary_format/zebin/zeinfo_decoder.h index 85e18469c9..ac512413e7 100644 --- a/shared/source/device_binary_format/zebin/zeinfo_decoder.h +++ b/shared/source/device_binary_format/zebin/zeinfo_decoder.h @@ -22,6 +22,7 @@ namespace Zebin::ZeInfo { inline constexpr NEO::Zebin::ZeInfo::Types::Version zeInfoDecoderVersion{1, 54}; using KernelExecutionEnvBaseT = Types::Kernel::ExecutionEnv::ExecutionEnvBaseT; +using KernelPayloadArgBaseT = Types::Kernel::PayloadArgument::PayloadArgumentBaseT; template bool readZeInfoValueChecked(const NEO::Yaml::YamlParser &parser, const NEO::Yaml::Node &node, T &outValue, ConstStringRef context, std::string &outErrReason); diff --git a/shared/source/device_binary_format/zebin/zeinfo_decoder_ext.cpp b/shared/source/device_binary_format/zebin/zeinfo_decoder_ext.cpp index c7f9d3b561..5504a86587 100644 --- a/shared/source/device_binary_format/zebin/zeinfo_decoder_ext.cpp +++ b/shared/source/device_binary_format/zebin/zeinfo_decoder_ext.cpp @@ -17,6 +17,10 @@ void readZeInfoValueCheckedExtra(const NEO::Yaml::YamlParser &parser, const NEO: encounterUnknownZeInfoAttribute(entry.str(), outErrReason, outWarning, error); } +bool readZeInfoArgTypeNameCheckedExt(const NEO::Yaml::YamlParser &parser, const NEO::Yaml::Node &payloadArgumentMemberNd, KernelPayloadArgBaseT &outKernelPayArg) { + return false; +} + namespace Types::Kernel::ExecutionEnv { ExecutionEnvExt *allocateExecEnvExt() { return nullptr; @@ -28,4 +32,16 @@ void freeExecEnvExt(ExecutionEnvExt *envExt) { void populateKernelExecutionEnvironmentExt(KernelDescriptor &dst, const KernelExecutionEnvBaseT &execEnv, const Types::Version &srcZeInfoVersion) { } +namespace Types::Kernel::PayloadArgument { +PayloadArgumentExtT *allocatePayloadArgumentExt() { + return nullptr; +} +void freePayloadArgumentExt(PayloadArgumentExtT *pPayArgExt) { +} +} // namespace Types::Kernel::PayloadArgument + +DecodeError populateKernelPayloadArgumentExt(NEO::KernelDescriptor &dst, const KernelPayloadArgBaseT &src, std::string &outErrReason) { + return DecodeError::unhandledBinary; +} + } // namespace NEO::Zebin::ZeInfo diff --git a/shared/source/device_binary_format/zebin/zeinfo_decoder_ext.h b/shared/source/device_binary_format/zebin/zeinfo_decoder_ext.h index c1c20505cc..f2b1b248a0 100644 --- a/shared/source/device_binary_format/zebin/zeinfo_decoder_ext.h +++ b/shared/source/device_binary_format/zebin/zeinfo_decoder_ext.h @@ -13,4 +13,8 @@ namespace NEO::Zebin::ZeInfo { void populateKernelExecutionEnvironmentExt(KernelDescriptor &dst, const KernelExecutionEnvBaseT &execEnv, const Types::Version &srcZeInfoVersion); +DecodeError populateKernelPayloadArgumentExt(NEO::KernelDescriptor &dst, const KernelPayloadArgBaseT &src, std::string &outErrReason); + +bool readZeInfoArgTypeNameCheckedExt(const NEO::Yaml::YamlParser &parser, const NEO::Yaml::Node &payloadArgumentMemberNd, KernelPayloadArgBaseT &outKernelPayArg); + } // namespace NEO::Zebin::ZeInfo diff --git a/shared/test/unit_test/device_binary_format/CMakeLists.txt b/shared/test/unit_test/device_binary_format/CMakeLists.txt index 7cbed51666..e4dfabc407 100644 --- a/shared/test/unit_test/device_binary_format/CMakeLists.txt +++ b/shared/test/unit_test/device_binary_format/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020-2024 Intel Corporation +# Copyright (C) 2020-2025 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -23,6 +23,7 @@ target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/yaml/yaml_parser_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/zebin_debug_binary_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/zebin_decoder_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/${BRANCH_DIR_SUFFIX}zebin_decoder_exclusive_tests.cpp ) add_subdirectories() diff --git a/shared/test/unit_test/device_binary_format/zebin_decoder_exclusive_tests.cpp b/shared/test/unit_test/device_binary_format/zebin_decoder_exclusive_tests.cpp new file mode 100644 index 0000000000..00dade2546 --- /dev/null +++ b/shared/test/unit_test/device_binary_format/zebin_decoder_exclusive_tests.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/device_binary_format/zebin/zeinfo_decoder_ext.h" +#include "shared/source/program/kernel_info.h" +#include "shared/test/common/test_macros/test.h" + +using namespace NEO::Zebin; + +TEST(ExtBaseKernelDescriptorAndPayloadArgumentPointers, givenKernelDescriptorAndPayloadArgWhenProperlyCreatedThenExtraFieldsSetToNullPtrValue) { + NEO::KernelDescriptor kd; + NEO::Zebin::ZeInfo::KernelPayloadArgBaseT arg; + + EXPECT_EQ(nullptr, kd.kernelDescriptorExt); + EXPECT_EQ(nullptr, arg.pPayArgExt); + EXPECT_EQ(nullptr, NEO::Zebin::ZeInfo::Types::Kernel::PayloadArgument::allocatePayloadArgumentExt()); +} diff --git a/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp b/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp index 4c35bab3f1..17550ff051 100644 --- a/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp +++ b/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp @@ -10,6 +10,7 @@ #include "shared/source/device_binary_format/device_binary_formats.h" #include "shared/source/device_binary_format/zebin/zebin_decoder.h" #include "shared/source/device_binary_format/zebin/zebin_elf.h" +#include "shared/source/device_binary_format/zebin/zeinfo_decoder_ext.h" #include "shared/source/device_binary_format/zebin/zeinfo_enum_lookup.h" #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/compiler_product_helper.h" @@ -2389,6 +2390,17 @@ kernels: EXPECT_FALSE(kernelDescriptor->kernelAttributes.flags.isInvalid); } +TEST(BaseKernelDescriptorAndPayloadArgumentPoinetrsExt, givenKernelDescriptorAndPayloadArgWhenProperlyCreatedThenExtraFieldsSetToNullPtr) { + NEO::KernelDescriptor kd; + NEO::Zebin::ZeInfo::KernelPayloadArgBaseT arg; + + if (nullptr != kd.kernelDescriptorExt) { + EXPECT_NE(nullptr, arg.pPayArgExt); + } else { + EXPECT_EQ(nullptr, arg.pPayArgExt); + } +} + TEST(PopulateKernelSourceAttributes, GivenInvalidKernelAttributeWhenPopulatingKernelSourceAttributesThenKernelIsInvalidFlagIsSet) { NEO::KernelDescriptor kd; NEO::Zebin::ZeInfo::KernelAttributesBaseT attributes;