21 #ifndef EIGEN_INTEROP_HEADERS_SYCL_H
22 #define EIGEN_INTEROP_HEADERS_SYCL_H
24 #include "../../InternalHeaderCheck.h"
28 #if !defined(EIGEN_DONT_VECTORIZE_SYCL)
32 template <
int has_blend,
int lengths>
33 struct sycl_packet_traits : default_packet_traits {
79 #ifdef SYCL_DEVICE_ONLY
80 #define SYCL_PACKET_TRAITS(packet_type, has_blend, unpacket_type, lengths) \
82 struct packet_traits<unpacket_type> \
83 : sycl_packet_traits<has_blend, lengths> { \
84 typedef packet_type type; \
85 typedef packet_type half; \
88 SYCL_PACKET_TRAITS(cl::sycl::cl_float4, 1,
float, 4)
89 SYCL_PACKET_TRAITS(cl::sycl::cl_float4, 1, const
float, 4)
90 SYCL_PACKET_TRAITS(cl::sycl::cl_double2, 0,
double, 2)
91 SYCL_PACKET_TRAITS(cl::sycl::cl_double2, 0, const
double, 2)
92 #undef SYCL_PACKET_TRAITS
97 #define SYCL_ARITHMETIC(packet_type) \
99 struct is_arithmetic<packet_type> { \
100 enum { value = true }; \
102 SYCL_ARITHMETIC(cl::sycl::cl_float4)
103 SYCL_ARITHMETIC(cl::sycl::cl_double2)
104 #undef SYCL_ARITHMETIC
106 #define SYCL_UNPACKET_TRAITS(packet_type, unpacket_type, lengths) \
108 struct unpacket_traits<packet_type> { \
109 typedef unpacket_type type; \
110 enum { size = lengths, vectorizable = true, alignment = Aligned16 }; \
111 typedef packet_type half; \
113 SYCL_UNPACKET_TRAITS(cl::sycl::cl_float4,
float, 4)
114 SYCL_UNPACKET_TRAITS(cl::sycl::cl_double2,
double, 2)
116 #undef SYCL_UNPACKET_TRAITS
123 namespace TensorSycl {
126 template <
typename PacketReturnType,
int PacketSize>
127 struct PacketWrapper;
129 #ifndef SYCL_DEVICE_ONLY
130 template <
typename PacketReturnType,
int PacketSize>
131 struct PacketWrapper {
132 typedef typename ::Eigen::internal::unpacket_traits<PacketReturnType>::type
134 template <
typename Index>
136 eigen_assert(
false &&
"THERE IS NO PACKETIZE VERSION FOR THE CHOSEN TYPE");
141 return ::Eigen::internal::template plset<PacketReturnType>(in);
144 eigen_assert(
false &&
"THERE IS NO PACKETIZE VERSION FOR THE CHOSEN TYPE");
149 #elif defined(SYCL_DEVICE_ONLY)
150 template <
typename PacketReturnType>
151 struct PacketWrapper<PacketReturnType, 4> {
152 typedef typename ::Eigen::internal::unpacket_traits<PacketReturnType>::type
154 template <
typename Index>
168 __builtin_unreachable();
170 __builtin_unreachable();
173 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static PacketReturnType convert_to_packet_type(
174 Scalar in, Scalar other) {
175 return PacketReturnType(in, other, other, other);
177 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static void set_packet(PacketReturnType &lhs, Scalar *rhs) {
178 lhs = PacketReturnType(rhs[0], rhs[1], rhs[2], rhs[3]);
182 template <
typename PacketReturnType>
183 struct PacketWrapper<PacketReturnType, 1> {
184 typedef typename ::Eigen::internal::unpacket_traits<PacketReturnType>::type
186 template <
typename Index>
190 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static PacketReturnType convert_to_packet_type(Scalar in,
192 return PacketReturnType(in);
194 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static void set_packet(PacketReturnType &lhs, Scalar *rhs) {
199 template <
typename PacketReturnType>
200 struct PacketWrapper<PacketReturnType, 2> {
201 typedef typename ::Eigen::internal::unpacket_traits<PacketReturnType>::type
203 template <
typename Index>
213 __builtin_unreachable();
215 __builtin_unreachable();
218 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static PacketReturnType convert_to_packet_type(
219 Scalar in, Scalar other) {
220 return PacketReturnType(in, other);
222 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static void set_packet(PacketReturnType &lhs, Scalar *rhs) {
223 lhs = PacketReturnType(rhs[0], rhs[1]);
#define EIGEN_DEVICE_FUNC
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.