From d4c632094421a7b86f75c18d5456c977b54130f6 Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Tue, 21 Feb 2023 21:15:14 -0800 Subject: [PATCH 1/5] [SYCL] Augment known_identity for std::complex and std::plus. --- sycl/include/sycl/known_identity.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sycl/include/sycl/known_identity.hpp b/sycl/include/sycl/known_identity.hpp index 39981f9d4720c..718b8115a4c5f 100644 --- a/sycl/include/sycl/known_identity.hpp +++ b/sycl/include/sycl/known_identity.hpp @@ -63,6 +63,13 @@ using IsLogicalOR = bool_constant>::value || std::is_same>::value>; +template +using isComplex = + bool_constant>::value || + std::is_same>::value || + std::is_same>::value || + std::is_same>::value>; + // Identity = 0 template using IsZeroIdentityOp = @@ -70,7 +77,10 @@ using IsZeroIdentityOp = (IsPlus::value || IsBitOR::value || IsBitXOR::value)) || - (is_genfloat::value && IsPlus::value)>; + (is_genfloat::value && + IsPlus::value) || + (isComplex::value && + IsPlus::value)>; // Identity = 1 template From 92225acd99853160d6729549a7ecf8ff037e4b1b Mon Sep 17 00:00:00 2001 From: "Agarwal, Udit" Date: Wed, 22 Feb 2023 09:16:55 -0800 Subject: [PATCH 2/5] Only support floating-point templates for std::complex. --- sycl/include/sycl/known_identity.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sycl/include/sycl/known_identity.hpp b/sycl/include/sycl/known_identity.hpp index 718b8115a4c5f..dbc42aacce951 100644 --- a/sycl/include/sycl/known_identity.hpp +++ b/sycl/include/sycl/known_identity.hpp @@ -65,9 +65,7 @@ using IsLogicalOR = template using isComplex = - bool_constant>::value || - std::is_same>::value || - std::is_same>::value || + bool_constant>::value || std::is_same>::value>; // Identity = 0 From be4de835898f3bb8a1f72daec2731c7d780f692e Mon Sep 17 00:00:00 2001 From: Udit kumar agarwal <16324601+uditagarwal97@users.noreply.github.com> Date: Mon, 27 Feb 2023 11:39:10 -0800 Subject: [PATCH 3/5] [SYCL][DOC] Update extension specification to extend sycl::known_identies to std::complex --- .../proposed/sycl_ext_oneapi_complex_algorithms.asciidoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc b/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc index 3f65f58e3341c..fdc2ab7054abc 100644 --- a/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc +++ b/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc @@ -125,6 +125,10 @@ NOTE: `sycl::bit_and`, `sycl::bit_or`, `sycl::bit_xor`, `sycl::logical_and`, because their behaviors are defined in terms of operators that `std::complex` does not implement. +=== Known Identities + +Along with the known identities listed in https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#table.identities[Table 123], `sycl::known_identity` and `sycl::has_known_identity` also support `std::complex` with floating-point types. + == Issues None. From 990fcd8331076e054fa526dd8fb972482d1a5712 Mon Sep 17 00:00:00 2001 From: Udit kumar agarwal <16324601+uditagarwal97@users.noreply.github.com> Date: Mon, 27 Feb 2023 11:48:15 -0800 Subject: [PATCH 4/5] Fix typo. --- .../proposed/sycl_ext_oneapi_complex_algorithms.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc b/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc index fdc2ab7054abc..2e1adedc16bc0 100644 --- a/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc +++ b/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc @@ -127,7 +127,7 @@ does not implement. === Known Identities -Along with the known identities listed in https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#table.identities[Table 123], `sycl::known_identity` and `sycl::has_known_identity` also support `std::complex` with floating-point types. +Along with the known identities listed in https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#table.identities[Table 123], `sycl::known_identity` and `sycl::has_known_identity` also support `std::complex` with the `float` and `double` floating-point types. == Issues From bc631436f127ad4d836d1cc607b50e833e4cf8d1 Mon Sep 17 00:00:00 2001 From: Udit kumar agarwal <16324601+uditagarwal97@users.noreply.github.com> Date: Mon, 27 Feb 2023 14:30:31 -0800 Subject: [PATCH 5/5] [SYCL][DOCS] Minor formatting changes. --- .../sycl_ext_oneapi_complex_algorithms.asciidoc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc b/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc index 2e1adedc16bc0..da4484d255eb4 100644 --- a/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc +++ b/sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc @@ -127,7 +127,15 @@ does not implement. === Known Identities -Along with the known identities listed in https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#table.identities[Table 123], `sycl::known_identity` and `sycl::has_known_identity` also support `std::complex` with the `float` and `double` floating-point types. +This extension adds the following known identities, augmenting https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#table.identities[Table 123] in the core SYCL specification: +[cols="5,30,70"] +[grid="rows"] +[options="header"] +|======================================== +|Operator|Available When|Identity +|`sycl::plus`|`std::is_same_v, std::complex> \|\| +std::is_same_v, std::complex>`|`AccumulatorT{}` +|======================================== == Issues