@@ -497,14 +497,14 @@ template <typename Type, int NumElements> class vec {
497
497
}
498
498
499
499
#ifdef __SYCL_DEVICE_ONLY__
500
-
501
500
template <typename vector_t_ = vector_t ,
502
501
typename = typename std::enable_if<
503
502
std::is_same<vector_t_, vector_t >::value &&
504
503
!std::is_same<vector_t_, DataT>::value>::type>
505
504
vec (vector_t openclVector) : m_Data(openclVector) {}
506
505
operator vector_t () const { return m_Data; }
507
506
#endif
507
+
508
508
// Available only when: NumElements == 1
509
509
template <int N = NumElements>
510
510
operator typename std::enable_if<N == 1 , DataT>::type() const {
@@ -529,11 +529,18 @@ template <typename Type, int NumElements> class vec {
529
529
std::is_integral<DataT>::value,
530
530
vec<convertT, NumElements>>::type
531
531
convert () const {
532
+ // Use __SYCL_DEVICE_ONLY__ macro because cast to OpenCL vector type is defined
533
+ // by SYCL device compiler only.
534
+ #ifdef __SYCL_DEVICE_ONLY__
535
+ return vec<convertT, NumElements>{
536
+ (typename vec<convertT, NumElements>::DataType)m_Data};
537
+ #else
532
538
vec<convertT, NumElements> Result;
533
539
for (size_t I = 0 ; I < NumElements; ++I) {
534
540
Result.setValue (I, static_cast <convertT>(getValue (I)));
535
541
}
536
542
return Result;
543
+ #endif
537
544
}
538
545
// From FP to Integer
539
546
template <typename convertT, rounding_mode roundingMode>
@@ -542,12 +549,20 @@ template <typename Type, int NumElements> class vec {
542
549
std::is_floating_point<DataT>::value,
543
550
vec<convertT, NumElements>>::type
544
551
convert () const {
552
+ // Use __SYCL_DEVICE_ONLY__ macro because cast to OpenCL vector type is defined
553
+ // by SYCL device compiler only.
554
+ #ifdef __SYCL_DEVICE_ONLY__
555
+ return vec<convertT, NumElements>{
556
+ detail::convertHelper<vec<convertT, NumElements>::DataType,
557
+ roundingMode>(m_Data)};
558
+ #else
545
559
vec<convertT, NumElements> Result;
546
560
for (size_t I = 0 ; I < NumElements; ++I) {
547
561
Result.setValue (
548
562
I, detail::convertHelper<convertT, roundingMode>(getValue (I)));
549
563
}
550
564
return Result;
565
+ #endif
551
566
}
552
567
553
568
template <typename asT>
@@ -709,6 +724,20 @@ template <typename Type, int NumElements> class vec {
709
724
#ifdef __SYCL_RELLOGOP
710
725
#error "Undefine __SYCL_RELLOGOP macro"
711
726
#endif
727
+ #ifdef __SYCL_USE_EXT_VECTOR_TYPE__
728
+ #define __SYCL_RELLOGOP (RELLOGOP ) \
729
+ vec<rel_t , NumElements> operator RELLOGOP (const vec &Rhs) const { \
730
+ return vec<rel_t , NumElements>{m_Data RELLOGOP vector_t (Rhs)}; \
731
+ } \
732
+ template <typename T> \
733
+ typename std::enable_if<std::is_convertible<T, DataT>::value && \
734
+ (std::is_fundamental<T>::value || \
735
+ std::is_same<T, half>::value), \
736
+ vec<rel_t , NumElements>>::type \
737
+ operator RELLOGOP (const T &Rhs) const { \
738
+ return *this RELLOGOP vec (static_cast <const DataT &>(Rhs)); \
739
+ }
740
+ #else
712
741
#define __SYCL_RELLOGOP (RELLOGOP ) \
713
742
vec<rel_t , NumElements> operator RELLOGOP (const vec &Rhs) const { \
714
743
vec<rel_t , NumElements> Ret; \
@@ -718,14 +747,14 @@ template <typename Type, int NumElements> class vec {
718
747
return Ret; \
719
748
} \
720
749
template <typename T> \
721
- typename std::enable_if< \
722
- std::is_convertible<T, DataT>::value && \
723
- (std::is_fundamental<T>::value || \
724
- std::is_same<typename std::remove_const<T>::type, half>::value), \
725
- vec<rel_t , NumElements>>::type \
750
+ typename std::enable_if<std::is_convertible<T, DataT>::value && \
751
+ (std::is_fundamental<T>::value || \
752
+ std::is_same<T, half>::value), \
753
+ vec<rel_t , NumElements>>::type \
726
754
operator RELLOGOP (const T &Rhs) const { \
727
755
return *this RELLOGOP vec (static_cast <const DataT &>(Rhs)); \
728
756
}
757
+ #endif
729
758
730
759
__SYCL_RELLOGOP (==)
731
760
__SYCL_RELLOGOP(!=)
0 commit comments