Skip to content

[SYCL] Augment known_identity for std::complex and std::plus. #8425

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
Mar 2, 2023

Conversation

uditagarwal97
Copy link
Contributor

@uditagarwal97 uditagarwal97 commented Feb 22, 2023

This PR proposes to augment sycl::has_known_identity to return true for std::complex and std::plus operator. This will have two benefits:

  1. It enables support for complex numbers in sycl::reduction without the user having to explicitly pass identity.
  2. sycl::known_identity can now be used to simplify the implementation of group algorithms (See PR [SYCL] Add complex support to group algorithms #5394).

Also, this PR addresses the Github issue #5477.
Test Case PR: intel/llvm-test-suite#1609

Comment on lines 68 to 69
bool_constant<std::is_same<T, std::complex<short>>::value ||
std::is_same<T, std::complex<int>>::value ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have these two instantiations of std::complex<> for integral T?

I've only ever seen std::complex<float>, std::complex<double> and std::complex<long double>. Both sycl_ext_oneapi_complex and sycl_ext_oneapi_complex_algorithms only support float, double and sycl::half.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for bringing this up. I wasn't aware that for std::complex, we only support float and double types. I've accordingly made the changes.

@uditagarwal97 uditagarwal97 temporarily deployed to aws February 22, 2023 16:57 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 22, 2023 17:54 — with GitHub Actions Inactive
@aelovikov-intel
Copy link
Contributor

Do we need to update any extensions with new wording?

@uditagarwal97 uditagarwal97 temporarily deployed to aws February 22, 2023 18:53 — with GitHub Actions Inactive
@uditagarwal97
Copy link
Contributor Author

Do we need to update any extensions with new wording?

I'm not sure but I think update to sycl_ext_oneapi_complex_algorithms.asciidoc is not required as it already introduces std::complex and std::complex to reduce and reduce_over_group algorithms.
@Pennycook What's your opinion?

@uditagarwal97 uditagarwal97 temporarily deployed to aws February 22, 2023 20:26 — with GitHub Actions Inactive
@Pennycook
Copy link
Contributor

I'm not sure but I think update to sycl_ext_oneapi_complex_algorithms.asciidoc is not required as it already introduces std::complex and std::complex to reduce and reduce_over_group algorithms. @Pennycook What's your opinion?

SYCL 2020 says:

If an implementation can identify an identity value for a given combination of accumulator type and function object type, the value is defined as a member of the known_identity trait class. Whether this member value exists can be tested using the has_known_identity trait class.

Since the intent of this trait is to let people test which types an implementation can reason about, it seems redundant to also put that information into an extension specification. But I might just be feeling lazy, so I'd like @gmlueck's opinion on this.

@gmlueck
Copy link
Contributor

gmlueck commented Feb 22, 2023

Since the intent of this trait is to let people test which types an implementation can reason about, it seems redundant to also put that information into an extension specification. But I might just be feeling lazy, so I'd like @gmlueck's opinion on this.

I think it's worthwhile to add this to the extension specification. The core SYCL spec has Table 123 "Known identities", which lists the operators that have known identifies for certain types. It would make sense for our extension spec to list extended cases that have known identities.

BTW, sycl_ext_oneapi_complex_algorithms is listed as "proposed". Is this implemented now? If so, it should be moved to either "experimental" or "supported" as appropriate (and it should be updated to note its current status).

@uditagarwal97 uditagarwal97 temporarily deployed to aws February 24, 2023 12:24 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 24, 2023 19:13 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 24, 2023 19:58 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 requested a review from a team as a code owner February 27, 2023 19:39
@uditagarwal97
Copy link
Contributor Author

Since the intent of this trait is to let people test which types an implementation can reason about, it seems redundant to also put that information into an extension specification. But I might just be feeling lazy, so I'd like @gmlueck's opinion on this.

I think it's worthwhile to add this to the extension specification. The core SYCL spec has Table 123 "Known identities", which lists the operators that have known identifies for certain types. It would make sense for our extension spec to list extended cases that have known identities.

Sure, thanks for the feedback. I've updated the extension specification as well. @Pennycook please review the changes.

BTW, sycl_ext_oneapi_complex_algorithms is listed as "proposed". Is this implemented now? If so, it should be moved to either "experimental" or "supported" as appropriate (and it should be updated to note its current status).

I don't know if sycl_ext_oneapi_complex_algorithms is completely implemented.

@gmlueck
Copy link
Contributor

gmlueck commented Feb 27, 2023

I don't know if sycl_ext_oneapi_complex_algorithms is completely implemented.

Do either of you know? I'm wondering if we just forgot to move the extension specification.

@Pennycook
Copy link
Contributor

Do either of you know? I'm wondering if we just forgot to move the extension specification.

sycl_ext_oneapi_complex_algorithms says that it depends on two other extensions. The first is sycl_ext_oneapi_complex, which is still showing as "proposed". The second is sycl_ext_oneapi_marray, which hasn't actually been merged yet: #6550

@uditagarwal97 uditagarwal97 temporarily deployed to aws February 27, 2023 21:18 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 27, 2023 22:00 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 28, 2023 03:13 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 28, 2023 09:57 — with GitHub Actions Inactive
Copy link
Contributor

@gmlueck gmlueck left a comment

Choose a reason for hiding this comment

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

spec changes LGTM

Copy link
Contributor

@aelovikov-intel aelovikov-intel left a comment

Choose a reason for hiding this comment

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

SYCL RT changes LGTM.

@uditagarwal97 uditagarwal97 temporarily deployed to aws February 28, 2023 23:22 — with GitHub Actions Inactive
@uditagarwal97
Copy link
Contributor Author

@intel/llvm-gatekeepers The PR is ready!

@uditagarwal97 uditagarwal97 temporarily deployed to aws March 2, 2023 12:24 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws March 2, 2023 14:02 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws March 2, 2023 14:39 — with GitHub Actions Inactive
@steffenlarsen
Copy link
Contributor

CUDA Failed Tests (1):
SYCL :: SubGroup/shuffle_fp64.cpp
Unrelated and reported in #8516.

@steffenlarsen steffenlarsen merged commit 2e73312 into intel:sycl Mar 2, 2023
steffenlarsen pushed a commit to intel/llvm-test-suite that referenced this pull request Mar 22, 2023
This PR adds test case for testing identityless reduction for complex numbers.

Corresponding intel/llvm PR: intel/llvm#8425
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
This PR adds test case for testing identityless reduction for complex numbers.

Corresponding intel/llvm PR: intel#8425
@uditagarwal97 uditagarwal97 deleted the complex_reduction branch March 21, 2024 19:59
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.

5 participants