Skip to content

[SYCL] Merge sycl_declared_aspects to sycl_used_aspects #7419

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 8 commits into from
Nov 17, 2022

Conversation

KornevNikita
Copy link
Contributor

@KornevNikita KornevNikita commented Nov 16, 2022

To make RT be able to throw an exception if device doesn't support the feature pass should also propagate sycl_declared aspects by merging it with sycl_used_aspects.
Design: #7415

To make RT be able to throw an exception if device doesn't support the
feature pass should also propagate sycl_declared aspects by merging it
with sycl_used_aspects.
Spec: intel#7415
@KornevNikita KornevNikita requested a review from a team as a code owner November 16, 2022 16:36
@@ -8,25 +8,25 @@ queue q;

// CHECK: define dso_local spir_kernel void @{{.*}}kernel_name_1{{.*}} !sycl_declared_aspects ![[ASPECTS1:[0-9]+]] !srcloc ![[SRCLOC1:[0-9]+]]

// CHECK: define dso_local spir_func void @{{.*}}func1{{.*}} !sycl_declared_aspects ![[ASPECTS1]] !srcloc ![[SRCLOC2:[0-9]+]] {
// CHECK: define dso_local spir_func void @{{.*}}func1{{.*}} !sycl_declared_aspects ![[ASPECTS1]] !srcloc ![[SRCLOC2:[0-9]+]]
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 run the pass even if -disable-llvm-passes option is passed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to understand why the clang-only test was changed :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I fixed this test because it was failed. Seems like we are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like we need this FE test changes for now

Copy link
Contributor

@elizabethandrews elizabethandrews Nov 16, 2022

Choose a reason for hiding this comment

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

I assume sycl_used_aspects metadata is being added here since the pass runs even if we pass -disable-llvm-passes. Can you modify the CHECK to test for it as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly. Sure thing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 435c611

Copy link
Contributor

Choose a reason for hiding this comment

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

Please modify the comment at the top of the test to indicate we check sycl_used_aspects here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KornevNikita KornevNikita requested a review from a team November 16, 2022 16:55
Copy link
Contributor

@elizabethandrews elizabethandrews left a comment

Choose a reason for hiding this comment

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

I have a generic question about this change. sycl_declared_aspects metadata is used to denote what aspects a kernel supports and sycl_used_aspects is used to represent what the kernel actually uses right? If you merge the 2, aren't you losing information on what is actually used in the kernel? Am I misunderstanding something?

@@ -8,25 +8,30 @@ queue q;

// CHECK: define dso_local spir_kernel void @{{.*}}kernel_name_1{{.*}} !sycl_declared_aspects ![[ASPECTS1:[0-9]+]] !srcloc ![[SRCLOC1:[0-9]+]]

// CHECK: define dso_local spir_func void @{{.*}}func1{{.*}} !sycl_declared_aspects ![[ASPECTS1]] !srcloc ![[SRCLOC2:[0-9]+]] {
// CHECK: define dso_local spir_func void @{{.*}}func1{{.*}} !sycl_declared_aspects ![[ASPECTS1]] !srcloc ![[SRCLOC2:[0-9]+]]
// CHECK-SAME: !sycl_used_aspects
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC the aspect list should be the same as that in !sycl_decl_aspects right? Please add ![[ASPECT1]] to this CHECK as well, and make similar modifications to remaining CHECK lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added e647f36.
About your question. Since sycl_declared_aspects strictly requires the device to support declared aspects whether they are really used or no. I believe It's ok to merge them into sycl_used_aspects so we treat them as used. @steffenlarsen am I right?

Copy link
Contributor

Choose a reason for hiding this comment

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

My point was that you lose information about which aspects were actually used in the kernel once this new pass runs. I am not sure for what all purposes actual aspect usage information is required, but off the top of my head I expect it is required to emit proper diagnostics, etc. I am assuming that this merge is done only after any pass which requires knowledge of actual aspects used is complete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we perform this merge at the end of the pass.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since the merge happens after the verification it should be okay, though you could argue that if functions disagree about aspects in their device_has attributes (or properties) it should also be a warning. That said, the spec only says a diagnostic needs to be issued if a kernel with a device_has "uses" an optional kernel feature.

After the pass, I don't see any problem in considering all device_has aspects as propagated uses as in some ways that is how the runtime will see them too. However, maybe there could be value in preserving information about the origin of the aspects, i.e. types/functions explicitly marked as using an aspect such as sycl::half. We could do this by changing the name of the metadata produced from the __sycl_detail__::__uses_aspects__ attribute, then in this pass we would extract that information and pass it along as we currently do the sycl_used_aspects. However, I don't know of a current use-case for this so I don't think it has to be part of these changes.

Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

Couple small comments, but otherwise LGTM!

@KornevNikita
Copy link
Contributor Author

Failures are unrelated: intel/llvm-test-suite#1380

@AlexeySachkov AlexeySachkov merged commit af9580e into intel:sycl Nov 17, 2022
AlexeySachkov pushed a commit to intel/llvm-test-suite that referenced this pull request Nov 21, 2022
@KornevNikita KornevNikita deleted the propagate-declared-aspects branch December 9, 2022 14:45
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
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.

7 participants