Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add marray<bool> support to "any" / "all"
The "any" and "all" functions are not sensibly defined for SYCL when the input type is scalar or `marray`. I think this happened because we copied the OpenCL semantics without thinking through the use cases. The current definition looks at the most significant bit of each input element to determine if the result is true or false. This makes sense for OpenCL, where true values are represented as -1 (all 1 bits) and false values are represented by 0. It also makes sense in SYCL for the `vec` type because the relational functions set `vec` elements to -1 / 0. However, it does not make sense when the parameter is `marray` or a scalar. Consider a typical use of `any` like this: ``` marray<float, N> m1 = /*...*/; marray<float, N> m2 = /*...*/; marray<bool, N> comparisons = isequal(v1, v2); if (any(comparisons)) {/*...*/} ``` Here, the `comparisons` variable is passed to `any`, where it does not make sense to test the most significant bit of each `bool` element. This commit adds a new overload to `any` / `all` for `marray<bool>` with sensible C++ semantics. It also deprecates the existing overloads for `marray` of non-bool types. The scalar overloads of `any` / `all` are also deprecated. The existing semantics (where the MSB is tested) do not make sense for SYCL. In addition, these versions of `any` and `all` have already been deprecated in OpenCL. Closes internal issue 658.
- Loading branch information