From fa7d69209c8d89565a5e9a0a527b5a0999291280 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 | 39 ++++++++++++++++++- .../zebin/zeinfo_decoder.cpp | 6 ++- .../zebin/zeinfo_decoder.h | 1 + .../zebin/zeinfo_decoder_ext.cpp | 18 +++++++++ .../zebin/zeinfo_decoder_ext.h | 4 ++ .../device_binary_format/CMakeLists.txt | 1 + .../zebin_decoder_exclusive_tests.cpp | 21 ++++++++++ .../zebin_decoder_tests.cpp | 12 ++++++ 8 files changed, 100 insertions(+), 2 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..0a477fc5c7 100644 --- a/shared/source/device_binary_format/zebin/zeinfo.h +++ b/shared/source/device_binary_format/zebin/zeinfo.h @@ -12,6 +12,7 @@ #include "shared/source/utilities/const_stringref.h" #include +#include #include namespace NEO::Zebin::ZeInfo { @@ -663,7 +664,43 @@ inline constexpr OffsetT offset = -1; inline constexpr BtiValueT btiValue = -1; } // namespace Defaults -struct PayloadArgumentBaseT { +struct PayloadArgElasticPtrBaseT; +struct PayloadArgumentBaseT; +struct PayloadArgumentExtT; +PayloadArgumentExtT *allocatePayloadArgumentExt(); +void freePayloadArgumentExt(PayloadArgumentExtT *); +void copyPayloadArgumentExt(PayloadArgumentExtT *&, const PayloadArgElasticPtrBaseT &); + +struct PayloadArgElasticPtrBaseT { + PayloadArgElasticPtrBaseT() { + pPayArgExt = allocatePayloadArgumentExt(); + } + ~PayloadArgElasticPtrBaseT() { + freePayloadArgumentExt(pPayArgExt); + } + PayloadArgElasticPtrBaseT(const PayloadArgElasticPtrBaseT &src) { + copyPayloadArgumentExt(pPayArgExt, src); + } + PayloadArgElasticPtrBaseT &operator=(const PayloadArgElasticPtrBaseT &rhs) { + if (this != &rhs) { + copyPayloadArgumentExt(pPayArgExt, rhs); + } + return *this; + } + PayloadArgElasticPtrBaseT(PayloadArgElasticPtrBaseT &&src) noexcept : pPayArgExt(src.pPayArgExt) { + src.pPayArgExt = nullptr; + } + PayloadArgElasticPtrBaseT &operator=(PayloadArgElasticPtrBaseT &&rhs) noexcept { + if (this != &rhs) { + this->pPayArgExt = rhs.pPayArgExt; + rhs.pPayArgExt = nullptr; + } + return *this; + } + PayloadArgumentExtT *pPayArgExt = nullptr; +}; + +struct PayloadArgumentBaseT : PayloadArgElasticPtrBaseT { 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..bc1adcf249 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,18 @@ 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) { +} +void copyPayloadArgumentExt(PayloadArgumentExtT *&pPayArgExtOut, const PayloadArgElasticPtrBaseT &src) { +} +} // 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 a1164d7bbe..e4dfabc407 100644 --- a/shared/test/unit_test/device_binary_format/CMakeLists.txt +++ b/shared/test/unit_test/device_binary_format/CMakeLists.txt @@ -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 055f5b02a3..974e8fb83f 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;