Skip to content

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

Merged
AlexeySachkov merged 17 commits into
intel:syclfrom
jzc:add-aspect-names
May 29, 2024
Merged

AlexeySachkov merged 17 commits into
intel:syclfrom
jzc:add-aspect-names

Conversation

@jzc

@jzc jzc commented Apr 18, 2024 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

jzc commented Apr 24, 2024

Copy link
Copy Markdown
Contributor Author

@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.

Comment thread llvm/lib/SYCLLowerIR/ModuleSplitter.cpp Outdated
Categorizer.registerSimpleStringAttributeRule("sycl-register-alloc-mode");
Categorizer.registerSimpleStringAttributeRule("sycl-grf-size");
Categorizer.registerListOfIntegersInMetadataSortedRule("sycl_used_aspects");
Categorizer.registerRule([&](Function *F) {

Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread clang/lib/CodeGen/BackendUtil.cpp Resolved
Comment thread llvm/lib/SYCLLowerIR/AddAspectNames.cpp Resolved
Comment thread llvm/lib/SYCLLowerIR/AddAspectNames.cpp Resolved
Comment thread llvm/lib/SYCLLowerIR/AddAspectNames.cpp Resolved
Comment thread llvm/lib/SYCLLowerIR/ModuleSplitter.cpp 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

@premanandrao premanandrao left a comment

Copy link
Copy Markdown
Contributor

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.

@jzc
jzc temporarily deployed to WindowsCILock May 21, 2024 21:35 — with GitHub Actions Inactive
@jzc
jzc temporarily deployed to WindowsCILock May 21, 2024 22:21 — with GitHub Actions Inactive

@smanna12 smanna12 left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
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

This branch was previously deployed

1 inactive deployment
WindowsCILock — ff1140bf Deployed May 21, 2024 by jzc
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