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][DOC] Update marray specification #12786

Open
wants to merge 6 commits into
base: sycl
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 129 additions & 47 deletions sycl/doc/extensions/experimental/sycl_ext_oneapi_complex.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public:

/// Compares complex numbers z and w and returns true if they are different, otherwise false.
friend constexpr bool operator!=(const complex<value_type> &z, const complex<value_type> &w);
///Compares complex number z and real y and returns true if they are different, otherwise false.
/// Compares complex number z and real y and returns true if they are different, otherwise false.
friend constexpr bool operator!=(const complex<value_type> &z, value_type y);
/// Compares real x and complex number w and returns true if they are different, otherwise false.
friend constexpr bool operator!=(value_type x, const complex<value_type> &w);
Expand All @@ -228,15 +228,16 @@ public:
This proposal also introduces the specialization of the `sycl::marray` class to
support SYCL `complex`. The `marray` class undergoes slight modification for
this specialization, primarily involving the removal of operators that are
inapplicable. No new functions or operators are introduced to the `marray`
class.
inapplicable and implementing the operators that are *only* supported by
`complex<T>`.
No new functions or operators are introduced to the `marray` class.

The `complex`'s `marray` specialization maintains the principles of trivial
copyability (as seen in the <<Complex Class, `complex` class description>>),
with the `is_device_copyable` type trait resolving to `std::true_type`.

The `marray` specialization for `complex<T>` deletes any operator that is not
supported by `complex<T>`.
supported by `complex<T>` and implements the ones supported.

```C++
namespace sycl {
Expand All @@ -248,74 +249,155 @@ public:

/* ... */

friend marray operator %(const marray &lhs, const marray &rhs) = delete;
friend marray operator %(const marray &lhs, const value_type &rhs) = delete;
friend marray operator %(const value_type &lhs, const marray &rhs) = delete;
/// Adds marray rhs to marray lhs and assigns the result to lhs.
friend marray &operator +=(marray &lhs, const marray &rhs);
/// Adds complex number rhs to marray lhs and assigns the result to lhs.
friend marray &operator +=(marray &lhs, const value_type &rhs);

/// Subtracts marray rhs from marray lhs and assigns the result to lhs.
friend marray &operator -=(marray &lhs, const marray &rhs);
/// Subtracts complex number rhs from marray lhs and assigns the result to lhs.
friend marray &operator -=(marray &lhs, const value_type &rhs);

/// Multiplies marray rhs to marray lhs and assigns the result to lhs.
friend marray &operator *=(marray &lhs, const marray &rhs);
/// Multiplies complex number rhs to marray lhs and assigns the result to lhs.
friend marray &operator *=(marray &lhs, const value_type &rhs);

/// Divides marray lhs by marray rhs and assigns the result to lhs.
friend marray &operator /=(marray &lhs, const marray &rhs);
/// Divides marray lhs by complex number rhs and assigns the result to lhs.
friend marray &operator /=(marray &lhs, const value_type &rhs);

/// Adds marray rhs to marray lhs and returns the result.
friend marray operator +(const marray &lhs, const marray &rhs);
/// Adds complex number rhs to marray lhs and returns the result.
friend marray operator +(const marray &lhs, const value_type &rhs);
/// Adds marray rhs to complex number lhs and returns the result.
friend marray operator +(const value_type &lhs, const marray &rhs);
/// Returns a copy of marray lhs.
friend marray operator +(const marray &lhs);

/// Subtracts marray rhs from marray lhs and returns the result.
friend marray operator -(const marray &lhs, const marray &rhs);
/// Subtracts complex number rhs from marray lhs and returns the result.
friend marray operator -(const marray &lhs, const value_type &rhs);
/// Subtracts marray rhs from complex number lhs and returns the result.
friend marray operator -(const value_type &lhs, const marray &rhs);
/// Negates each element of marray lhs.
friend marray operator -(const marray &lhs);

/// Multiplies marray rhs to marray lhs and returns the result.
friend marray operator *(const marray &lhs, const marray &rhs);
/// Multiplies complex number rhs to marray lhs and returns the result.
friend marray operator *(const marray &lhs, const value_type &rhs);
/// Multiplies marray rhs to complex number lhs and returns the result.
friend marray operator *(const value_type &lhs, const marray &rhs);

/// Divides marray lhs by marray rhs and returns the result.
friend marray operator /(const marray &lhs, const marray &rhs);
/// Divides marray lhs by complex number rhs and returns the result.
friend marray operator /(const marray &lhs, const value_type &rhs);
/// Divides complex number lhs by marray rhs and returns the result.
friend marray operator /(const value_type &lhs, const marray &rhs);

/// Compares marray rhs to marray lhs and returns an marray of booleans where each element is true if the corresponding elements in lhs and rhs are the same, otherwise false.
friend marray<bool, NumElements> operator ==(const marray &lhs, const marray &rhs);
/// Compares complex number rhs to marray lhs and returns an marray of booleans where each element is true if the corresponding elements in lhs and rhs are the same, otherwise false.
friend marray<bool, NumElements> operator ==(const marray &lhs, const value_type &rhs);
/// Compares marray rhs to complex number lhs and returns an marray of booleans where each element is true if the corresponding elements in lhs and rhs are the same, otherwise false.
friend marray<bool, NumElements> operator ==(const value_type &lhs, const marray &rhs);

/// Compares marray rhs to marray lhs and returns an marray of booleans where each element is true if the corresponding elements in lhs and rhs differs, otherwise false.
friend marray<bool, NumElements> operator !=(const marray &lhs, const marray &rhs);
/// Compares complex number rhs to marray lhs and returns an marray of booleans where each element is true if the corresponding elements in lhs and rhs differs, otherwise false.
friend marray<bool, NumElements> operator !=(const marray &lhs, const value_type &rhs);
/// Compares marray rhs to complex number lhs and returns an marray of booleans where each element is true if the corresponding elements in lhs and rhs differs, otherwise false.
friend marray<bool, NumElements> operator !=(const value_type &lhs, const marray &rhs);

/* ... */

friend marray &operator %=(marray &lhs, const marray &rhs) = delete;
friend marray &operator %=(marray &lhs, const value_type &rhs) = delete;
friend marray &operator %=(value_type &lhs, const marray &rhs) = delete;

friend marray &operator &=(marray &lhs, const marray &rhs) = delete;
friend marray &operator &=(marray &lhs, const value_type &rhs) = delete;

friend marray &operator |=(marray &lhs, const marray &rhs) = delete;
friend marray &operator |=(marray &lhs, const value_type &rhs) = delete;

friend marray &operator ^=(marray &lhs, const marray &rhs) = delete;
friend marray &operator ^=(marray &lhs, const value_type &rhs) = delete;

friend marray &operator <<=(marray &lhs, const marray &rhs) = delete;
friend marray &operator <<=(marray &lhs, const value_type &rhs) = delete;

friend marray &operator >>=(marray &lhs, const marray &rhs) = delete;
friend marray &operator >>=(marray &lhs, const value_type &rhs) = delete;

friend marray &operator ++(marray &lhs) = delete;
friend marray operator ++(marray &lhs, int) = delete;
friend marray &operator ++(marray & rhs) = delete;

friend marray &operator --(marray &lhs) = delete;
friend marray operator --(marray &lhs, int) = delete;
friend marray &operator --(marray & rhs) = delete;

friend marray &operator +=(marray &lhs) = delete;
friend marray operator +=(marray &lhs, int) = delete;

friend marray &operator -=(marray &lhs) = delete;
friend marray operator -=(marray &lhs, int) = delete;

friend marray operator %(const marray &lhs, const marray &rhs) = delete;
friend marray operator %(const marray &lhs, const value_type &rhs) = delete;
friend marray operator %(const value_type &lhs, const marray &rhs) = delete;

friend marray operator ~(const marray &lhs) = delete;

friend marray operator &(const marray &lhs, const marray &rhs) = delete;
friend marray operator &(const marray &lhs, const value_type &rhs) = delete;
friend marray operator &(const value_type &lhs, const marray &rhs) = delete;

friend marray operator |(const marray &lhs, const marray &rhs) = delete;
friend marray operator |(const marray &lhs, const value_type &rhs) = delete;
friend marray operator |(const value_type &lhs, const marray &rhs) = delete;

friend marray operator ^(const marray &lhs, const marray &rhs) = delete;
friend marray operator ^(const marray &lhs, const value_type &rhs) = delete;
friend marray operator ^(const value_type &lhs, const marray &rhs) = delete;

friend marray &operator &=(marray & lhs, const marray & rhs) = delete;
friend marray &operator &=(marray & lhs, const value_type & rhs) = delete;
friend marray &operator &=(value_type & lhs, const marray & rhs) = delete;

friend marray &operator |=(marray & lhs, const marray & rhs) = delete;
friend marray &operator |=(marray & lhs, const value_type & rhs) = delete;
friend marray &operator |=(value_type & lhs, const marray & rhs) = delete;

friend marray &operator ^=(marray & lhs, const marray & rhs) = delete;
friend marray &operator ^=(marray & lhs, const value_type & rhs) = delete;
friend marray &operator ^=(value_type & lhs, const marray & rhs) = delete;

friend marray<bool, NumElements> operator <<(const marray & lhs, const marray & rhs) = delete;
friend marray<bool, NumElements> operator <<(const marray & lhs, const value_type & rhs) = delete;
friend marray<bool, NumElements> operator <<(const value_type & lhs, const marray & rhs) = delete;

friend marray<bool, NumElements> operator >>(const marray & lhs, const marray & rhs) = delete;
friend marray<bool, NumElements> operator >>(const marray & lhs, const value_type & rhs) = delete;
friend marray<bool, NumElements> operator >>(const value_type & lhs, const marray & rhs) = delete;
friend marray<bool, NumElements> operator <<(const marray &lhs, const marray &rhs) = delete;
friend marray<bool, NumElements> operator <<(const marray &lhs, const value_type &rhs) = delete;
friend marray<bool, NumElements> operator <<(const value_type &lhs, const marray &rhs) = delete;

friend marray &operator <<=(marray & lhs, const marray & rhs) = delete;
friend marray &operator <<=(marray & lhs, const value_type & rhs) = delete;
friend marray<bool, NumElements> operator >>(const marray &lhs, const marray &rhs) = delete;
friend marray<bool, NumElements> operator >>(const marray &lhs, const value_type &rhs) = delete;
friend marray<bool, NumElements> operator >>(const value_type &lhs, const marray &rhs) = delete;

friend marray &operator >>=(marray & lhs, const marray & rhs) = delete;
friend marray &operator >>=(marray & lhs, const value_type & rhs) = delete;
friend marray<bool, NumElements> operator !(const marray &lhs) = delete;

friend marray<bool, NumElements> operator <(const marray & lhs, const marray & rhs) = delete;
friend marray<bool, NumElements> operator <(const marray & lhs, const value_type & rhs) = delete;
friend marray<bool, NumElements> operator <(const value_type & lhs, const marray & rhs) = delete;
friend marray<bool, NumElements> operator &&(const marray &lhs, const marray &hhs) = delete;
friend marray<bool, NumElements> operator &&(const marray &lhs, const value_type &rhs) = delete;
friend marray<bool, NumElements> operator &&(const value_type &lhs, const marray &rhs) = delete;

friend marray<bool, NumElements> operator >(const marray & lhs, const marray & rhs) = delete;
friend marray<bool, NumElements> operator >(const marray & lhs, const value_type & rhs) = delete;
friend marray<bool, NumElements> operator >(const value_type & lhs, const marray & rhs) = delete;
friend marray<bool, NumElements> operator ||(const marray &lhs, const marray &rhs) = delete;
friend marray<bool, NumElements> operator ||(const marray &lhs, const value_type &rhs) = delete;
friend marray<bool, NumElements> operator ||(const value_type &lhs, const marray &rhs) = delete;

friend marray<bool, NumElements> operator <=(const marray & lhs, const marray & rhs) = delete;
friend marray<bool, NumElements> operator <=(const marray & lhs, const value_type & rhs) = delete;
friend marray<bool, NumElements> operator <=(const value_type & lhs, const marray & rhs) = delete;
friend marray<bool, NumElements> operator <(const marray &lhs, const marray &rhs) = delete;
friend marray<bool, NumElements> operator <(const marray &lhs, const value_type &rhs) = delete;
friend marray<bool, NumElements> operator <(const value_type &lhs, const marray &rhs) = delete;

friend marray<bool, NumElements> operator >=(const marray & lhs, const marray & rhs) = delete;
friend marray<bool, NumElements> operator >=(const marray & lhs, const value_type & rhs) = delete;
friend marray<bool, NumElements> operator >=(const value_type & lhs, const marray & rhs) = delete;
friend marray<bool, NumElements> operator >(const marray &lhs, const marray &rhs) = delete;
friend marray<bool, NumElements> operator >(const marray &lhs, const value_type &rhs) = delete;
friend marray<bool, NumElements> operator >(const value_type &lhs, const marray &rhs) = delete;

friend marray operator ~(const marray &v) = delete;
friend marray<bool, NumElements> operator <=(const marray &lhs, const marray &rhs) = delete;
friend marray<bool, NumElements> operator <=(const marray &lhs, const value_type &rhs) = delete;
friend marray<bool, NumElements> operator <=(const value_type &lhs, const marray &rhs) = delete;

friend marray<bool, NumElements> operator !(const marray &v) = delete;
friend marray<bool, NumElements> operator >=(const marray &lhs, const marray &rhs) = delete;
friend marray<bool, NumElements> operator >=(const marray &lhs, const value_type &rhs) = delete;
friend marray<bool, NumElements> operator >=(const value_type &lhs, const marray &rhs) = delete;
};

} // namespace sycl
Expand Down