Skip to content

Commit 13b81d1

Browse files
committed
[SYCL] Fix operator~ for sycl::vec<bool, N>
Signed-off-by: Michael Aziz <michael.aziz@intel.com>
1 parent 6029e49 commit 13b81d1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

sycl/include/sycl/types.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,11 @@ template <typename Type, int NumElements> class vec {
12281228
// Use __SYCL_DEVICE_ONLY__ macro because cast to OpenCL vector type is defined
12291229
// by SYCL device compiler only.
12301230
#ifdef __SYCL_DEVICE_ONLY__
1231-
return vec{(typename vec::DataType) ~m_Data};
1231+
vec Ret{(typename vec::DataType) ~m_Data};
1232+
if constexpr (std::is_same<Type, bool>::value) {
1233+
Ret.ConvertToDataT();
1234+
}
1235+
return Ret;
12321236
#else
12331237
vec Ret;
12341238
for (size_t I = 0; I < NumElements; ++I) {

sycl/test-e2e/Basic/vec_bool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int main() {
4646

4747
// Test negate (operator ~)
4848
{
49-
init_arr(expected, false);
49+
init_arr(expected, true);
5050

5151
sycl::buffer<sycl::vec<bool, size>> bufVecTrue(&vec_true, 1);
5252
sycl::buffer<sycl::vec<bool, size>> bufResVec(&resVec, 1);

0 commit comments

Comments
 (0)