feature: New forward-compatibility model for zeinfo

Up till now, NEO ignored uknown attributes in zeinfo
which could lead to undefined behavior. With this change
NEO will emit an error whenever an unknown attribute is
encountered.

Note : old behavior can be restored using new
IgnoreZebinUnknownAttributes debug environment variable

Resolves: NEO-11762

Signed-off-by: Chodor, Jaroslaw <jaroslaw.chodor@intel.com>
This commit is contained in:
Chodor, Jaroslaw
2024-08-20 20:19:53 +00:00
committed by Compute-Runtime-Automation
parent 2844cba1f1
commit 5463ddea06
7 changed files with 160 additions and 113 deletions

View File

@@ -638,6 +638,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")

View File

@@ -34,7 +34,8 @@ enum class DecodeError : uint8_t {
success,
undefined,
invalidBinary,
unhandledBinary
unhandledBinary,
unkownZeinfoAttribute
};
enum class GeneratorType : uint8_t {

View File

@@ -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 <typename ElSize, size_t len>
@@ -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<uint8_t>(execEnv.barrierCount);
@@ -278,10 +293,9 @@ DecodeError populateExternalFunctionsMetadata(NEO::ProgramInfo &dst, NEO::Yaml::
extFunInfo.simdSize = static_cast<uint8_t>(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,6 +838,7 @@ 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);
@@ -824,10 +847,10 @@ DecodeError readZeInfoDebugEnvironment(const Yaml::YamlParser &parser, const Yam
} else if (Tags::Kernel::DebugEnv::debugSurfaceOffset == key) {
validDebugEnv &= readZeInfoValueChecked(parser, debugEnvNd, outDebugEnv.debugSurfaceOffset, 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) {
@@ -855,6 +878,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);
@@ -870,7 +894,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) {
@@ -879,7 +903,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) {
@@ -1019,6 +1043,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);
@@ -1059,11 +1084,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) {
@@ -1446,6 +1471,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);
@@ -1462,12 +1488,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) {
@@ -1531,6 +1557,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);
@@ -1548,11 +1575,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) {
@@ -1620,6 +1647,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)) {
@@ -1634,13 +1662,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) {
@@ -1667,6 +1694,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);
@@ -1678,12 +1706,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) {

View File

@@ -49,7 +49,7 @@ DecodeError decodeZeInfo(ProgramInfo &dst, ConstStringRef zeInfo, std::string &o
DecodeError decodeAndPopulateKernelMiscInfo(size_t kernelMiscInfoOffset, std::vector<NEO::KernelInfo *> &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<Types::GlobalHostAccessTable::GlobalHostAccessTableT, 32>;
@@ -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

View File

@@ -261,7 +261,7 @@ kernels:
arg_index: 0
- bti_value: 1
arg_index: 1
-)===";
)===";
};
template <NEO::Elf::ElfIdentifierClass numBits>

View File

@@ -626,4 +626,5 @@ ExperimentalUSMAllocationReuseVersion = -1
ForceNonWalkerSplitMemoryCopy = -1
DirectSubmissionSwitchSemaphoreMode = -1
OverrideTimestampWidth = -1
IgnoreZebinUnknownAttributes = 0
# Please don't edit below this line

View File

@@ -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) {
@@ -2120,7 +2128,7 @@ kernels:
EXPECT_EQ(0, debugEnv.debugSurfaceOffset);
}
TEST(ReadZeInfoDebugEnvironment, givenUnknownEntryThenEmitsWarning) {
TEST(ReadZeInfoDebugEnvironment, givenUnknownEntryThenEmitsError) {
NEO::ConstStringRef yaml = R"===(---
kernels:
- name: some_kernel
@@ -2140,9 +2148,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) {
@@ -2357,9 +2365,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) {
@@ -2422,7 +2430,7 @@ kernels:
EXPECT_EQ(192, args[1].size);
}
TEST(ReadZeInfoPerThreadPayloadArguments, GivenUnknownEntryThenEmmitsWarning) {
TEST(ReadZeInfoPerThreadPayloadArguments, GivenUnknownEntryThenEmitsError) {
NEO::ConstStringRef yaml = R"===(---
kernels:
- name: some_kernel
@@ -2444,14 +2452,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) {
@@ -2577,7 +2581,7 @@ kernels:
EXPECT_TRUE(args[3].isPtr);
}
TEST(ReadZeInfoPayloadArguments, GivenUnknownEntryThenEmmitsWarning) {
TEST(ReadZeInfoPayloadArguments, GivenUnknownEntryThenEmitsError) {
NEO::ConstStringRef yaml = R"===(---
kernels:
- name: some_kernel
@@ -2601,15 +2605,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) {
@@ -2714,7 +2712,7 @@ kernels:
EXPECT_EQ(13, btis[1].argIndex);
}
TEST(ReadZeInfoBindingTableIndices, GivenUnknownEntryThenEmmitsWarning) {
TEST(ReadZeInfoBindingTableIndices, GivenUnknownEntryThenEmitsError) {
NEO::ConstStringRef yaml = R"===(---
kernels:
- name: some_kernel
@@ -2735,9 +2733,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);
@@ -2855,7 +2853,7 @@ kernels:
EXPECT_TRUE(buffers[0].isSimtThread);
}
TEST(ReadZeInfoPerThreadMemoryBuffers, GivenUnknownEntryThenEmmitsWarning) {
TEST(ReadZeInfoPerThreadMemoryBuffers, GivenUnknownEntryThenEmmitsError) {
NEO::ConstStringRef yaml = R"===(---
kernels:
- name: some_kernel
@@ -2877,9 +2875,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);
@@ -3231,7 +3229,7 @@ TEST(DecodeSingleDeviceBinaryZebin, GivenEmptyInZeInfoThenEmitsWarning) {
EXPECT_TRUE(errors.empty()) << errors;
}
TEST(DecodeSingleDeviceBinaryZebin, GivenUnknownEntryInZeInfoGlobalScopeThenEmitsWarning) {
TEST(DecodeSingleDeviceBinaryZebin, GivenUnknownEntryInZeInfoGlobalScopeThenEmitsError) {
NEO::MockExecutionEnvironment mockExecutionEnvironment{};
auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper<NEO::GfxCoreHelper>();
ZebinTestData::ValidEmptyProgram zebin;
@@ -3245,9 +3243,9 @@ TEST(DecodeSingleDeviceBinaryZebin, GivenUnknownEntryInZeInfoGlobalScopeThenEmit
std::string errors;
std::string warnings;
auto error = NEO::decodeSingleDeviceBinary<NEO::DeviceBinaryFormat::zebin>(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) {
@@ -3265,8 +3263,9 @@ TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoDoesNotContainKernelsSectionThenEm
std::string warnings;
auto error = NEO::decodeSingleDeviceBinary<NEO::DeviceBinaryFormat::zebin>(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) {
@@ -3355,7 +3354,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<const uint8_t>::fromAny(zeInfo.data(), zeInfo.size()));
@@ -6641,7 +6640,7 @@ TEST(PopulateGlobalDeviceHostNameMapping, givenZebinWithGlobalHostAccessTableSec
}
}
TEST(PopulateGlobalDeviceHostNameMapping, givenZebinWithGlobalHostAccessTableSectionAndUnrecognizableKeyThenEmitWarning) {
TEST(PopulateGlobalDeviceHostNameMapping, givenZebinWithGlobalHostAccessTableSectionAndUnrecognizableKeyThenEmitError) {
NEO::ConstStringRef yaml = R"===(
kernels:
- name : some_kernel
@@ -6663,11 +6662,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) {
@@ -6720,7 +6719,7 @@ functions:
}
}
TEST(PopulateZeInfoExternalFunctionsMetadata, GivenValidExternalFunctionsMetadataWithUnknownEntriesThenParsesItProperly) {
TEST(PopulateZeInfoExternalFunctionsMetadata, GivenValidExternalFunctionsMetadataWithUnknownEntriesThenEmitError) {
NEO::ConstStringRef yaml = R"===(---
functions:
- name: fun0
@@ -6746,17 +6745,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) {
@@ -6997,7 +6990,7 @@ TEST(PopulateInlineSamplers, GivenInvalidFilterModeThenPopulateInlineSamplersFai
EXPECT_FALSE(errors.empty());
}
TEST(ReadZeInfoInlineSamplers, GivenUnknownEntryThenPrintWarning) {
TEST(ReadZeInfoInlineSamplers, GivenUnknownEntryThenPrintError) {
NEO::ConstStringRef yaml = R"===(---
kernels:
- name: some_kernel
@@ -7022,9 +7015,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) {
@@ -7071,3 +7064,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());
}