File tree Expand file tree Collapse file tree 2 files changed +33
-5
lines changed Expand file tree Collapse file tree 2 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -1075,11 +1075,24 @@ template <typename Type, int NumElements> class vec {
1075
1075
#ifdef __SYCL_DEVICE_ONLY__
1076
1076
#define __SYCL_RELLOGOP (RELLOGOP ) \
1077
1077
vec<rel_t , NumElements> operator RELLOGOP (const vec & Rhs) const { \
1078
- auto Ret = \
1079
- vec<rel_t , NumElements>((typename vec<rel_t , NumElements>::vector_t )( \
1080
- m_Data RELLOGOP Rhs.m_Data )); \
1081
- if (NumElements == 1 ) /* Scalar 0/1 logic was applied, invert*/ \
1082
- Ret *= -1 ; \
1078
+ vec<rel_t , NumElements> Ret{}; \
1079
+ /* This special case is needed since there are no standard operator|| */ \
1080
+ /* or operator&& functions for std::array. */ \
1081
+ if constexpr (IsUsingArrayOnDevice && \
1082
+ (std::string_view (#RELLOGOP) == " ||" || \
1083
+ std::string_view (#RELLOGOP) == " &&" )) { \
1084
+ for (size_t I = 0 ; I < NumElements; ++I) { \
1085
+ Ret.setValue (I, \
1086
+ -(vec_data<DataT>::get (getValue (I)) \
1087
+ RELLOGOP vec_data<DataT>::get (Rhs.getValue (I)))); \
1088
+ } \
1089
+ } else { \
1090
+ Ret = vec<rel_t , NumElements>( \
1091
+ (typename vec<rel_t , NumElements>::vector_t )( \
1092
+ m_Data RELLOGOP Rhs.m_Data )); \
1093
+ if (NumElements == 1 ) /* Scalar 0/1 logic was applied, invert*/ \
1094
+ Ret *= -1 ; \
1095
+ } \
1083
1096
return Ret; \
1084
1097
} \
1085
1098
template <typename T> \
Original file line number Diff line number Diff line change
1
+ // RUN: %{build} -o %t.out
2
+ // RUN: %{run} %t.out
3
+ // RUN: %if preview-breaking-changes-supported %{ %clangxx -fsycl -fpreview-breaking-changes && ./%t.out %}
4
+
5
+ #include < sycl/sycl.hpp>
6
+
7
+ int main () {
8
+ sycl::queue q;
9
+ q.single_task ([=]() {
10
+ auto testVec1 = sycl::vec<double , 16 >(static_cast <double >(1 ));
11
+ auto testVec2 = sycl::vec<double , 16 >(static_cast <double >(2 ));
12
+ sycl::vec<std::int64_t , 16 > resVec1 = testVec1 || testVec2;
13
+ sycl::vec<std::int64_t , 16 > resVec2 = testVec1 && testVec2;
14
+ });
15
+ }
You can’t perform that action at this time.
0 commit comments