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

Fix codegen bug when targeting PTX with new API #6506

Merged

Conversation

aleino-nv
Copy link
Collaborator

@aleino-nv aleino-nv commented Mar 3, 2025

  • add a repro of the problem
    • This is added as a unit test, because the new API is not yet in use for the tests in tests/
    • This unit test can be removed when the new API is used for tests/
  • Simple fix that detects entry points more robustly when applying some "ConstRef hack"
    • When using the old API, an explicit EntryPointAttribute was being attached to the entry point, even though none was present in the code

See issue #6507 for debugging notes.

This closes issue #6507.

@aleino-nv aleino-nv force-pushed the aleino/new-api-invalid-cuda-code-bug branch from 8d27bf0 to e3c1454 Compare March 4, 2025 09:00
@aleino-nv aleino-nv changed the title Aleino/new api invalid cuda code bug Fix codegen bug when targeting PTX with new API Mar 4, 2025
@aleino-nv aleino-nv marked this pull request as ready for review March 4, 2025 09:05
@aleino-nv aleino-nv requested a review from a team as a code owner March 4, 2025 09:05
@aleino-nv aleino-nv added the pr: non-breaking PRs without breaking changes label Mar 4, 2025
@aleino-nv aleino-nv force-pushed the aleino/new-api-invalid-cuda-code-bug branch from 8a360de to 216c894 Compare March 4, 2025 10:13
This just compiles tests/compute/simlpe.slang for PTX with the new compilation API, in
order to reproduce a code generation bug.
…wring

For shaders like tests/compute/simple.slang, which have a 'numthreads' attribute but no
'shader' attribute, the old compile request API would add an EntryPointAttribute to the
AST node of the entry point. However, the new API doesn't, and so a certain ConstRef hack
doesn't get applied when using the new API, leading to subsequent code generation issues.

This patch also checks for a 'numthreads' attribute when deciding whether to apply the
ConstRef hack.

This closes issue shader-slang#6507 and helps to resolve issue shader-slang#4760.
Our GitHub runners don't have the CUDA toolkits installed, so they can't run all tests.
@aleino-nv aleino-nv force-pushed the aleino/new-api-invalid-cuda-code-bug branch from 216c894 to fb67a82 Compare March 4, 2025 11:03
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm curious. What is the "runner" test list meant for, and why couldn't expected-failure-github.txt be used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Our GitHub runners don't have the CUDA toolkits installed, so they can't run all tests.
The unit test I add targets PTX and so needs the CUDA toolkit.

Ideally this should be detected at runtime, but I don't think we can readily do that.
The test should be short-lived, so I just added the runner list as a means to filter.

@aleino-nv aleino-nv enabled auto-merge (squash) March 5, 2025 05:56
@aleino-nv aleino-nv merged commit 5248a02 into shader-slang:master Mar 5, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants