23#ifndef EIGEN_INTEROP_HEADERS_SYCL_H
24#define EIGEN_INTEROP_HEADERS_SYCL_H
27#include "../../InternalHeaderCheck.h"
31#if !defined(EIGEN_DONT_VECTORIZE_SYCL)
36struct sycl_packet_traits : default_packet_traits {
81#ifdef SYCL_DEVICE_ONLY
82#define SYCL_PACKET_TRAITS(packet_type, unpacket_type, lengths) \
84 struct packet_traits<unpacket_type> : sycl_packet_traits<lengths> { \
85 typedef packet_type type; \
86 typedef packet_type half; \
89SYCL_PACKET_TRAITS(cl::sycl::cl_half8, Eigen::half, 8)
90SYCL_PACKET_TRAITS(cl::sycl::cl_half8, const Eigen::half, 8)
91SYCL_PACKET_TRAITS(cl::sycl::cl_float4,
float, 4)
92SYCL_PACKET_TRAITS(cl::sycl::cl_float4, const
float, 4)
93SYCL_PACKET_TRAITS(cl::sycl::cl_double2,
double, 2)
94SYCL_PACKET_TRAITS(cl::sycl::cl_double2, const
double, 2)
95#undef SYCL_PACKET_TRAITS
100#define SYCL_ARITHMETIC(packet_type) \
102 struct is_arithmetic<packet_type> : std::true_type {};
103SYCL_ARITHMETIC(cl::sycl::cl_half8)
104SYCL_ARITHMETIC(cl::sycl::cl_float4)
105SYCL_ARITHMETIC(cl::sycl::cl_double2)
106#undef SYCL_ARITHMETIC
108#define SYCL_UNPACKET_TRAITS(packet_type, unpacket_type, lengths) \
110 struct unpacket_traits<packet_type> { \
111 typedef unpacket_type type; \
112 enum { size = lengths, vectorizable = true, alignment = Aligned16 }; \
113 typedef packet_type half; \
115SYCL_UNPACKET_TRAITS(cl::sycl::cl_half8, Eigen::half, 8)
116SYCL_UNPACKET_TRAITS(cl::sycl::cl_float4,
float, 4)
117SYCL_UNPACKET_TRAITS(cl::sycl::cl_double2,
double, 2)
119#undef SYCL_UNPACKET_TRAITS
126namespace TensorSycl {
129template <
typename PacketReturnType,
int PacketSize>
132#ifndef SYCL_DEVICE_ONLY
133template <
typename PacketReturnType,
int PacketSize>
134struct PacketWrapper {
135 typedef typename ::Eigen::internal::unpacket_traits<PacketReturnType>::type Scalar;
136 template <
typename Index>
137 EIGEN_DEVICE_FUNC
static Scalar scalarize(Index,
const PacketReturnType&) {
138 eigen_assert(
false &&
"THERE IS NO PACKETIZE VERSION FOR THE CHOSEN TYPE");
141 EIGEN_DEVICE_FUNC
static PacketReturnType convert_to_packet_type(Scalar in, Scalar) {
142 return ::Eigen::internal::template plset<PacketReturnType>(in);
144 EIGEN_DEVICE_FUNC
static void set_packet(PacketReturnType&, Scalar*) {
145 eigen_assert(
false &&
"THERE IS NO PACKETIZE VERSION FOR THE CHOSEN TYPE");
150#elif defined(SYCL_DEVICE_ONLY)
151template <
typename PacketReturnType>
152struct PacketWrapper<PacketReturnType, 4> {
153 typedef typename ::Eigen::internal::unpacket_traits<PacketReturnType>::type Scalar;
154 template <
typename Index>
155 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static Scalar scalarize(Index index,
const PacketReturnType& in) {
168 __builtin_unreachable();
170 __builtin_unreachable();
173 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static PacketReturnType convert_to_packet_type(Scalar in, Scalar other) {
174 return PacketReturnType(in, other, other, other);
176 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static void set_packet(PacketReturnType& lhs, Scalar* rhs) {
177 lhs = PacketReturnType(rhs[0], rhs[1], rhs[2], rhs[3]);
181template <
typename PacketReturnType>
182struct PacketWrapper<PacketReturnType, 1> {
183 typedef typename ::Eigen::internal::unpacket_traits<PacketReturnType>::type Scalar;
184 template <
typename Index>
185 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static Scalar scalarize(Index,
const PacketReturnType& in) {
188 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static PacketReturnType convert_to_packet_type(Scalar in, Scalar) {
189 return PacketReturnType(in);
191 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static void set_packet(PacketReturnType& lhs, Scalar* rhs) { lhs = rhs[0]; }
194template <
typename PacketReturnType>
195struct PacketWrapper<PacketReturnType, 2> {
196 typedef typename ::Eigen::internal::unpacket_traits<PacketReturnType>::type Scalar;
197 template <
typename Index>
198 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static Scalar scalarize(Index index,
const PacketReturnType& in) {
207 __builtin_unreachable();
209 __builtin_unreachable();
212 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static PacketReturnType convert_to_packet_type(Scalar in, Scalar other) {
213 return PacketReturnType(in, other);
215 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static void set_packet(PacketReturnType& lhs, Scalar* rhs) {
216 lhs = PacketReturnType(rhs[0], rhs[1]);