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

[SYCL] Add aspect names to sycl_used_aspects before cleaning up #13486

Merged
merged 17 commits into from
May 29, 2024

Conversation

jzc
Copy link
Contributor

@jzc jzc commented Apr 18, 2024

This PR provides an alternate approach to the problem stated in #13194. Before cleaning up the metadata in CleanupSYCLMetadataPass, we update sycl_used_aspects metadata to include the aspect name. Note that the aspect name might not exist, e.g. in the case of the negative-valued "internal" aspects, in which case the value is passed along as normal.

enum SYCLInternalAspect : int32_t {
fp_intrinsic_accuracy_high = -1,
fp_intrinsic_accuracy_medium = -2,
fp_intrinsic_accuracy_low = -3,
fp_intrinsic_accuracy_sycl = -4,
fp_intrinsic_accuracy_cuda = -5,
};

@AlexeySachkov
Copy link
Contributor

Conceptually that is a cool idea, I think. It allows us to avoid potentially expensive FE changes to generate aspect names when aspects are attached through the corresponding attribute. It also shouldn't cause significant LLVM IR size increase, because even if the same aspect is used by different functions, metadata would just point to the same node for it, without duplicating the string with the aspect name.

I'm not entirely sure if CleanupSYCLMetadataPass is the right place for it, though. For me, cleanup means removal and suggested changes instead add something new instead of removing stuff. Perhaps a separate dedicated pass for this would be better? Or maybe we can even make it a part of existing propagate aspects usage pass somehow? If we go with the latter, we should be careful, because we are running it twice and the metadata format change should only happen once and ideally not in-between two pass invocations. @steffenlarsen, @intel/dpcpp-tools-reviewers, any feedback here?

@jzc
Copy link
Contributor Author

jzc commented Apr 24, 2024

@AlexeySachkov I did consider making it a part of the propagate aspect pass, but I did forget about the two pass approach. I was originally thinking that doing it in that pass would cause a lot of tests to have their format changed.

However, thinking about it more and now considering the two pass approach, I think if we wanted to do this transformation in the propagate aspects pass, we could a parameter to the pass that indicates whether this transformation is applied. That way, we could have the second pass do the transformation and not in-between. With the parameter too, I think it'll also reduce the amount of tests we have to change if we make the original behavior the default behavior of the pass.

@@ -980,7 +980,29 @@ getDeviceCodeSplitter(ModuleDesc &&MD, IRSplitMode Mode, bool IROutputOnly,
// output files in existing tests.
Categorizer.registerSimpleStringAttributeRule("sycl-register-alloc-mode");
Categorizer.registerSimpleStringAttributeRule("sycl-grf-size");
Categorizer.registerListOfIntegersInMetadataSortedRule("sycl_used_aspects");
Categorizer.registerRule([&](Function *F) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit.
Please, move it to dedicated function.

@AlexeySachkov
Copy link
Contributor

@AlexeySachkov I did consider making it a part of the propagate aspect pass, but I did forget about the two pass approach. I was originally thinking that doing it in that pass would cause a lot of tests to have their format changed.

However, thinking about it more and now considering the two pass approach, I think if we wanted to do this transformation in the propagate aspects pass, we could a parameter to the pass that indicates whether this transformation is applied. That way, we could have the second pass do the transformation and not in-between. With the parameter too, I think it'll also reduce the amount of tests we have to change if we make the original behavior the default behavior of the pass.

Note that my preference is probably to have a dedicated pass for this transformation just to have cleaner and more modular implementation even though the pass will likely be very small.

@jzc jzc temporarily deployed to WindowsCILock May 3, 2024 20:15 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to WindowsCILock May 3, 2024 21:00 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to WindowsCILock May 8, 2024 18:50 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to WindowsCILock May 8, 2024 19:38 — with GitHub Actions Inactive
llvm/include/llvm/SYCLLowerIR/AddAspectNames.h Outdated Show resolved Hide resolved
clang/lib/CodeGen/BackendUtil.cpp Outdated Show resolved Hide resolved
llvm/lib/SYCLLowerIR/AddAspectNames.cpp Outdated Show resolved Hide resolved
llvm/lib/SYCLLowerIR/AddAspectNames.cpp Outdated Show resolved Hide resolved
llvm/lib/SYCLLowerIR/AddAspectNames.cpp Outdated Show resolved Hide resolved
llvm/lib/SYCLLowerIR/ModuleSplitter.cpp Outdated Show resolved Hide resolved
@jzc jzc marked this pull request as ready for review May 14, 2024 15:31
@jzc jzc requested review from a team as code owners May 14, 2024 15:31
Copy link
Contributor

@premanandrao premanandrao left a comment

Choose a reason for hiding this comment

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

The FE changes themselves are small, I am okay with it.

Copy link
Contributor

@smanna12 smanna12 left a comment

Choose a reason for hiding this comment

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

FE change LGTM

@AlexeySachkov
Copy link
Contributor

@intel/dpcpp-esimd-reviewers, could you please take a look? I think it is only CMakeLists.txt change
@intel/llvm-reviewers-runtime, could you please take a look? I think it is only some test changes

@AlexeySachkov AlexeySachkov merged commit 563904b into intel:sycl May 29, 2024
13 checks passed
AlexeySachkov pushed a commit that referenced this pull request Jun 7, 2024
After #13486, aspect name information is visible in `sycl-post-link`
without the use of `!sycl_aspects`, so this PR updates `sycl-post-link`
to use the aspect names that are now available within the
`!sycl_used_aspects` metadata instead of `!sycl_aspects`.

Aditionally, this PR also adds E2E related to optional kernel features
for AOT enabled by these changes
ianayl pushed a commit to ianayl/sycl that referenced this pull request Jun 13, 2024
…13974)

After intel#13486, aspect name information is visible in `sycl-post-link`
without the use of `!sycl_aspects`, so this PR updates `sycl-post-link`
to use the aspect names that are now available within the
`!sycl_used_aspects` metadata instead of `!sycl_aspects`.

Aditionally, this PR also adds E2E related to optional kernel features
for AOT enabled by these changes
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