Skip to content

[SYCL] Fixed reported issues by a static verifier #10564

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 5 commits into from
Aug 1, 2023

Conversation

eunakim0103
Copy link
Contributor

@eunakim0103 eunakim0103 commented Jul 25, 2023

The static verifier tool reported following two issues and fixed with adding a copy constructor & assignment operator, and removing dead code.

  1. Missing user-defined assignment operator - "Copy without assign" rule violation
  2. Uninitialized scalar field - class member variable initialization

@eunakim0103 eunakim0103 requested a review from a team as a code owner July 25, 2023 22:36
@eunakim0103 eunakim0103 marked this pull request as draft July 25, 2023 22:38
Signed-off-by: Kim, Euna <[email protected]>
@eunakim0103 eunakim0103 temporarily deployed to aws July 25, 2023 22:59 — with GitHub Actions Inactive
@eunakim0103 eunakim0103 temporarily deployed to aws July 25, 2023 23:41 — with GitHub Actions Inactive
@@ -438,6 +438,8 @@ class buffer : public detail::buffer_plain,
PI_ERROR_INVALID_VALUE);
}

buffer &operator=(buffer<T, dimensions, AllocatorT> &rhs) = delete;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
buffer &operator=(buffer<T, dimensions, AllocatorT> &rhs) = delete;
buffer &operator=(const buffer &rhs) = delete;

Also, why do we delete it? We have a valid copy ctor for this class below.

Copy link
Contributor Author

@eunakim0103 eunakim0103 Jul 27, 2023

Choose a reason for hiding this comment

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

Line 461 of this file has that operator= definition already; The static verifier complains about a missing user-defined assignment operator for the templated definition of buffer as shown in the diff.

Copy link
Contributor Author

@eunakim0103 eunakim0103 Jul 27, 2023

Choose a reason for hiding this comment

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

It might not be necessary to have this templated assignment operator defined, but static verifier tool checked all of the copy constructor parameters and reported this as a problem. This addition will be removed.

@@ -252,6 +252,8 @@ struct sub_group_mask {
sub_group_mask(const sub_group_mask &rhs)
: Bits(rhs.Bits), bits_num(rhs.bits_num) {}

sub_group_mask &operator=(sub_group_mask &rhs) = delete;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sub_group_mask &operator=(sub_group_mask &rhs) = delete;
sub_group_mask &operator=(const sub_group_mask &rhs) = delete;

And again, why do we delete it? Seems to me like it should be valid to use copy assignment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Fixed. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the copy assignment operator still getting deleted instead of providing a proper implementation? This causes issues in Kokkos/desul, see https://github.com/desul/desul/blob/d2a78e176e0a30f5893c596012d1115df5289be7/atomics/include/desul/atomics/Compare_Exchange_SYCL.hpp#L106.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for pointing this out, @masterleinad ! Technically the copy assignment operator isn't part of sycl_ext_oneapi_sub_group_mask until version 2, but since we had it before I agree that we might as well have kept it around. I am adding it back in #10886.

@eunakim0103 eunakim0103 temporarily deployed to aws July 27, 2023 03:16 — with GitHub Actions Inactive
@eunakim0103 eunakim0103 temporarily deployed to aws July 27, 2023 03:56 — with GitHub Actions Inactive
@eunakim0103
Copy link
Contributor Author

The test fail is unrelated to this PR:
-- Testing: 1449 tests, 12 workers --
FAIL: SYCL :: Printf/char.cpp (1152 of 1449)
******************** TEST 'SYCL :: Printf/char.cpp' FAILED ********************

@eunakim0103 eunakim0103 marked this pull request as ready for review July 27, 2023 04:20
Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

LGTM!

@eunakim0103 eunakim0103 temporarily deployed to aws July 27, 2023 11:27 — with GitHub Actions Inactive
@eunakim0103 eunakim0103 temporarily deployed to aws July 27, 2023 12:06 — with GitHub Actions Inactive
@steffenlarsen
Copy link
Contributor

The test fail is unrelated to this PR: -- Testing: 1449 tests, 12 workers -- FAIL: SYCL :: Printf/char.cpp (1152 of 1449) ******************** TEST 'SYCL :: Printf/char.cpp' FAILED ********************

I do not remember seeing it fail elsewhere. Could you please push a merge commit to help confirm that it is unrelated?

@eunakim0103 eunakim0103 temporarily deployed to aws July 27, 2023 14:08 — with GitHub Actions Inactive
@eunakim0103 eunakim0103 temporarily deployed to aws July 27, 2023 14:48 — with GitHub Actions Inactive
@eunakim0103
Copy link
Contributor Author

@steffenlarsen We are going to add another commit to this PR. Please hold the merge request for now. I am going to covert to draft for now and and will open the review when it is ready shortly.

@eunakim0103 eunakim0103 marked this pull request as draft July 28, 2023 14:23
@steffenlarsen steffenlarsen marked this pull request as ready for review August 1, 2023 11:37
@steffenlarsen
Copy link
Contributor

Per offline discussion I have reopened this as the other changes will be unrelated and should be made a separate patch.

Precommit failure is an infrastructure hiccup.

@steffenlarsen steffenlarsen merged commit b659690 into intel:sycl Aug 1, 2023
steffenlarsen added a commit to steffenlarsen/llvm that referenced this pull request Aug 18, 2023
As part of version two of [sycl_ext_oneapi_sub_group_mask](https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/supported/sycl_ext_oneapi_sub_group_mask.asciidoc)
the copy-asssignment operator is defined as default but were deleted as
part of intel#10564. This changes them to
`default` ahead of version 2 of the extension to avoid regressions.

Signed-off-by: Larsen, Steffen <[email protected]>
steffenlarsen added a commit that referenced this pull request Aug 21, 2023
)

As part of version two of
[sycl_ext_oneapi_sub_group_mask](https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/supported/sycl_ext_oneapi_sub_group_mask.asciidoc)
the copy-asssignment operator is defined as default but were deleted as
part of #10564. This changes them to
`default` ahead of version 2 of the extension to avoid regressions.

---------

Signed-off-by: Larsen, Steffen <[email protected]>
@eunakim0103 eunakim0103 changed the title [SYCL] Coverity reported issues [SYCL] Fixed reported issues by a static verifier Aug 24, 2023
mdtoguchi pushed a commit to mdtoguchi/llvm that referenced this pull request Oct 18, 2023
Coverity reported following two issues and fixed with adding a copy
constructor & assignment operator, and removing dead code.

1. Missing user-defined assignment operator - "Copy without assign" rule
violation
2. Uninitialized scalar field - class member variable initialization

---------

Signed-off-by: Kim, Euna <[email protected]>
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.

3 participants