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: support 0-dim acc in handler::copy(accessor, accessor) #1551

Merged
merged 1 commit into from
Apr 22, 2020

Conversation

v-klochkov
Copy link
Contributor

Signed-off-by: Vyacheslav N Klochkov vyacheslav.n.klochkov@intel.com

@v-klochkov v-klochkov requested a review from a team as a code owner April 20, 2020 10:39
sycl/include/CL/sycl/handler.hpp Outdated Show resolved Hide resolved
sycl/include/CL/sycl/handler.hpp Outdated Show resolved Hide resolved
@s-kanaev
Copy link
Contributor

@v-klochkov Please apply clang-format to the patch. You can find usefule artifacts in deails of clang-format-check job details.

@v-klochkov v-klochkov force-pushed the public_vklochkov_copy_0dim branch from c69dac4 to 8b33aaa Compare April 20, 2020 19:46
@v-klochkov v-klochkov requested a review from romanovvlad April 20, 2020 19:47
@v-klochkov
Copy link
Contributor Author

@s-kanaev I gave some honor to clang-format and added few additional/recommended changes.
I though want to ignore few places
a) 2 places in handler.hpp: the code without clang-format is much more readable and
b) 2 places in LIT test: I just follow the more compact style of all other similar funcs in LIT test.

@v-klochkov
Copy link
Contributor Author

@romanovvlad Thank you for the quick initial review.
I updated the changes in handler.hpp and also added 3 more cases to LIT test to check atomics.

@v-klochkov v-klochkov force-pushed the public_vklochkov_copy_0dim branch from 8b33aaa to 8bfe7eb Compare April 20, 2020 20:01
typename TSrc, int DimSrc, access::mode ModeSrc, access::target TargetSrc,
typename TDst, int DimDst, access::mode ModeDst, access::target TargetDst,
access::placeholder IsPHSrc, access::placeholder IsPHDst>
detail::enable_if_t<(DimSrc > 0) && (DimDst > 0), bool>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check here if DimSrc == DimDst?

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 don't know if it is correct to copy from 1D accessor to 3D. It is probably correct. So, that check is not needed.
In my patch I do not change any constraints.
My patch only separates the existing code to this routine to make it possible to copy to/from 0-dim accessor.

access::placeholder IsPH>
detail::enable_if_t<Dim == 0 && Mode == access::mode::atomic, T>
readFromFirstAccElement(accessor<T, Dim, Mode, Target, IsPH> Src) const {
auto AtomicSrc = (atomic<T, access::address_space::global_space>)Src;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this conversion be converted to this?

Suggested change
auto AtomicSrc = (atomic<T, access::address_space::global_space>)Src;
atomic<T, access::address_space::global_space> AtomicSrc = Src;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I changed it that way.

access::placeholder IsPH>
detail::enable_if_t<Dim == 0 && Mode == access::mode::atomic, void>
writeToFirstAccElement(accessor<T, Dim, Mode, Target, IsPH> Dst, T V) const {
auto AtomicDst = (atomic<T, access::address_space::global_space>)Dst;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@s-kanaev
Copy link
Contributor

@s-kanaev I gave some honor to clang-format and added few additional/recommended changes.
I though want to ignore few places
a) 2 places in handler.hpp: the code without clang-format is much more readable and
b) 2 places in LIT test: I just follow the more compact style of all other similar funcs in LIT test.

I believe you have to massage the code to make clang-format happy.

@v-klochkov v-klochkov force-pushed the public_vklochkov_copy_0dim branch from 8bfe7eb to f82691c Compare April 21, 2020 17:16
@v-klochkov
Copy link
Contributor Author

@s-kanaev

I believe you have to massage the code to make clang-format happy.

I already applied clang-format per your request, and ignored format's recommendation in only 4 places in sake of better code readability. Did you read my reasoning above?
Sure, clang-format is good in 95%, but let's not turn it into dogma, please.

@v-klochkov v-klochkov requested a review from s-kanaev April 21, 2020 17:25
romanovvlad
romanovvlad previously approved these changes Apr 21, 2020
Copy link
Contributor

@romanovvlad romanovvlad left a comment

Choose a reason for hiding this comment

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

LGTM, but I would like @s-kanaev to approve as well.

@s-kanaev
Copy link
Contributor

I already applied clang-format per your request, and ignored format's recommendation in only 4 places in sake of better code readability. Did you read my reasoning above?
Sure, clang-format is good in 95%, but let's not turn it into dogma, please.

I understand readability as a pretty good reason. The justification for my argument is that I'm not really sure that "Merge" button will be available with clang-format job failed.

access::placeholder IsPH>
detail::enable_if_t<Dim == 0 && Mode == access::mode::atomic, void>
writeToFirstAccElement(accessor<T, Dim, Mode, Target, IsPH> Dst, T V) const {
atomic<T, access::address_space::global_space> AtomicDst = Dst;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be a reference to atomic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The accessor operator[] and operator() return a value, not a reference.

93 /* Available only when: accessMode == access::mode::atomic && dimensions ==
94 0 /
95 operator atomic<dataT, access::address_space::global_space> () const;
96
97 /
Available only when: accessMode == access::mode::atomic && dimensions >
98 0 */
99 atomic<dataT, access::address_space::global_space> operator[](
100 id index) const;

Please clarify if I understood your comment incorrectly.
Did you think about adding & sign right before AtomicDst?
atomic<T, access::address_space::global_space> &AtomicDst = Dst;
If so it would be incorrect code, I think.

@romanovvlad
Copy link
Contributor

I already applied clang-format per your request, and ignored format's recommendation in only 4 places in sake of better code readability. Did you read my reasoning above?
Sure, clang-format is good in 95%, but let's not turn it into dogma, please.

I understand readability as a pretty good reason. The justification for my argument is that I'm not really sure that "Merge" button will be available with clang-format job failed.

clang-format-check is not required so we should be able to merge even if it fails

@bader
Copy link
Contributor

bader commented Apr 21, 2020

I already applied clang-format per your request, and ignored format's recommendation in only 4 places in sake of better code readability. Did you read my reasoning above?
Sure, clang-format is good in 95%, but let's not turn it into dogma, please.

I understand readability as a pretty good reason. The justification for my argument is that I'm not really sure that "Merge" button will be available with clang-format job failed.

The reason to make this change is to make consistent formatting across the project, not to make "merge button available".

@v-klochkov, if you think that our project should not accept changes proposed by clang-format, please suggest clang-format configuration file changes. It's much better approach than just break the guidelines followed by the community.

@s-kanaev
Copy link
Contributor

s-kanaev commented Apr 21, 2020

The reason to make this change is to make consistent formatting across the project, not to make "merge button available".

I understand it pretty much. I have only translated mechanics or sequence of actions into plain English.

Signed-off-by: Vyacheslav N Klochkov <vyacheslav.n.klochkov@intel.com>
@v-klochkov v-klochkov force-pushed the public_vklochkov_copy_0dim branch from 6faf521 to bc90862 Compare April 21, 2020 21:36
@v-klochkov
Copy link
Contributor Author

I understand readability as a pretty good reason. The justification for my argument is that I'm not really sure that "Merge" button will be available with clang-format job failed.

The reason to make this change is to make consistent formatting across the project, not to make "merge button available".

@v-klochkov, if you think that our project should not accept changes proposed by clang-format, please suggest clang-format configuration file changes. It's much better approach than just break the guidelines followed by the community.

Teaching clang-format to recognize the existing laconic/1-line style/format already used in file,
or teaching it to recognize pattern in arg names does not seem easy doable and/or deserving time.

'clang-format' check did not have "Required" status, thus I thought there was some flexibility here.
The clang-format issue is fixed now.

Copy link
Contributor

@s-kanaev s-kanaev left a comment

Choose a reason for hiding this comment

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

The changes LGTM.

Might need some changes in config of clang-format, though.

@bader bader merged commit 5666107 into intel:sycl Apr 22, 2020
@v-klochkov v-klochkov deleted the public_vklochkov_copy_0dim branch April 22, 2020 17:01
alexbatashev pushed a commit to alexbatashev/llvm that referenced this pull request Apr 29, 2020
…versioning

* origin/sycl:
  [XPTI][Framework] Reference implementation of the Xpti framework to be used with instrumentation in SYCL (intel#1557)
  [SYCL] Initial ABI checks implementation (intel#1528)
  [SYCL] Support connection with multiple plugins (intel#1490)
  [SYCL] Add a new header file with the reduction class definition (intel#1558)
  [SYCL] Add test for SYCL kernels with accessor and spec constant (intel#1536)
  [SYCL][CUDA] Move interop tests (intel#1570)
  [Driver][SYCL] Remove COFF object format designator for Windows device compiles (intel#1574)
  [SYCL] Fix conflicting visibility attributes (intel#1571)
  [SYCL][DOC] Update the SYCL Runtime Interface document with design details (intel#680)
  [SYCL] Improve image accessors support on a host device (intel#1502)
  [SYCL] Make queue's non-USM event ownership temporary (intel#1561)
  [SYCL] Added support of rounding modes for non-host devices (intel#1463)
  [SYCL] SemaSYCL significant refactoring (intel#1517)
  [SYCL] Support 0-dim accessor in handler::copy(accessor, accessor) (intel#1551)
v-klochkov added a commit to v-klochkov/llvm that referenced this pull request Jan 28, 2021
Accessors with atomic access mode were supported in handler::copy() by mistake
in the patch (intel#1551).

Signed-off-by: Vyacheslav N Klochkov <vyacheslav.n.klochkov@intel.com>
v-klochkov added a commit that referenced this pull request Jan 30, 2021
Accessors with atomic access mode were supported in handler::copy() by mistake
in the patch (#1551).

Signed-off-by: Vyacheslav N Klochkov <vyacheslav.n.klochkov@intel.com>
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.

4 participants