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 default argument support for work_group_size_hint attribute #5565

Merged
merged 12 commits into from Mar 2, 2022

Conversation

Michoumichmich
Copy link
Contributor

@Michoumichmich Michoumichmich commented Feb 13, 2022

This commit adds support for default arguments in [[sycl::work_group_size_hint]] according to the specification (5.8.1 Kernel attributes, table 180).

Signed-off by: Michel Migdal mm@mgdl.fr

Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

This is missing all of its test coverage.

clang/include/clang/Basic/Attr.td Outdated Show resolved Hide resolved
Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

This still needs test coverage for the changes. In addition to the functional change to making the arguments optional, we should have some tests for declaration merging. e.g.,

[[sycl::work_group_size_hint(1, 2, 3)]] void func();
[[sycl::work_group_size_hint(1)]] void func() {} // Should still have 1, 2, 3, right?

@Michoumichmich Michoumichmich marked this pull request as draft February 14, 2022 18:46
@Michoumichmich
Copy link
Contributor Author

Michoumichmich commented Feb 14, 2022

This still needs test coverage for the changes. In addition to the functional change to making the arguments optional, we should have some tests for declaration merging. e.g.,

I wasn't sure whether I was "allowed" to add tests for myself (as I was surprised that there were no prior tests), but I will.

[[sycl::work_group_size_hint(1, 2, 3)]] void func();
[[sycl::work_group_size_hint(1)]] void func() {} // Should still have 1, 2, 3, right?

Well, according to this comment:

// *different* attributes. This means that you should not be able to redeclare
this should be an error. No? (Furthermore it suggests that the dimensionality should match the kernel. But currently this is not diagnosed, but it's better like that). Maybe I will wait for #4224 to be resolved (dimX and dimZ are std::swapped in the implementation, but it's not done on this attribute)

@AaronBallman
Copy link
Contributor

This still needs test coverage for the changes. In addition to the functional change to making the arguments optional, we should have some tests for declaration merging. e.g.,

I wasn't sure whether I was "allowed" to add tests for myself (as I was surprised that there were no prior tests), but I will.

Oh, we definitely love new test coverage! :-)

[[sycl::work_group_size_hint(1, 2, 3)]] void func();
[[sycl::work_group_size_hint(1)]] void func() {} // Should still have 1, 2, 3, right?

Well, according to this comment:

// *different* attributes. This means that you should not be able to redeclare

this should be an error. No? (Furthermore it suggests that the dimensionality should match the kernel. But currently this is not diagnosed, but it's better like that). Maybe I will wait for #4224 to be resolved (dimX and dimZ are std::swapped in the implementation, but it's not done on this attribute)

Oh, great catch, I had completely forgotten about that really weird behavior. That should be an error situation. I'd recommend adding it as a test case with the same set of FIXME comments associated with it.

@Michoumichmich Michoumichmich marked this pull request as ready for review February 19, 2022 21:54
@AaronBallman
Copy link
Contributor

I'm adding some more reviewers for visibility.

@smanna12
Copy link
Contributor

@Michoumichmich, could you please update your PR description? Thanks

@Michoumichmich
Copy link
Contributor Author

@Michoumichmich, could you please update your PR description? Thanks

Yes, sorry, it's up-to-date now!

@Michoumichmich
Copy link
Contributor Author

Michoumichmich commented Feb 22, 2022

I added the workaround. However the same one should be applied reqd_work_group_size, but it never came up because tests are missing for a case like: __attribute__((reqd_work_group_size(1, 1, 1, 1))) in SemaOpenCL.

@Michoumichmich
Copy link
Contributor Author

Michoumichmich commented Feb 22, 2022

I also updated the documentation for work_group_size_hint and removed the part about handling reqd_work_group_size with num_simd_work_items (that was misplaced I guess and may already be found in the doc for intel::num_simd_work_items).

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 test file work-group-size-hint-host.cpp is misnamed. I would

clang/test/SemaSYCL/work-group-size-hint-device.cpp Outdated Show resolved Hide resolved
clang/test/SemaSYCL/work-group-size-hint-host.cpp Outdated Show resolved Hide resolved
Co-authored-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
Fznamznon
Fznamznon previously approved these changes Feb 28, 2022
Copy link
Contributor

@Fznamznon Fznamznon left a comment

Choose a reason for hiding this comment

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

LGTM

Co-authored-by: smanna12 <soumi.manna@intel.com>
Fznamznon
Fznamznon previously approved these changes Feb 28, 2022
smanna12
smanna12 previously approved these changes Feb 28, 2022
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.

LGTM

@Michoumichmich
Copy link
Contributor Author

Hum, that's surprising, check-clang-semasycl passed successfully on my side

@bader
Copy link
Contributor

bader commented Feb 28, 2022

Hum, that's surprising, check-clang-semasycl passed successfully on my side

It looks like your changes imply that PropagateAndDiagnoseDeviceAttr should be updated as well. Have you uploaded all the changes?

@Michoumichmich
Copy link
Contributor Author

Hum, that's surprising, check-clang-semasycl passed successfully on my side

It looks like your changes imply that PropagateAndDiagnoseDeviceAttr should be updated as well. Have you uploaded all the changes?

@bader @smanna12 thanks for the help, I fixed it, I believe that llvm_unreachable did not trigger the error because I built in release

@bader
Copy link
Contributor

bader commented Feb 28, 2022

Okay.
NOTE: you can use Release for CMAKE_BUILD_TYPE and have assertions enabled LLVM_ENABLE_ASSERTIONS at the same time.

@bader
Copy link
Contributor

bader commented Mar 1, 2022

Pre-commit failures are not related to this patch and being investigated. @AaronBallman, please, check if you are okay with the changes.

AaronBallman
AaronBallman previously approved these changes Mar 1, 2022
Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM aside from some typos!

clang/include/clang/Basic/Attr.td Outdated Show resolved Hide resolved
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM!

@bader bader changed the title [SYCL] Fixes for work_group_size_hint [SYCL] Add default argument support for work_group_size_hint attribute Mar 2, 2022
@bader bader merged commit 0cff80e into intel:sycl Mar 2, 2022
@Michoumichmich Michoumichmich deleted the fixes_work_group_size_hint branch March 2, 2022 10:57
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.

None yet

6 participants