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

Add inline-assembly support #1769

Merged
merged 1 commit into from Apr 12, 2022
Merged

Conversation

Flakebi
Copy link
Member

@Flakebi Flakebi commented Apr 6, 2022

So far, it is complicated and time-consuming to test the behavior of
certain instructions or their interactions. The easiest method to test
a sequence of instructions to date, is to make a simple graphics test,
disassemble the pipelines, edit the assembly, recompile them and use
pipeline replacement to load the edited code.

This patch adds a simpler and more robust way by letting one write
inline assembly in glsl.

glsl allows strings only in a single place, which is the debug print
instruction. Using the special '%ra' format specifier [0] triggers llpc
to interpret the second argument as an inline assembly string.

The arguments to printf are:

  • "%ra" for radeon-assembly
  • assembly instructions
  • variable constraints
  • "no output" or a variable where the output is stored (optional if
    there are no further arguments)
  • zero or more arguments

See the llvm reference for more details on how to write the constraint
string: https://llvm.org/docs/LangRef.html#inline-assembler-expressions

The added tests contain an example of how inline assembly can be used.

[0]: The list of existing format specifiers does not include a %r:
https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/master/docs/debug_printf.md#debug-printf-format-string

test/amber/a16.amber Outdated Show resolved Hide resolved
@Flakebi Flakebi force-pushed the inline-asm branch 2 times, most recently from 8a30cb6 to 4ddc59b Compare April 6, 2022 14:50
@github-actions
Copy link

github-actions bot commented Apr 6, 2022

The LLPC code coverage report is available at https://storage.googleapis.com/amdvlk-llpc-github-ci-artifacts-public/coverage_release_clang_shadercache_coverage_assertions_2103206623/index.html.
Configuration: release_clang_shadercache_coverage_assertions.

@github-actions
Copy link

github-actions bot commented Apr 6, 2022

The LLPC code coverage report is available at https://storage.googleapis.com/amdvlk-llpc-github-ci-artifacts-public/coverage_release_clang_coverage_2103206623/index.html.
Configuration: release_clang_coverage.

@JaxLinAMD
Copy link
Contributor

retest this please

@amdvlk-admin
Copy link
Collaborator

Test summary for commit 4ddc59b

CTS tests (Failed: 0/195808)
  • Built with version 1.3.0.0
  • Rhel 8.2, Gfx10
    • Passed: 38337/67464 (56.8%)
    • Failed: 0/67464 (0.0%)
    • Not Supported: 29127/67464 (43.2%)
    • Warnings: 0/67464 (0.0%)
    Ubuntu 18.04, Gfx9
    • Passed: 33521/60880 (55.1%)
    • Failed: 0/60880 (0.0%)
    • Not Supported: 27359/60880 (44.9%)
    • Warnings: 0/60880 (0.0%)
    Ubuntu 20.04, Gfx8
    • Passed: 39335/67464 (58.3%)
    • Failed: 0/67464 (0.0%)
    • Not Supported: 28129/67464 (41.7%)
    • Warnings: 0/67464 (0.0%)

llpc/translator/lib/SPIRV/SPIRVReader.cpp Outdated Show resolved Hide resolved
llpc/translator/lib/SPIRV/SPIRVReader.cpp Outdated Show resolved Hide resolved
@Flakebi
Copy link
Member Author

Flakebi commented Apr 11, 2022

V2: Include SPIR-V header, move code into a function and use llvm diagnostics for errors so that it also works in release mode.

Still missing some documentation (is there a better place for documenting this than the comment in SPIRVReader.cpp?).

@github-actions
Copy link

The LLPC code coverage report is available at https://storage.googleapis.com/amdvlk-llpc-github-ci-artifacts-public/coverage_release_clang_coverage_2150024286/index.html.
Configuration: release_clang_coverage.

@github-actions
Copy link

The LLPC code coverage report is available at https://storage.googleapis.com/amdvlk-llpc-github-ci-artifacts-public/coverage_release_clang_shadercache_coverage_assertions_2150024286/index.html.
Configuration: release_clang_shadercache_coverage_assertions.

@amdvlk-admin
Copy link
Collaborator

Test summary for commit ac184dc

CTS tests (Failed: 0/195808)
  • Built with version 1.3.0.0
  • Rhel 8.2, Gfx10
    • Passed: 38337/67464 (56.8%)
    • Failed: 0/67464 (0.0%)
    • Not Supported: 29127/67464 (43.2%)
    • Warnings: 0/67464 (0.0%)
    Ubuntu 18.04, Gfx9
    • Passed: 33521/60880 (55.1%)
    • Failed: 0/60880 (0.0%)
    • Not Supported: 27359/60880 (44.9%)
    • Warnings: 0/60880 (0.0%)
    Ubuntu 20.04, Gfx8
    • Passed: 39335/67464 (58.3%)
    • Failed: 0/67464 (0.0%)
    • Not Supported: 28129/67464 (41.7%)
    • Warnings: 0/67464 (0.0%)

amdrexu
amdrexu previously approved these changes Apr 12, 2022
Copy link
Member

@amdrexu amdrexu left a comment

Choose a reason for hiding this comment

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

If you feed it is necessary, you can add a brief doc. But currently, the functionality seems straightforward by reading the inline comments.

So far, it is complicated and time-consuming to test the behavior of
certain instructions or their interactions. The easiest method to test
a sequence of instructions to date, is to make a simple graphics test,
disassemble the pipelines, edit the assembly, recompile them and use
pipeline replacement to load the edited code.

This patch adds a simpler and more robust way by letting one write
inline assembly in glsl.

glsl allows strings only in a single place, which is the debug print
instruction. Using the special '%ra' format specifier [0] triggers llpc
to interpret the second argument as an inline assembly string.

The arguments to printf are:
- "%ra" for radeon-assembly
- assembly instructions
- variable constraints
- "no output" or a variable where the output is stored (optional if
  there are no further arguments)
- zero or more arguments

See the llvm reference for more details on how to write the constraint
string: https://llvm.org/docs/LangRef.html#inline-assembler-expressions

The added tests contain an example of how inline assembly can be used.

[0]: The list of existing format specifiers does not include a %r:
https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/master/docs/debug_printf.md#debug-printf-format-string
@Flakebi
Copy link
Member Author

Flakebi commented Apr 12, 2022

V3: Add an example to the inline comment

@github-actions
Copy link

The LLPC code coverage report is available at https://storage.googleapis.com/amdvlk-llpc-github-ci-artifacts-public/coverage_release_clang_coverage_2153351864/index.html.
Configuration: release_clang_coverage.

@github-actions
Copy link

The LLPC code coverage report is available at https://storage.googleapis.com/amdvlk-llpc-github-ci-artifacts-public/coverage_release_clang_shadercache_coverage_assertions_2153351864/index.html.
Configuration: release_clang_shadercache_coverage_assertions.

@amdvlk-admin
Copy link
Collaborator

Test summary for commit e8b0a67

CTS tests (Failed: 0/195808)
  • Built with version 1.3.0.0
  • Rhel 8.2, Gfx10
    • Passed: 38337/67464 (56.8%)
    • Failed: 0/67464 (0.0%)
    • Not Supported: 29127/67464 (43.2%)
    • Warnings: 0/67464 (0.0%)
    Ubuntu 18.04, Gfx9
    • Passed: 33521/60880 (55.1%)
    • Failed: 0/60880 (0.0%)
    • Not Supported: 27359/60880 (44.9%)
    • Warnings: 0/60880 (0.0%)
    Ubuntu 20.04, Gfx8
    • Passed: 39335/67464 (58.3%)
    • Failed: 0/67464 (0.0%)
    • Not Supported: 28129/67464 (41.7%)
    • Warnings: 0/67464 (0.0%)

@Flakebi Flakebi merged commit b44997c into GPUOpen-Drivers:dev Apr 12, 2022
@Flakebi Flakebi deleted the inline-asm branch April 12, 2022 09:20
@amdrexu
Copy link
Member

amdrexu commented Apr 15, 2022

@Flakebi There are some internal discussions about this PR. Please check them with Nicolai. The porting is blocked.

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.

None yet

5 participants