File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -372,12 +372,34 @@ template <typename Type, int NumElements> class vec {
372
372
return *this ;
373
373
}
374
374
375
+ #ifdef __SYCL_USE_EXT_VECTOR_TYPE__
376
+ explicit vec (const DataT &arg) {
377
+ m_Data = (DataType)arg;
378
+ }
379
+
380
+ template <typename Ty = DataT>
381
+ typename std::enable_if<std::is_fundamental<Ty>::value, vec &>::type
382
+ operator =(const DataT &Rhs) {
383
+ m_Data = (DataType)Rhs;
384
+ return *this ;
385
+ }
386
+ #else
375
387
explicit vec (const DataT &arg) {
376
388
for (int i = 0 ; i < NumElements; ++i) {
377
389
setValue (i, arg);
378
390
}
379
391
}
380
392
393
+ template <typename Ty = DataT>
394
+ typename std::enable_if<std::is_fundamental<Ty>::value, vec &>::type
395
+ operator =(const DataT &Rhs) {
396
+ for (int i = 0 ; i < NumElements; ++i) {
397
+ setValue (i, Rhs);
398
+ }
399
+ return *this ;
400
+ }
401
+ #endif
402
+
381
403
#ifdef __SYCL_USE_EXT_VECTOR_TYPE__
382
404
// Optimized naive constructors with NumElements of DataT values.
383
405
// We don't expect compilers to optimize vararg recursive functions well.
Original file line number Diff line number Diff line change @@ -50,5 +50,13 @@ int main() {
50
50
int64_t (vec_2.x ());
51
51
cl::sycl::int4 (vec_2.x ());
52
52
53
+ // Check broadcasting operator=
54
+ cl::sycl::vec<float , 4 > b_vec (1.0 );
55
+ b_vec = 0.5 ;
56
+ assert (static_cast <float >(b_vec.x ()) == static_cast <float >(0.5 ));
57
+ assert (static_cast <float >(b_vec.y ()) == static_cast <float >(0.5 ));
58
+ assert (static_cast <float >(b_vec.z ()) == static_cast <float >(0.5 ));
59
+ assert (static_cast <float >(b_vec.w ()) == static_cast <float >(0.5 ));
60
+
53
61
return 0 ;
54
62
}
You can’t perform that action at this time.
0 commit comments