Skip to content

Commit 07c5b48

Browse files
authored
[SYCL][Doc] Add sycl complex to complex algorithms extension (#6717)
This PR extends the complex algorithms extension to support `sycl::ext::oneapi::complex` and `marray<sycl::ext::oneapi::complex>`. Additionally it adds the `multiplies` operator as a valid binary operation for complex values when reducing and scanning across work items. This PR has a dependency upon #6550.
1 parent 2542e6a commit 07c5b48

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

sycl/doc/extensions/proposed/sycl_ext_oneapi_complex_algorithms.asciidoc

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ IMPORTANT: This specification is a draft.
2121

2222
NOTE: Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by permission by Khronos.
2323

24-
This extension adds limited support for `std::complex<float>` and
25-
`std::complex<double>` to several SYCL group functions and algorithms.
24+
This extension adds SYCL group functions and algorithms to complex types in device code.
25+
This includes `std::complex<float>`, `std::complex<double>`,
26+
`sycl::complex<sycl::half>`, `sycl::complex<float>`, `sycl::complex<double>`
27+
and their `marray` equivalents.
2628

2729
== Notice
2830

@@ -50,6 +52,15 @@ John Pennycook, Intel (john 'dot' pennycook 'at' intel 'dot' com)
5052

5153
This extension is written against the SYCL 2020 specification, Revision 4.
5254

55+
This extension builds on the `sycl::ext::oneapi::complex` and
56+
`marray<sycl::ext::oneapi::complex>` classes. Therefore this extension is
57+
dependent on link:sycl_ext_oneapi_complex.asciidoc[sycl_ext_oneapi_complex]
58+
and
59+
link:sycl_ext_oneapi_complex_marray.asciidoc[sycl_ext_oneapi_complex_marray].
60+
Function overloads which use `std::complex` are not dependent upon the
61+
above extensions.
62+
63+
5364
== Feature Test Macro
5465

5566
This extension provides a feature-test macro as described in the core SYCL
@@ -64,33 +75,43 @@ value to determine which of the extension's APIs the implementation supports.
6475
|===
6576
|Value |Description
6677
|1 |Initial extension version. Base features are supported.
78+
|2 |Proposal is extended to other complex extensions. Multiplication binary operation is added.
6779
|===
6880

6981
== Overview
7082

83+
To reduce repetition, within this extension, `gencomplex` will be redefined to
84+
include `std::complex` floating point types. Therefore, `gencomplex` is defined
85+
as types `std::complex<float>`, `std::complex<double>`,
86+
`sycl::complex<sycl::half>`, `sycl::complex<float>`, and
87+
`sycl::complex<double>`. The extension will also refer to `mgencomplex` which
88+
are types `sycl::marray<sycl::complex<sycl::half>>`,
89+
`sycl::marray<sycl::complex<float>>`, and `sycl::marray<sycl::complex<double>>`.
90+
7191
The types supported by some group functions and algorithms in SYCL 2020 are
7292
restricted to built-in scalar types and SYCL vector types. This extension
73-
relaxes these restrictions to permit `std::complex<float>` and
74-
`std::complex<double>` types.
93+
relaxes these restrictions to permit `gencomplex` and `mgencomplex` types.
7594

7695
Note that the following group functions and algorithms already accept
77-
`std::complex<float>` arguments and `std::complex<double>` because they
78-
are trivially copyable:
96+
`gencomplex` arguments and `mgencomplex` because they are trivially copyable:
7997

8098
- `group_broadcast`
8199
- `group_shift_left`
82100
- `group_shift_right`
83101
- `permute_group_by_xor`
84102
- `select_from_group`
85103

86-
Usage of `std::complex<double>` requires support for double precision,
87-
and specifically the `sycl::aspect::fp64` device aspect.
104+
Each function is only supported if the underlying value type is also supported.
105+
For example, `group_broadcast` only supports
106+
`sycl::ext::oneapi::complex<sycl::half>` and
107+
`marray<sycl::ext::oneapi::complex<sycl::half>>` if the device supports
108+
`sycl::aspect::fp16`.
88109

89110
== Extended Functions and Algorithms
90111

91-
The following group functions and algorithms accept `std::complex<float>`
92-
and `std::complex<double>` arguments only when used with a `BinaryOperation`
93-
argument of `sycl::plus`:
112+
The following group functions and algorithms accept `gencomplex` arguments
113+
only when used with a `BinaryOperation` argument of `sycl::plus` and
114+
`sycl::multiplies`. These operations do not support `mgencomplex`:
94115

95116
- `joint_reduce`
96117
- `reduce_over_group`
@@ -99,10 +120,6 @@ argument of `sycl::plus`:
99120
- `joint_inclusive_scan`
100121
- `inclusive_scan_over_group`
101122

102-
NOTE: `sycl::multiplies` is not currently supported because it cannot be
103-
implemented as an element-wise operation on the real and imaginary components.
104-
This restriction may be lifted in a future version of the extension.
105-
106123
NOTE: `sycl::bit_and`, `sycl::bit_or`, `sycl::bit_xor`, `sycl::logical_and`,
107124
`sycl::logical_or`, `sycl::minimum` and `sycl::maximum` are not supported
108125
because their behaviors are defined in terms of operators that `std::complex`
@@ -126,4 +143,5 @@ None.
126143
|========================================
127144
|Rev|Date|Author|Changes
128145
|1|2021-12-08|John Pennycook|*Initial public working draft*
146+
|2|2022-31-08|Aidan Belton|*Extend to support sycl complex extension and multiplication binary operation*
129147
|========================================

0 commit comments

Comments
 (0)