Skip to content

[SYCL] Add local_accessor and deprecate target::local #6341

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 16 commits into from
Aug 25, 2022

Conversation

AidanBeltonS
Copy link
Contributor

This PR creates the local_accessor class by aliasing the accessor class with target::local.
The motivation behind this is that target::local has been deprecated in favour of local_accessor in SYCL2020.
The approach of aliasing is taken as the spec states that local_access has the same semantics and restrictions as accessor with target::local.

Related issue: #4713
llvm-test-suite: intel/llvm-test-suite#1063

Copy link
Contributor

@againull againull left a comment

Choose a reason for hiding this comment

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

I'm sorry for the delayed review.

Comment on lines 2018 to 2021
class __SYCL_SPECIAL_CLASS __SYCL2020_DEPRECATED(
"'accessor' with 'target::local' is deprecated: use 'local_accessor' "
"instead.") accessor<DataT, Dimensions, AccessMode, access::target::local,
IsPlaceholder> :
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately [[deprecated]] attribute doesn't work on template specializations: https://godbolt.org/z/nx56bsfjz
Deprecation message is not generated.

Another problem is that even if you deprecate this template specialization then I believe usage of local_accessor alias will result in deprecated message as well, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, that is a bit of an issue. I think a possible solution could be to deprecate the class constructors instead of the class itself.
The only way I can think of to resolve the alias of local_accessor producing a deprecated message is to create a new class just for local_accessor.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed this seems to be very unpleasant issue, I'm sorry.

Other possible option is just to not add [[deprecated]] attribute in this patch if we are ok with absence of deprecation message. @steffenlarsen Do you think it is ok to not emit deprecation warning in this case? Since emitting a deprecation warning in this case causes too much headache and it seems to be only usability issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would definitely prefer that we deprecate the API explicitly, but you are right that we cannot deprecate specializations.

That said, SYCL 2020 deprecated select members of target, local included, so what I suggest is:

  1. Deprecate access::target::local.
  2. Move the implementation in this specialization into a new local_accessor class.
  3. Make local_accessor a base class of this accessor specialization.

This has the added benefit of making it easy to remove the deprecated specialization when we remove (access::)target::local in the future. 😄

Copy link
Contributor

@againull againull Jun 29, 2022

Choose a reason for hiding this comment

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

@steffenlarsen Sounds great to me, thanks a lot for the help!

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 updated this PR to follow the suggested approach. It takes a slightly different structure by using a local_accessor_base class to implement both local_accessor and accessor. This is necessary to handle accessors template arguments.

Additionally, some changes to Clang's SemaSYCL were applied so the new local_accessor is identified and correctly handled.

@AidanBeltonS AidanBeltonS requested a review from a team as a code owner August 10, 2022 09:42
premanandrao
premanandrao previously approved these changes Aug 11, 2022
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.

FE changes look good to me.

smanna12
smanna12 previously approved these changes Aug 11, 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.

FE changes LGTM.

@AidanBeltonS AidanBeltonS dismissed stale reviews from smanna12 and premanandrao via e662262 August 12, 2022 14:17
@AidanBeltonS AidanBeltonS temporarily deployed to aws August 12, 2022 14:20 Inactive
remove unnecessary cl namespace

Co-authored-by: Steffen Larsen <steffen.larsen@intel.com>
@AidanBeltonS AidanBeltonS temporarily deployed to aws August 12, 2022 14:28 Inactive
@againull againull self-requested a review August 15, 2022 17:15
@steffenlarsen
Copy link
Contributor

Friendly ping, @intel/dpcpp-esimd-reviewers

Copy link
Contributor

@v-klochkov v-klochkov left a comment

Choose a reason for hiding this comment

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

ESIMD related changes have only minor differences in 1 LIT test.
Ok for ESIMD. Thank you.

@steffenlarsen steffenlarsen merged commit e4423ef into intel:sycl Aug 25, 2022
@steffenlarsen
Copy link
Contributor

@AidanBeltonS - Commit fails in post-commit. Seems like MSVC is having trouble with the default template argument in AccessorSubscript. Could you please investigate?

@AidanBeltonS
Copy link
Contributor Author

@AidanBeltonS - Commit fails in post-commit. Seems like MSVC is having trouble with the default template argument in AccessorSubscript. Could you please investigate?

Okay I am currently looking into it.

@AidanBeltonS
Copy link
Contributor Author

I have proposed a fix for this issue with #6648.

@AidanBeltonS AidanBeltonS deleted the local_accessor branch August 26, 2022 09:56
steffenlarsen pushed a commit that referenced this pull request Aug 26, 2022
This PR fixes an issue caused when building on Windows with MSVC. The problem was introduced in #6341. 
MSVC does not correctly infer the default template for its return type. This is fixed by setting the return type to auto and letting the compiler infer the return type.
@steffenlarsen
Copy link
Contributor

I have proposed a fix for this issue with #6648.

Post-commit is back to green. Thank you, @AidanBeltonS !

steffenlarsen pushed a commit to intel/llvm-test-suite that referenced this pull request Sep 2, 2022
This PR updates tests that use `target::local` to local_accessor. In all cases the change should not functionally change the test. The goal is to move from the deprecated `target::local` accessor to `local_accessor`.

Depends on: intel/llvm#6341
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Feb 23, 2023
This PR updates tests that use `target::local` to local_accessor. In all cases the change should not functionally change the test. The goal is to move from the deprecated `target::local` accessor to `local_accessor`.

Depends on: intel#6341
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
This PR updates tests that use `target::local` to local_accessor. In all cases the change should not functionally change the test. The goal is to move from the deprecated `target::local` accessor to `local_accessor`.

Depends on: intel#6341
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