diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 1ab265b2b3..b40ffe6af8 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -637,6 +637,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableSetPair, -1, "Use SET_PAIR to pair two buf DECLARE_DEBUG_VARIABLE(int32_t, ForcePreferredAllocationMethod, -1, "Sets preferred allocation method for Wddm paths; values = -1: driver default, 0: UseUmdSystemPtr, 1: AllocateByKmd") DECLARE_DEBUG_VARIABLE(int32_t, EventTimestampRefreshIntervalInMilliSec, -1, "-1: use driver default, This value sets the refresh interval for getting synchronized GPU and CPU timestamp") DECLARE_DEBUG_VARIABLE(int64_t, ReadOnlyAllocationsTypeMask, 0, "0: default, >0: (bitmask) for given Graphics Allocation Type, set as read only resource.") +DECLARE_DEBUG_VARIABLE(bool, IgnoreZebinUnknownAttributes, false, "enable to treat unknown zebin attributes as warning instead of error"); /* Binary Cache */ DECLARE_DEBUG_VARIABLE(bool, BinaryCacheTrace, false, "enable cl_cache to produce .trace files with information about hash computation") diff --git a/shared/source/device_binary_format/device_binary_formats.h b/shared/source/device_binary_format/device_binary_formats.h index 4d563275d1..eb0e5e8e25 100644 --- a/shared/source/device_binary_format/device_binary_formats.h +++ b/shared/source/device_binary_format/device_binary_formats.h @@ -34,7 +34,8 @@ enum class DecodeError : uint8_t { success, undefined, invalidBinary, - unhandledBinary + unhandledBinary, + unkownZeinfoAttribute }; enum class GeneratorType : uint8_t { diff --git a/shared/source/device_binary_format/zebin/zeinfo_decoder.cpp b/shared/source/device_binary_format/zebin/zeinfo_decoder.cpp index c86a5e5de0..8a44ecab00 100644 --- a/shared/source/device_binary_format/zebin/zeinfo_decoder.cpp +++ b/shared/source/device_binary_format/zebin/zeinfo_decoder.cpp @@ -46,12 +46,23 @@ DecodeError validateZeInfoVersion(const Types::Version &receivedZeInfoVersion, s return DecodeError::unhandledBinary; } if (receivedZeInfoVersion.minor > zeInfoDecoderVersion.minor) { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Minor version : " + std::to_string(receivedZeInfoVersion.minor) + " is newer than available in decoder : " + std::to_string(zeInfoDecoderVersion.minor) + " - some features may be skipped\n"); + outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Minor version : " + std::to_string(receivedZeInfoVersion.minor) + " is newer than available in decoder : " + std::to_string(zeInfoDecoderVersion.minor) + "\n"); } return DecodeError::success; } -void extractZeInfoSections(const Yaml::YamlParser &parser, ZeInfoSections &outZeInfoSections, std::string &outWarning) { +void encounterUnknownZeInfoAttribute(const std::string &entryDescriptor, std::string &outErrReason, std::string &outWarning, DecodeError &errCode) { + auto formattedMessage = "DeviceBinaryFormat::zebin::.ze_info : Unknown entry " + entryDescriptor + "\n"; + if (debugManager.flags.IgnoreZebinUnknownAttributes.get()) { + outWarning.append(formattedMessage); + } else { + outErrReason.append(formattedMessage); + errCode = DecodeError::unkownZeinfoAttribute; + } +} + +DecodeError extractZeInfoSections(const Yaml::YamlParser &parser, ZeInfoSections &outZeInfoSections, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; for (const auto &globalScopeNd : parser.createChildrenRange(*parser.getRoot())) { auto key = parser.readKey(globalScopeNd); if (Tags::kernels == key) { @@ -63,12 +74,14 @@ void extractZeInfoSections(const Yaml::YamlParser &parser, ZeInfoSections &outZe } else if (Tags::functions == key) { outZeInfoSections.functions.push_back(&globalScopeNd); } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + parser.readKey(globalScopeNd).str() + "\" in global scope of .ze_info\n"); + encounterUnknownZeInfoAttribute("\"" + parser.readKey(globalScopeNd).str() + "\" in global scope of .ze_info", outErrReason, outWarning, err); } } + return err; } -void extractZeInfoKernelSections(const NEO::Yaml::YamlParser &parser, const NEO::Yaml::Node &kernelNd, ZeInfoKernelSections &outZeInfoKernelSections, ConstStringRef context, std::string &outWarning) { +DecodeError extractZeInfoKernelSections(const NEO::Yaml::YamlParser &parser, const NEO::Yaml::Node &kernelNd, ZeInfoKernelSections &outZeInfoKernelSections, ConstStringRef context, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; for (const auto &kernelMetadataNd : parser.createChildrenRange(kernelNd)) { auto key = parser.readKey(kernelMetadataNd); if (Tags::Kernel::name == key) { @@ -92,9 +105,10 @@ void extractZeInfoKernelSections(const NEO::Yaml::YamlParser &parser, const NEO: } else if (Tags::Kernel::inlineSamplers == key) { outZeInfoKernelSections.inlineSamplersNd.push_back(&kernelMetadataNd); } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + parser.readKey(kernelMetadataNd).str() + "\" in context of : " + context.str() + "\n"); + encounterUnknownZeInfoAttribute("\"" + parser.readKey(kernelMetadataNd).str() + "\" in context of : " + context.str(), outErrReason, outWarning, err); } } + return err; } bool validateZeInfoSectionsCount(const ZeInfoSections &zeInfoSections, std::string &outErrReason) { @@ -181,6 +195,7 @@ DecodeError readZeInfoGlobalHostAceessTable(const NEO::Yaml::YamlParser &parser, ZeInfoGlobalHostAccessTables &outDeviceNameToHostTable, ConstStringRef context, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; bool validTable = true; for (const auto &globalHostAccessNameNd : parser.createChildrenRange(node)) { outDeviceNameToHostTable.resize(outDeviceNameToHostTable.size() + 1); @@ -192,11 +207,11 @@ DecodeError readZeInfoGlobalHostAceessTable(const NEO::Yaml::YamlParser &parser, } else if (Tags::GlobalHostAccessTable::hostName == key) { validTable &= readZeInfoValueChecked(parser, globalHostAccessNameMemberNd, globalHostAccessMetadata.hostName, context, outErrReason); } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + key.str() + "\" for payload argument in context of " + context.str() + "\n"); + encounterUnknownZeInfoAttribute("\"" + key.str() + "\" for payload argument in context of " + context.str(), outErrReason, outWarning, err); } } } - return validTable ? DecodeError::success : DecodeError::invalidBinary; + return validTable ? err : DecodeError::invalidBinary; } template @@ -254,7 +269,7 @@ DecodeError populateZeInfoVersion(Types::Version &dst, ConstStringRef &versionSt DecodeError populateExternalFunctionsMetadata(NEO::ProgramInfo &dst, NEO::Yaml::YamlParser &yamlParser, const NEO::Yaml::Node &functionNd, std::string &outErrReason, std::string &outWarning) { ConstStringRef functionName; Types::Function::ExecutionEnv::ExecutionEnvBaseT execEnv = {}; - bool isValid = true; + DecodeError err = DecodeError::success; for (const auto &functionMetadataNd : yamlParser.createChildrenRange(functionNd)) { auto key = yamlParser.readKey(functionMetadataNd); @@ -262,15 +277,15 @@ DecodeError populateExternalFunctionsMetadata(NEO::ProgramInfo &dst, NEO::Yaml:: functionName = yamlParser.readValueNoQuotes(functionMetadataNd); } else if (Tags::Function::executionEnv == key) { auto execEnvErr = readZeInfoExecutionEnvironment(yamlParser, functionMetadataNd, execEnv, "external functions", outErrReason, outWarning); - if (execEnvErr != DecodeError::success) { - isValid = false; + if (DecodeError::success == err) { + err = execEnvErr; } } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + yamlParser.readKey(functionMetadataNd).str() + "\" in context of : external functions\n"); + encounterUnknownZeInfoAttribute("\"" + yamlParser.readKey(functionMetadataNd).str() + "\" in context of : external functions", outErrReason, outWarning, err); } } - if (isValid) { + if (DecodeError::success == err) { NEO::ExternalFunctionInfo extFunInfo{}; extFunInfo.functionName = functionName.str(); extFunInfo.barrierCount = static_cast(execEnv.barrierCount); @@ -278,10 +293,9 @@ DecodeError populateExternalFunctionsMetadata(NEO::ProgramInfo &dst, NEO::Yaml:: extFunInfo.simdSize = static_cast(execEnv.simdSize); extFunInfo.hasRTCalls = execEnv.hasRTCalls; dst.externalFunctions.push_back(extFunInfo); - return DecodeError::success; - } else { - return DecodeError::invalidBinary; } + + return err; } DecodeError readKernelMiscArgumentInfos(const NEO::Yaml::YamlParser &parser, const NEO::Yaml::Node &node, KernelMiscArgInfos &kernelMiscArgInfosVec, std::string &outErrReason, std::string &outWarning) { @@ -415,10 +429,13 @@ DecodeError decodeZeInfo(ProgramInfo &dst, ConstStringRef zeInfo, std::string &o } ZeInfoSections zeInfoSections{}; - extractZeInfoSections(yamlParser, zeInfoSections, outWarning); + auto extractZeInfoSectionsError = extractZeInfoSections(yamlParser, zeInfoSections, outErrReason, outWarning); if (false == validateZeInfoSectionsCount(zeInfoSections, outErrReason)) { return DecodeError::invalidBinary; } + if (DecodeError::success != extractZeInfoSectionsError) { + return extractZeInfoSectionsError; + } Types::Version zeInfoVersion{}; auto zeInfoDecodeError = decodeZeInfoVersion(yamlParser, zeInfoSections, outErrReason, outWarning, zeInfoVersion); @@ -504,8 +521,12 @@ DecodeError decodeZeInfoKernels(ProgramInfo &dst, Yaml::YamlParser &parser, cons DecodeError decodeZeInfoKernelEntry(NEO::KernelDescriptor &dst, NEO::Yaml::YamlParser &yamlParser, const NEO::Yaml::Node &kernelNd, uint32_t grfSize, uint32_t minScratchSpaceSize, std::string &outErrReason, std::string &outWarning, const Types::Version &srcZeInfoVersion) { ZeInfoKernelSections zeInfokernelSections; - extractZeInfoKernelSections(yamlParser, kernelNd, zeInfokernelSections, ".ze_info", outWarning); - auto extractError = validateZeInfoKernelSectionsCount(zeInfokernelSections, outErrReason, outWarning); + auto extractError = extractZeInfoKernelSections(yamlParser, kernelNd, zeInfokernelSections, ".ze_info", outErrReason, outWarning); + if (DecodeError::success != extractError) { + return extractError; + } + + extractError = validateZeInfoKernelSectionsCount(zeInfokernelSections, outErrReason, outWarning); if (DecodeError::success != extractError) { return extractError; } @@ -592,6 +613,7 @@ DecodeError decodeZeInfoKernelExecutionEnvironment(KernelDescriptor &dst, Yaml:: DecodeError readZeInfoExecutionEnvironment(const Yaml::YamlParser &parser, const Yaml::Node &node, KernelExecutionEnvBaseT &outExecEnv, ConstStringRef context, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; bool validExecEnv = true; for (const auto &execEnvMetadataNd : parser.createChildrenRange(node)) { auto key = parser.readKey(execEnvMetadataNd); @@ -652,7 +674,7 @@ DecodeError readZeInfoExecutionEnvironment(const Yaml::YamlParser &parser, const } else if (Tags::Kernel::ExecutionEnv::spillSize == key) { validExecEnv &= readZeInfoValueChecked(parser, execEnvMetadataNd, outExecEnv.spillSize, context, outErrReason); } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + key.str() + "\" in context of " + context.str() + "\n"); + encounterUnknownZeInfoAttribute("\"" + key.str() + "\" in context of " + context.str(), outErrReason, outWarning, err); } } @@ -665,7 +687,7 @@ DecodeError readZeInfoExecutionEnvironment(const Yaml::YamlParser &parser, const return DecodeError::invalidBinary; } - return DecodeError::success; + return err; } void populateKernelExecutionEnvironment(KernelDescriptor &dst, const KernelExecutionEnvBaseT &execEnv, const Types::Version &srcZeInfoVersion) { @@ -730,6 +752,7 @@ DecodeError decodeZeInfoKernelUserAttributes(KernelDescriptor &dst, Yaml::YamlPa } DecodeError readZeInfoAttributes(const Yaml::YamlParser &parser, const Yaml::Node &node, KernelAttributesBaseT &outAttributes, ConstStringRef context, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; namespace AttributeTypes = Types::Kernel::Attributes; bool validAttributes = true; for (const auto &attributesMetadataNd : parser.createChildrenRange(node)) { @@ -753,11 +776,10 @@ DecodeError readZeInfoAttributes(const Yaml::YamlParser &parser, const Yaml::Nod } else if (key.contains(Tags::Kernel::Attributes::hintSuffix.data())) { outAttributes.otherHints.push_back({key, parser.readValue(attributesMetadataNd)}); } else { - outErrReason.append("DeviceBinaryFormat::zebin::.ze_info : Unknown attribute entry \"" + key.str() + "\" in context of " + context.str() + "\n"); - validAttributes = false; + encounterUnknownZeInfoAttribute("\"" + key.str() + "\" in context of " + context.str(), outErrReason, outWarning, err); } } - return validAttributes ? DecodeError::success : DecodeError::invalidBinary; + return validAttributes ? err : DecodeError::invalidBinary; } std::string attributeToString(const int32_t &attribute) { @@ -816,16 +838,17 @@ DecodeError decodeZeInfoKernelDebugEnvironment(KernelDescriptor &dst, Yaml::Yaml } DecodeError readZeInfoDebugEnvironment(const Yaml::YamlParser &parser, const Yaml::Node &node, KernelDebugEnvBaseT &outDebugEnv, ConstStringRef context, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; bool validDebugEnv = true; for (const auto &debugEnvNd : parser.createChildrenRange(node)) { auto key = parser.readKey(debugEnvNd); if (Tags::Kernel::DebugEnv::debugSurfaceBTI == key) { validDebugEnv &= readZeInfoValueChecked(parser, debugEnvNd, outDebugEnv.debugSurfaceBTI, context, outErrReason); } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + key.str() + "\" in context of " + context.str() + "\n"); + encounterUnknownZeInfoAttribute("\"" + key.str() + "\" in context of " + context.str(), outErrReason, outWarning, err); } } - return validDebugEnv ? DecodeError::success : DecodeError::invalidBinary; + return validDebugEnv ? err : DecodeError::invalidBinary; } void populateKernelDebugEnvironment(NEO::KernelDescriptor &dst, const KernelDebugEnvBaseT &debugEnv) { @@ -853,6 +876,7 @@ DecodeError decodeZeInfoKernelPerThreadPayloadArguments(KernelDescriptor &dst, Y } DecodeError readZeInfoPerThreadPayloadArguments(const Yaml::YamlParser &parser, const Yaml::Node &node, KernelPerThreadPayloadArguments &outPerThreadPayloadArguments, ConstStringRef context, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; bool validPerThreadPayload = true; for (const auto &perThreadPayloadArgumentNd : parser.createChildrenRange(node)) { outPerThreadPayloadArguments.resize(outPerThreadPayloadArguments.size() + 1); @@ -868,7 +892,7 @@ DecodeError readZeInfoPerThreadPayloadArguments(const Yaml::YamlParser &parser, } else if (Tags::Kernel::PerThreadPayloadArgument::offset == key) { validPerThreadPayload &= readZeInfoValueChecked(parser, perThreadPayloadArgumentMemberNd, perThreadPayloadArgMetadata.offset, context, outErrReason); } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + key.str() + "\" for per-thread payload argument in context of " + context.str() + "\n"); + encounterUnknownZeInfoAttribute("\"" + key.str() + "\" for per-thread payload argument in context of " + context.str(), outErrReason, outWarning, err); } } if (0 == perThreadPayloadArgMetadata.size) { @@ -877,7 +901,7 @@ DecodeError readZeInfoPerThreadPayloadArguments(const Yaml::YamlParser &parser, } } - return validPerThreadPayload ? DecodeError::success : DecodeError::invalidBinary; + return validPerThreadPayload ? err : DecodeError::invalidBinary; } DecodeError populateKernelPerThreadPayloadArgument(KernelDescriptor &dst, const KernelPerThreadPayloadArgBaseT &src, const uint32_t grfSize, std::string &outErrReason, std::string &outWarning) { @@ -1017,6 +1041,7 @@ DecodeError decodeZeInfoKernelPayloadArguments(KernelDescriptor &dst, Yaml::Yaml } DecodeError readZeInfoPayloadArguments(const Yaml::YamlParser &parser, const Yaml::Node &node, KernelPayloadArguments &outPayloadArguments, int32_t &outMaxPayloadArgumentIndex, ConstStringRef context, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; bool validPayload = true; for (const auto &payloadArgumentNd : parser.createChildrenRange(node)) { outPayloadArguments.resize(outPayloadArguments.size() + 1); @@ -1057,11 +1082,11 @@ DecodeError readZeInfoPayloadArguments(const Yaml::YamlParser &parser, const Yam } else if (Tags::Kernel::PayloadArgument::btiValue == key) { validPayload &= readZeInfoValueChecked(parser, payloadArgumentMemberNd, payloadArgMetadata.btiValue, context, outErrReason); } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + key.str() + "\" for payload argument in context of " + context.str() + "\n"); + encounterUnknownZeInfoAttribute("\"" + key.str() + "\" for payload argument in context of " + context.str(), outErrReason, outWarning, err); } } } - return validPayload ? DecodeError::success : DecodeError::invalidBinary; + return validPayload ? err : DecodeError::invalidBinary; } DecodeError populateKernelPayloadArgument(NEO::KernelDescriptor &dst, const KernelPayloadArgBaseT &src, std::string &outErrReason, std::string &outWarning) { @@ -1444,6 +1469,7 @@ DecodeError decodeZeInfoKernelInlineSamplers(KernelDescriptor &dst, Yaml::YamlPa } DecodeError readZeInfoInlineSamplers(const Yaml::YamlParser &parser, const Yaml::Node &node, KernelInlineSamplers &outInlineSamplers, ConstStringRef context, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; bool validInlineSamplers = true; for (const auto &inlineSamplerNd : parser.createChildrenRange(node)) { outInlineSamplers.resize(outInlineSamplers.size() + 1); @@ -1460,12 +1486,12 @@ DecodeError readZeInfoInlineSamplers(const Yaml::YamlParser &parser, const Yaml: } else if (Tags::normalized == key) { validInlineSamplers &= readZeInfoValueChecked(parser, inlineSamplerMemberNd, inlineSampler.normalized, context, outErrReason); } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + key.str() + "\" for inline sampler in context of " + context.str() + "\n"); + encounterUnknownZeInfoAttribute("\"" + key.str() + "\" for inline sampler in context of " + context.str(), outErrReason, outWarning, err); } } } - return validInlineSamplers ? DecodeError::success : DecodeError::invalidBinary; + return validInlineSamplers ? err : DecodeError::invalidBinary; } DecodeError populateKernelInlineSampler(KernelDescriptor &dst, const KernelInlineSamplerBaseT &src, std::string &outErrReason, std::string &outWarning) { @@ -1529,6 +1555,7 @@ DecodeError decodeZeInfoKernelPerThreadMemoryBuffers(KernelDescriptor &dst, Yaml } DecodeError readZeInfoPerThreadMemoryBuffers(const Yaml::YamlParser &parser, const Yaml::Node &node, KernelPerThreadMemoryBuffers &outPerThreadMemoryBuffers, ConstStringRef context, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; bool validBuffer = true; for (const auto &perThreadMemoryBufferNd : parser.createChildrenRange(node)) { outPerThreadMemoryBuffers.resize(outPerThreadMemoryBuffers.size() + 1); @@ -1546,11 +1573,11 @@ DecodeError readZeInfoPerThreadMemoryBuffers(const Yaml::YamlParser &parser, con } else if (Tags::Kernel::PerThreadMemoryBuffer::slot == key) { validBuffer &= readZeInfoValueChecked(parser, perThreadMemoryBufferMemberNd, perThreadMemoryBufferMetadata.slot, context, outErrReason); } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + key.str() + "\" for per-thread memory buffer in context of " + context.str() + "\n"); + encounterUnknownZeInfoAttribute("\"" + key.str() + "\" for per-thread memory buffer in context of " + context.str(), outErrReason, outWarning, err); } } } - return validBuffer ? DecodeError::success : DecodeError::invalidBinary; + return validBuffer ? err : DecodeError::invalidBinary; } DecodeError populateKernelPerThreadMemoryBuffer(KernelDescriptor &dst, const KernelPerThreadMemoryBufferBaseT &src, const uint32_t minScratchSpaceSize, std::string &outErrReason, std::string &outWarning, const Types::Version &srcZeInfoVersion) { @@ -1618,6 +1645,7 @@ DecodeError decodeZeInfoKernelExperimentalProperties(KernelDescriptor &dst, Yaml } DecodeError readZeInfoExperimentalProperties(const Yaml::YamlParser &parser, const Yaml::Node &node, KernelExperimentalPropertiesBaseT &outExperimentalProperties, ConstStringRef context, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; bool validExperimentalProperty = true; for (const auto &experimentalPropertyNd : parser.createChildrenRange(node)) { for (const auto &experimentalPropertyMemberNd : parser.createChildrenRange(experimentalPropertyNd)) { @@ -1632,13 +1660,12 @@ DecodeError readZeInfoExperimentalProperties(const Yaml::YamlParser &parser, con validExperimentalProperty &= readZeInfoValueChecked(parser, experimentalPropertyMemberNd, outExperimentalProperties.hasNonKernelArgAtomic, context, outErrReason); } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + key.str() + "\" in context of " + context.str() + "\n"); - validExperimentalProperty = false; + encounterUnknownZeInfoAttribute("\"" + key.str() + "\" in context of " + context.str(), outErrReason, outWarning, err); } } } - return validExperimentalProperty ? DecodeError::success : DecodeError::invalidBinary; + return validExperimentalProperty ? err : DecodeError::invalidBinary; } void populateKernelExperimentalProperties(KernelDescriptor &dst, const KernelExperimentalPropertiesBaseT &experimentalProperties) { @@ -1665,6 +1692,7 @@ DecodeError decodeZeInfoKernelBindingTableEntries(KernelDescriptor &dst, Yaml::Y } DecodeError readZeInfoBindingTableIndices(const Yaml::YamlParser &parser, const Yaml::Node &node, KernelBindingTableEntries &outBindingTableIndices, ConstStringRef context, std::string &outErrReason, std::string &outWarning) { + DecodeError err = DecodeError::success; bool validBindingTableEntries = true; for (const auto &bindingTableIndexNd : parser.createChildrenRange(node)) { outBindingTableIndices.resize(outBindingTableIndices.size() + 1); @@ -1676,12 +1704,12 @@ DecodeError readZeInfoBindingTableIndices(const Yaml::YamlParser &parser, const } else if (Tags::Kernel::BindingTableIndex::btiValue == key) { validBindingTableEntries &= readZeInfoValueChecked(parser, bindingTableIndexMemberNd, bindingTableIndexMetadata.btiValue, context, outErrReason); } else { - outWarning.append("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"" + key.str() + "\" for binding table index in context of " + context.str() + "\n"); + encounterUnknownZeInfoAttribute("\"" + key.str() + "\" for binding table index in context of " + context.str(), outErrReason, outWarning, err); } } } - return validBindingTableEntries ? DecodeError::success : DecodeError::invalidBinary; + return validBindingTableEntries ? err : DecodeError::invalidBinary; } DecodeError populateKernelBindingTableIndicies(KernelDescriptor &dst, const KernelBindingTableEntries &btEntries, std::string &outErrReason) { diff --git a/shared/source/device_binary_format/zebin/zeinfo_decoder.h b/shared/source/device_binary_format/zebin/zeinfo_decoder.h index d83c8c54c2..a9beb02f76 100644 --- a/shared/source/device_binary_format/zebin/zeinfo_decoder.h +++ b/shared/source/device_binary_format/zebin/zeinfo_decoder.h @@ -49,7 +49,7 @@ DecodeError decodeZeInfo(ProgramInfo &dst, ConstStringRef zeInfo, std::string &o DecodeError decodeAndPopulateKernelMiscInfo(size_t kernelMiscInfoOffset, std::vector &kernelInfos, ConstStringRef metadataString, std::string &outErrReason, std::string &outWarning); -void extractZeInfoKernelSections(const NEO::Yaml::YamlParser &parser, const NEO::Yaml::Node &kernelNd, ZeInfoKernelSections &outZeInfoKernelSections, ConstStringRef context, std::string &outWarning); +DecodeError extractZeInfoKernelSections(const NEO::Yaml::YamlParser &parser, const NEO::Yaml::Node &kernelNd, ZeInfoKernelSections &outZeInfoKernelSections, ConstStringRef context, std::string &outErrReason, std::string &outWarning); DecodeError validateZeInfoKernelSectionsCount(const ZeInfoKernelSections &outZeInfoKernelSections, std::string &outErrReason, std::string &outWarning); using ZeInfoGlobalHostAccessTables = StackVec; @@ -137,6 +137,8 @@ inline bool isAtLeastZeInfoVersion(const Types::Version &srcVersion, const Types inline bool isScratchMemoryUsageDefinedInExecutionEnvironment(const Types::Version &srcVersion) { return isAtLeastZeInfoVersion(srcVersion, {1, 39}); } +void encounterUnknownZeInfoAttribute(const std::string &entryDescriptor, std::string &outErrReason, std::string &outWarning, DecodeError &errCode); + } // namespace Zebin::ZeInfo } // namespace NEO diff --git a/shared/test/common/mocks/mock_modules_zebin.h b/shared/test/common/mocks/mock_modules_zebin.h index 0ea0dbd711..2f3af72fd3 100644 --- a/shared/test/common/mocks/mock_modules_zebin.h +++ b/shared/test/common/mocks/mock_modules_zebin.h @@ -261,7 +261,7 @@ kernels: arg_index: 0 - bti_value: 1 arg_index: 1 --)==="; +)==="; }; template diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index 597ee00587..7ed8635486 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -625,4 +625,5 @@ ForceComputeWalkerPostSyncFlushWithWrite = -1 DeferStateInitSubmissionToFirstRegularUsage = -1 WaitForPagingFenceInController = -1 DirectSubmissionPrintSemaphoreUsage = -1 +IgnoreZebinUnknownAttributes = 0 # Please don't edit below this line 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 12b6af0e65..1d6ceb9d39 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 @@ -649,8 +649,11 @@ kernels: ASSERT_TRUE(success); auto &kernelNode = *parser.createChildrenRange(*parser.findNodeWithKeyDfs("kernels")).begin(); + std::string errors; std::string warnings; - NEO::Zebin::ZeInfo::extractZeInfoKernelSections(parser, kernelNode, kernelSections, "some_kernel", warnings); + auto errCode = NEO::Zebin::ZeInfo::extractZeInfoKernelSections(parser, kernelNode, kernelSections, "some_kernel", errors, warnings); + EXPECT_EQ(DecodeError::success, errCode); + EXPECT_TRUE(errors.empty()) << errors; EXPECT_TRUE(warnings.empty()) << warnings; ASSERT_FALSE(kernelSections.nameNd.empty()); ASSERT_FALSE(kernelSections.executionEnvNd.empty()); @@ -1137,8 +1140,10 @@ kernels: ASSERT_TRUE(success); auto &kernelNode = *parser.createChildrenRange(*parser.findNodeWithKeyDfs("kernels")).begin(); + std::string errors; std::string warnings; - NEO::Zebin::ZeInfo::extractZeInfoKernelSections(parser, kernelNode, kernelSections, "some_kernel", warnings); + auto errCode = NEO::Zebin::ZeInfo::extractZeInfoKernelSections(parser, kernelNode, kernelSections, "some_kernel", errors, warnings); + EXPECT_EQ(DecodeError::success, errCode); EXPECT_TRUE(warnings.empty()) << warnings; ASSERT_FALSE(kernelSections.nameNd.empty()); ASSERT_FALSE(kernelSections.executionEnvNd.empty()); @@ -1157,7 +1162,7 @@ kernels: EXPECT_EQ("experimental_properties", parser.readKey(*kernelSections.experimentalPropertiesNd[0])) << parser.readKey(*kernelSections.experimentalPropertiesNd[0]).str(); } -TEST(ExtractZeInfoKernelSections, GivenUnknownSectionThenEmitsAWarning) { +TEST(ExtractZeInfoKernelSections, GivenUnknownSectionThenEmitsAnError) { NEO::ConstStringRef yaml = R"===(--- kernels: - name: some_kernel @@ -1177,9 +1182,12 @@ kernels: ASSERT_TRUE(success); auto &kernelNode = *parser.createChildrenRange(*parser.findNodeWithKeyDfs("kernels")).begin(); + std::string errors; std::string warnings; - NEO::Zebin::ZeInfo::extractZeInfoKernelSections(parser, kernelNode, kernelSections, "some_kernel", warnings); - EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"apple\" in context of : some_kernel\n", warnings.c_str()); + auto errCode = NEO::Zebin::ZeInfo::extractZeInfoKernelSections(parser, kernelNode, kernelSections, "some_kernel", errors, warnings); + EXPECT_EQ(DecodeError::unkownZeinfoAttribute, errCode); + EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"apple\" in context of : some_kernel\n", errors.c_str()); + EXPECT_TRUE(warnings.empty()) << warnings; ASSERT_FALSE(kernelSections.nameNd.empty()); EXPECT_EQ("name", parser.readKey(*kernelSections.nameNd[0])) << parser.readKey(*kernelSections.nameNd[0]).str(); } @@ -1478,7 +1486,7 @@ kernels: "some_kernel", errors, warnings); - EXPECT_EQ(NEO::DecodeError::invalidBinary, err); + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, err); } TEST_F(decodeZeInfoKernelEntryTest, GivenValidExperimentalPropertiesThenPopulateKernelDescriptorSucceeds) { @@ -1949,7 +1957,7 @@ kernels: EXPECT_EQ(2, execEnv.indirectStatelessCount); } -TEST(ReadZeInfoExecutionEnvironment, GivenUnknownEntryThenEmmitsWarning) { +TEST(ReadZeInfoExecutionEnvironment, GivenUnknownEntryThenEmitsError) { NEO::ConstStringRef yaml = R"===(--- kernels: - name: some_kernel @@ -1969,10 +1977,10 @@ kernels: std::string warnings; NEO::Zebin::ZeInfo::Types::Kernel::ExecutionEnv::ExecutionEnvBaseT execEnv; auto err = NEO::Zebin::ZeInfo::readZeInfoExecutionEnvironment(parser, execEnvNode, execEnv, "some_kernel", errors, warnings); - EXPECT_EQ(NEO::DecodeError::success, err); - EXPECT_TRUE(errors.empty()) << errors; - EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"something_new\" in context of some_kernel\n", warnings.c_str()); - EXPECT_EQ(8, execEnv.simdSize); + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, err); + EXPECT_FALSE(errors.empty()); + EXPECT_TRUE(warnings.empty()) << warnings; + EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"something_new\" in context of some_kernel\n", errors.c_str()); } TEST(ReadZeInfoExecutionEnvironment, GivenInvalidValueForKnownEntryThenFails) { @@ -2094,7 +2102,7 @@ kernels: EXPECT_EQ(0, debugEnv.debugSurfaceBTI); } -TEST(ReadZeInfoDebugEnvironment, givenUnknownEntryThenEmitsWarning) { +TEST(ReadZeInfoDebugEnvironment, givenUnknownEntryThenEmitsError) { NEO::ConstStringRef yaml = R"===(--- kernels: - name: some_kernel @@ -2114,9 +2122,9 @@ kernels: std::string warnings; NEO::Zebin::ZeInfo::Types::Kernel::DebugEnv::DebugEnvBaseT debugEnv; auto err = NEO::Zebin::ZeInfo::readZeInfoDebugEnvironment(parser, argsNode, debugEnv, "some_kernel", errors, warnings); - EXPECT_EQ(NEO::DecodeError::success, err); - EXPECT_TRUE(errors.empty()) << errors; - EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"different\" in context of some_kernel\n", warnings.c_str()); + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, err); + EXPECT_TRUE(warnings.empty()) << warnings; + EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"different\" in context of some_kernel\n", errors.c_str()); } TEST(ReadZeInfoDebugEnvironment, givenInvalidValueForKnownEntryThenFail) { @@ -2331,9 +2339,9 @@ kernels: ... )==="; auto err = decodeZeInfoKernelEntry(zeinfo); - EXPECT_EQ(NEO::DecodeError::invalidBinary, err); + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, err); EXPECT_TRUE(warnings.empty()) << warnings; - EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown attribute entry \"unknown_attribute\" in context of some_kernel\n", errors.c_str()); + EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"unknown_attribute\" in context of some_kernel\n", errors.c_str()); } TEST(ReadZeInfoEnumChecked, GivenInvalidNodeThenFail) { @@ -2396,7 +2404,7 @@ kernels: EXPECT_EQ(192, args[1].size); } -TEST(ReadZeInfoPerThreadPayloadArguments, GivenUnknownEntryThenEmmitsWarning) { +TEST(ReadZeInfoPerThreadPayloadArguments, GivenUnknownEntryThenEmitsError) { NEO::ConstStringRef yaml = R"===(--- kernels: - name: some_kernel @@ -2418,14 +2426,10 @@ kernels: std::string warnings; NEO::Zebin::ZeInfo::KernelPerThreadPayloadArguments args; auto err = NEO::Zebin::ZeInfo::readZeInfoPerThreadPayloadArguments(parser, argsNode, args, "some_kernel", errors, warnings); - EXPECT_EQ(NEO::DecodeError::success, err); - EXPECT_TRUE(errors.empty()) << errors; - EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"something_new\" for per-thread payload argument in context of some_kernel\n", warnings.c_str()); - - ASSERT_EQ(1U, args.size()); - EXPECT_EQ(NEO::Zebin::ZeInfo::Types::Kernel::argTypePackedLocalIds, args[0].argType); - EXPECT_EQ(8, args[0].offset); - EXPECT_EQ(16, args[0].size); + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, err); + EXPECT_FALSE(errors.empty()); + EXPECT_TRUE(warnings.empty()) << warnings; + EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"something_new\" for per-thread payload argument in context of some_kernel\n", errors.c_str()); } TEST(ReadZeInfoPerThreadPayloadArguments, GivenInvalidValueForKnownEntryThenFails) { @@ -2551,7 +2555,7 @@ kernels: EXPECT_TRUE(args[3].isPtr); } -TEST(ReadZeInfoPayloadArguments, GivenUnknownEntryThenEmmitsWarning) { +TEST(ReadZeInfoPayloadArguments, GivenUnknownEntryThenEmitsError) { NEO::ConstStringRef yaml = R"===(--- kernels: - name: some_kernel @@ -2575,15 +2579,9 @@ kernels: NEO::Zebin::ZeInfo::KernelPayloadArguments args; int32_t maxArgIndex = -1; auto err = NEO::Zebin::ZeInfo::readZeInfoPayloadArguments(parser, argsNode, args, maxArgIndex, "some_kernel", errors, warnings); - EXPECT_EQ(NEO::DecodeError::success, err); - EXPECT_TRUE(errors.empty()) << errors; - EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"something_new\" for payload argument in context of some_kernel\n", warnings.c_str()); - - ASSERT_EQ(1U, args.size()); - EXPECT_EQ(NEO::Zebin::ZeInfo::Types::Kernel::argTypeArgByvalue, args[0].argType); - EXPECT_EQ(24, args[0].offset); - EXPECT_EQ(4, args[0].size); - EXPECT_EQ(2, args[0].argIndex); + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, err); + EXPECT_TRUE(warnings.empty()) << warnings; + EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"something_new\" for payload argument in context of some_kernel\n", errors.c_str()); } TEST(ReadZeInfoPayloadArguments, GivenArgByPointerWithSlmAddresingModeAndSlmAlignmentThenSetSlmAlignmentAccordingly) { @@ -2688,7 +2686,7 @@ kernels: EXPECT_EQ(13, btis[1].argIndex); } -TEST(ReadZeInfoBindingTableIndices, GivenUnknownEntryThenEmmitsWarning) { +TEST(ReadZeInfoBindingTableIndices, GivenUnknownEntryThenEmitsError) { NEO::ConstStringRef yaml = R"===(--- kernels: - name: some_kernel @@ -2709,9 +2707,9 @@ kernels: std::string warnings; NEO::Zebin::ZeInfo::KernelBindingTableEntries btis; auto err = NEO::Zebin::ZeInfo::readZeInfoBindingTableIndices(parser, argsNode, btis, "some_kernel", errors, warnings); - EXPECT_EQ(NEO::DecodeError::success, err); - EXPECT_TRUE(errors.empty()) << errors; - EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"something_new\" for binding table index in context of some_kernel\n", warnings.c_str()); + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, err); + EXPECT_TRUE(warnings.empty()) << warnings; + EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"something_new\" for binding table index in context of some_kernel\n", errors.c_str()); ASSERT_EQ(1U, btis.size()); EXPECT_EQ(1, btis[0].btiValue); @@ -2829,7 +2827,7 @@ kernels: EXPECT_TRUE(buffers[0].isSimtThread); } -TEST(ReadZeInfoPerThreadMemoryBuffers, GivenUnknownEntryThenEmmitsWarning) { +TEST(ReadZeInfoPerThreadMemoryBuffers, GivenUnknownEntryThenEmmitsError) { NEO::ConstStringRef yaml = R"===(--- kernels: - name: some_kernel @@ -2851,9 +2849,9 @@ kernels: std::string warnings; NEO::Zebin::ZeInfo::KernelPerThreadMemoryBuffers buffers; auto err = NEO::Zebin::ZeInfo::readZeInfoPerThreadMemoryBuffers(parser, buffersNode, buffers, "some_kernel", errors, warnings); - EXPECT_EQ(NEO::DecodeError::success, err); - EXPECT_TRUE(errors.empty()) << errors; - EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"something_new\" for per-thread memory buffer in context of some_kernel\n", warnings.c_str()); + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, err); + EXPECT_TRUE(warnings.empty()) << warnings; + EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"something_new\" for per-thread memory buffer in context of some_kernel\n", errors.c_str()); ASSERT_EQ(1U, buffers.size()); EXPECT_EQ(NEO::Zebin::ZeInfo::Types::Kernel::PerThreadMemoryBuffer::AllocationTypeScratch, buffers[0].allocationType); @@ -3205,7 +3203,7 @@ TEST(DecodeSingleDeviceBinaryZebin, GivenEmptyInZeInfoThenEmitsWarning) { EXPECT_TRUE(errors.empty()) << errors; } -TEST(DecodeSingleDeviceBinaryZebin, GivenUnknownEntryInZeInfoGlobalScopeThenEmitsWarning) { +TEST(DecodeSingleDeviceBinaryZebin, GivenUnknownEntryInZeInfoGlobalScopeThenEmitsError) { NEO::MockExecutionEnvironment mockExecutionEnvironment{}; auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); ZebinTestData::ValidEmptyProgram zebin; @@ -3219,9 +3217,9 @@ TEST(DecodeSingleDeviceBinaryZebin, GivenUnknownEntryInZeInfoGlobalScopeThenEmit std::string errors; std::string warnings; auto error = NEO::decodeSingleDeviceBinary(programInfo, singleBinary, errors, warnings, gfxCoreHelper); - EXPECT_EQ(NEO::DecodeError::success, error); - EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"some_entry\" in global scope of .ze_info\n", warnings.c_str()); - EXPECT_TRUE(errors.empty()) << errors; + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, error); + EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"some_entry\" in global scope of .ze_info\n", errors.c_str()); + EXPECT_TRUE(warnings.empty()) << warnings; } TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoDoesNotContainKernelsSectionThenEmitsError) { @@ -3239,8 +3237,9 @@ TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoDoesNotContainKernelsSectionThenEm std::string warnings; auto error = NEO::decodeSingleDeviceBinary(programInfo, singleBinary, errors, warnings, gfxCoreHelper); EXPECT_EQ(NEO::DecodeError::invalidBinary, error); - EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"a\" in global scope of .ze_info\n", warnings.c_str()); - EXPECT_STREQ("DeviceBinaryFormat::zebin::ZeInfo : Expected exactly 1 of kernels, got : 0\n", errors.c_str()); + EXPECT_STREQ("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"a\" in global scope of .ze_info\n" + "DeviceBinaryFormat::zebin::ZeInfo : Expected exactly 1 of kernels, got : 0\n", + errors.c_str()); } TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoContainsMultipleKernelSectionsThenFails) { @@ -3329,7 +3328,7 @@ TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoMinorVersionIsNewerThenEmitsWarnin ZebinTestData::ValidEmptyProgram zebin; zebin.removeSection(NEO::Zebin::Elf::SectionHeaderTypeZebin::SHT_ZEBIN_ZEINFO, NEO::Zebin::Elf::SectionNames::zeInfo); auto version = NEO::Zebin::ZeInfo::zeInfoDecoderVersion; - std::string expectedWarning = "DeviceBinaryFormat::zebin::.ze_info : Minor version : " + std::to_string(version.minor + 1) + " is newer than available in decoder : " + std::to_string(version.minor) + " - some features may be skipped\n"; + std::string expectedWarning = "DeviceBinaryFormat::zebin::.ze_info : Minor version : " + std::to_string(version.minor + 1) + " is newer than available in decoder : " + std::to_string(version.minor) + "\n"; version.minor += 1; auto zeInfo = std::string("version:\'") + versionToString(version) + "\'\nkernels:\n"; zebin.appendSection(NEO::Zebin::Elf::SectionHeaderTypeZebin::SHT_ZEBIN_ZEINFO, NEO::Zebin::Elf::SectionNames::zeInfo, ArrayRef::fromAny(zeInfo.data(), zeInfo.size())); @@ -6615,7 +6614,7 @@ TEST(PopulateGlobalDeviceHostNameMapping, givenZebinWithGlobalHostAccessTableSec } } -TEST(PopulateGlobalDeviceHostNameMapping, givenZebinWithGlobalHostAccessTableSectionAndUnrecognizableKeyThenEmitWarning) { +TEST(PopulateGlobalDeviceHostNameMapping, givenZebinWithGlobalHostAccessTableSectionAndUnrecognizableKeyThenEmitError) { NEO::ConstStringRef yaml = R"===( kernels: - name : some_kernel @@ -6637,11 +6636,11 @@ TEST(PopulateGlobalDeviceHostNameMapping, givenZebinWithGlobalHostAccessTableSec std::string warnings; NEO::Zebin::ZeInfo::ZeInfoGlobalHostAccessTables tables; auto err = NEO::Zebin::ZeInfo::readZeInfoGlobalHostAceessTable(parser, tableNode, tables, "global_host_access_table", errors, warnings); - EXPECT_EQ(NEO::DecodeError::success, err); - EXPECT_TRUE(errors.empty()) << errors; + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, err); + EXPECT_TRUE(warnings.empty()) << warnings; - std::string expectedWarning("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"banana_type\" for payload argument in context of global_host_access_table\n"); - EXPECT_STREQ(expectedWarning.c_str(), warnings.c_str()); + std::string expectedError("DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"banana_type\" for payload argument in context of global_host_access_table\n"); + EXPECT_STREQ(expectedError.c_str(), errors.c_str()); } TEST(PopulateZeInfoExternalFunctionsMetadata, GivenValidExternalFunctionsMetadataThenParsesItProperly) { @@ -6694,7 +6693,7 @@ functions: } } -TEST(PopulateZeInfoExternalFunctionsMetadata, GivenValidExternalFunctionsMetadataWithUnknownEntriesThenParsesItProperly) { +TEST(PopulateZeInfoExternalFunctionsMetadata, GivenValidExternalFunctionsMetadataWithUnknownEntriesThenEmitError) { NEO::ConstStringRef yaml = R"===(--- functions: - name: fun0 @@ -6720,17 +6719,11 @@ functions: std::string warnings; ProgramInfo programInfo; auto err = NEO::Zebin::ZeInfo::populateExternalFunctionsMetadata(programInfo, parser, functionNode, errors, warnings); - EXPECT_EQ(DecodeError::success, err); - EXPECT_TRUE(errors.empty()) << errors; - const auto expectedWarning = "DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"unknown\" in context of : external functions\n"; - EXPECT_STREQ(expectedWarning, warnings.c_str()); - - ASSERT_EQ(1U, programInfo.externalFunctions.size()); - auto &fun0Info = programInfo.externalFunctions[0]; - EXPECT_STREQ("fun0", fun0Info.functionName.c_str()); - EXPECT_EQ(128U, fun0Info.numGrfRequired); - EXPECT_EQ(8U, fun0Info.simdSize); - EXPECT_EQ(1U, fun0Info.barrierCount); + EXPECT_EQ(DecodeError::unkownZeinfoAttribute, err); + EXPECT_FALSE(errors.empty()); + EXPECT_TRUE(warnings.empty()) << warnings; + const auto expectedError = "DeviceBinaryFormat::zebin::.ze_info : Unknown entry \"unknown\" in context of : external functions\n"; + EXPECT_STREQ(expectedError, errors.c_str()); } TEST(PopulateZeInfoExternalFunctionsMetadata, GivenInvalidExternalFunctionsMetadataThenFail) { @@ -6971,7 +6964,7 @@ TEST(PopulateInlineSamplers, GivenInvalidFilterModeThenPopulateInlineSamplersFai EXPECT_FALSE(errors.empty()); } -TEST(ReadZeInfoInlineSamplers, GivenUnknownEntryThenPrintWarning) { +TEST(ReadZeInfoInlineSamplers, GivenUnknownEntryThenPrintError) { NEO::ConstStringRef yaml = R"===(--- kernels: - name: some_kernel @@ -6996,9 +6989,9 @@ kernels: "some_kernel", errors, warnings); - EXPECT_EQ(NEO::DecodeError::success, err); - EXPECT_FALSE(warnings.empty()); - EXPECT_TRUE(errors.empty()) << errors; + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, err); + EXPECT_TRUE(warnings.empty()) << warnings; + EXPECT_FALSE(errors.empty()); } TEST(ZeInfoMetadataExtractionFromElf, givenValidElfContainingZeInfoSectionWhenExtractingZeInfoMetadataStringThenProperMetadataIsReturnedForEachElfType) { @@ -7045,3 +7038,24 @@ TEST(ZeInfoMetadataExtractionFromElf, givenValidElfNotContainingZeInfoSectionWhe EXPECT_EQ(nullptr, zeInfoStr32B.data()); EXPECT_EQ(nullptr, zeInfoStr64B.data()); } + +TEST(EncounterUnknownZeInfoAttribute, whenUnknownAttributeIsEncounteredThenErrorMessageAndErrorCodeAreSet) { + std::string errorMessage, warning; + NEO::DecodeError errorCode = NEO::DecodeError::success; + NEO::Zebin::ZeInfo::encounterUnknownZeInfoAttribute("unknown_attribute", errorMessage, warning, errorCode); + EXPECT_EQ(NEO::DecodeError::unkownZeinfoAttribute, errorCode); + EXPECT_TRUE(warning.empty()) << warning; + EXPECT_FALSE(errorMessage.empty()); +} + +TEST(EncounterUnknownZeInfoAttribute, givenEnvVariabletoIgnoreUnknownAttributesWhenUnknownAttributeIsEncounteredThenWarningIsSet) { + DebugManagerStateRestore dbgRestore; + NEO::debugManager.flags.IgnoreZebinUnknownAttributes.set(true); + + std::string errorMessage, warning; + NEO::DecodeError errorCode = NEO::DecodeError::success; + NEO::Zebin::ZeInfo::encounterUnknownZeInfoAttribute("unknown_attribute", errorMessage, warning, errorCode); + EXPECT_EQ(NEO::DecodeError::success, errorCode); + EXPECT_TRUE(errorMessage.empty()) << errorMessage; + EXPECT_FALSE(warning.empty()); +}