Skip to content

[SYCL] Enable aspect usage propagation pass and add diagnostics #6982

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

Merged
merged 7 commits into from
Nov 4, 2022

Conversation

steffenlarsen
Copy link
Contributor

This commit adds a warning diagnostic for when there is a mismatch between aspect usage propagated to a function and the function's device_has attribute. Additionally, notes accompany the warning to give the user a trace through to where the aspects originate. Since the aspects are propagated in an LLVM pass, the warning is issued from there, which means no source information is available by default. To alleviate this, Clang CodeGen will now add srcloc metadata with an encoded version of the source location to allow the backend to correctly report the location for the various new diagnostics.

Additionally, this commit also adds the SYCLPropagateAspectsUsage pass to the passes run for SYCL device code.

This commit adds a warning diagnostic for when there is a mismatch
between aspect usage propagated to a function and the function's
`device_has` attribute. Additionally, notes accompany the warning to
give the user a trace through to where the aspects originate.
Since the aspects are propagated in an LLVM pass, the warning is issued
from there, which means no source information is available by default.
To alleviate this, Clang CodeGen will now add srcloc metadata with
an encoded version of the source location to allow the backend to
correctly report the location for the various new diagnostics.

Additionally, this commit also adds the SYCLPropagateAspectsUsage pass
to the passes run for SYCL device code.

Co-authored-by: Sabianin, Maksim <maksim.sabianin@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
@@ -1086,6 +1086,14 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
Fn->setMetadata("sycl_used_aspects",
llvm::MDNode::get(getLLVMContext(), AspectsMD));
}

// SYCL needs to know the source location of functions for diagnostics in
// the aspect propagation pass. Save the token in a srcloc metadata node.
Copy link
Contributor

Choose a reason for hiding this comment

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

I heard that not all optimizations care about metadata. Will it work when early optimizations enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The pass that uses srcloc relies on other metadata too, so we need it to run as early as possible. As such, srcloc should also be preserved with early opts too. As you suggest in the other comment, it may make sense to add it to the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added a test checking that it works with early optimizations: sycl/test/warnings/aspect_perserve_srcloc.cpp

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
@steffenlarsen steffenlarsen requested a review from a team as a code owner October 17, 2022 16:59
@AlexeySachkov AlexeySachkov requested a review from a team October 25, 2022 12:16
@steffenlarsen
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1353

@steffenlarsen
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1353

1 similar comment
@steffenlarsen
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1353

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. One nitpick. It might be helpful to reword the topic to let reviewers know that this change also adds this pass into the SYCL compilation pipeline.

Thanks.

@steffenlarsen steffenlarsen changed the title [SYCL] Implement optional device feature diagnostics [SYCL] Enable aspect usage propagation pass and add diagnostics Nov 2, 2022
@steffenlarsen
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1353

@steffenlarsen
Copy link
Contributor Author

Remaining verification failure in OpenCL on Windows for KernelAndProgram/kernel-bundle-merge-options-env.cpp is a known issue.

@steffenlarsen steffenlarsen merged commit 92c23b1 into intel:sycl Nov 4, 2022
0x12CC pushed a commit to oneapi-src/SYCLomatic-test that referenced this pull request Dec 6, 2022
…anged compiler behavior (#146)

* fix CI failed, due to compiler change after 20221202

Signed-off-by: Ni, Wenhui <wenhui.ni@intel.com>

* disable math_exec math_habs on gen12

Signed-off-by: Ni, Wenhui <wenhui.ni@intel.com>
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.

8 participants