Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SPV_INTEL_maximum_registers extension #2344

Merged
merged 9 commits into from
Feb 26, 2024

Conversation

vmaksimo
Copy link
Contributor

@vmaksimo vmaksimo commented Feb 6, 2024

@vmaksimo vmaksimo marked this pull request as ready for review February 7, 2024 17:03
@vmaksimo
Copy link
Contributor Author

vmaksimo commented Feb 7, 2024

Please take a look @MrSidims @asudarsa @LU-JOHN @bwlodarcz @VyacheslavLevytskyy

Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM conditionally if tokens are placed in https://github.com/KhronosGroup/SPIRV-Headers

@vmaksimo
Copy link
Contributor Author

vmaksimo commented Feb 8, 2024

LGTM conditionally if tokens are placed in https://github.com/KhronosGroup/SPIRV-Headers

Created PR to Headers, will update the translator code once Headers are merged (can be done in a separate PR) KhronosGroup/SPIRV-Headers#416

@vmaksimo vmaksimo changed the title Initial support for SPV_INTEL_maximum_registers extension Support SPV_INTEL_maximum_registers extension Feb 8, 2024
@@ -4318,6 +4318,50 @@ bool SPIRVToLLVM::transMetadata() {
F->setMetadata(kSPIR2MD::IntelFPGAIPInterface,
MDNode::get(*Context, InterfaceMDVec));
}
if (auto *EM = BF->getExecutionMode(
Copy link
Contributor

@LU-JOHN LU-JOHN Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check to ensure that only one mode is chosen?

Consider refactoring common code among the three if statements.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no. Even so it seems to have no sense to enable several different maxregisters execution modes, neither SPIR-V core spec, nor extension prohibits usage of several execution modes at the same time. So, I believe this code should not be changed to else if.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From KhronosGroup/SPIRV-Registry#235, in extensions/INTEL/SPV_INTEL_maximum_registers.asciidoc

  • Each OpEntryPoint must contain at most one of the
    MaximumRegistersINTEL, MaximumRegistersIdINTEL, or
    NamedMaximumRegistersINTEL execution modes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in 84a3ead. Unfortunately I can't add meaningful tests for that, because llvm-spirv fails with an assertion in case we add more than one execution mode of the certain type.
Verified locally that this check both on forward and reverse translation in case of invalid IR/SPV.

ConstantAsMetadata::get(getUInt32(M, EM->getLiterals()[0])));
ExecModeMD->addOperand(MDNode::get(*Context, ValueVec));
}
if (auto *EM = BF->getExecutionMode(
Copy link
Contributor

@LU-JOHN LU-JOHN Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "else if"?

if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_maximum_registers))
transFunctionMetadataAsExecutionMode(BF, F);
else
transFunctionMetadataAsUserSemanticDecoration(BF, F);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to support the 'old' implementation or throw an error here? Sorry if this is ignorant question.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we do, because it takes time for the consumers to adapt the new change on their side.

lib/SPIRV/SPIRVWriter.cpp Outdated Show resolved Hide resolved
lib/SPIRV/SPIRVWriter.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@asudarsa asudarsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Some minor comments. Thanks

@vmaksimo vmaksimo requested review from LU-JOHN and asudarsa February 16, 2024 11:47
Copy link
Contributor

@LU-JOHN LU-JOHN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MrSidims MrSidims merged commit 92ea64b into KhronosGroup:main Feb 26, 2024
9 checks passed
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 1, 2024
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 1, 2024
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 1, 2024
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 1, 2024
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 4, 2024
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 4, 2024
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 4, 2024
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 4, 2024
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 5, 2024
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 5, 2024
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 5, 2024
KorovinVlad pushed a commit to KorovinVlad/SPIRV-LLVM-Translator that referenced this pull request Mar 5, 2024
MrSidims pushed a commit that referenced this pull request Mar 6, 2024
#2390)

Spec:
KhronosGroup/SPIRV-Registry#235

* Add infrastructure for translating ExecutionModeId (#2297)

This functionality was added in SPIR-V 1.2 and allows using an <id> to
set the execution modes SubgroupsPerWorkgroupId, LocalSizeId, and
LocalSizeHintI, and others.

---------

Co-authored-by: Viktoria Maximova <[email protected]>
vmaksimo pushed a commit that referenced this pull request Mar 18, 2024
* [Backport to 15] Support SPV_INTEL_maximum_registers extension (#2344)
* Add infrastructure for translating ExecutionModeId (#2297)
vmaksimo added a commit that referenced this pull request Mar 18, 2024
* Add infrastructure for translating ExecutionModeId (#2297)
* [Backport to 14] Support SPV_INTEL_maximum_registers extension (#2344)

Co-authored-by: Viktoria Maximova <[email protected]>
vmaksimo added a commit that referenced this pull request Mar 18, 2024
* Add infrastructure for translating ExecutionModeId (#2297)
* [Backport to 13] Support SPV_INTEL_maximum_registers extension (#2344)
* .clang-tidy: allow recursion
(cherry picked from commit 28fdb7a)

Co-authored-by: Viktoria Maximova <[email protected]>
Co-authored-by: Sven van Haastregt <[email protected]>
vmaksimo added a commit that referenced this pull request Mar 19, 2024
vmaksimo added a commit that referenced this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants