15 #define EIGEN_TEST_NO_LONGDOUBLE 16 #define EIGEN_TEST_NO_COMPLEX 18 #define EIGEN_DEFAULT_DENSE_INDEX_TYPE int64_t 19 #define EIGEN_USE_SYCL 23 #include <Eigen/CXX11/Tensor> 27 template <
typename DataType,
typename IndexType>
30 IndexType sizeDim1 = 2;
31 IndexType sizeDim2 = 3;
32 IndexType sizeDim3 = 7;
41 DataType* gpu_data1 =
static_cast<DataType*
>(sycl_device.allocate(tensor1.
size()*
sizeof(DataType)));
42 DataType* gpu_data2 =
static_cast<DataType*
>(sycl_device.allocate(tensor2.
size()*
sizeof(DataType)));
46 sycl_device.memcpyHostToDevice(gpu_data1, tensor1.
data(),(tensor1.
size())*
sizeof(DataType));
48 sycl_device.memcpyDeviceToHost(tensor2.
data(), gpu_data2,(tensor2.
size())*
sizeof(DataType));
59 for (IndexType
i = 0;
i < 2; ++
i) {
60 for (IndexType
j = 0;
j < 3; ++
j) {
61 for (IndexType k = 0; k < 7; ++k) {
66 sycl_device.deallocate(gpu_data1);
67 sycl_device.deallocate(gpu_data2);
70 template <
typename DataType,
typename IndexType>
74 IndexType sizeDim1 = 2;
75 IndexType sizeDim2 = 3;
76 IndexType sizeDim3 = 7;
84 DataType* gpu_data1 =
static_cast<DataType*
>(sycl_device.allocate(tensor1.
size()*
sizeof(DataType)));
85 DataType* gpu_data2 =
static_cast<DataType*
>(sycl_device.allocate(tensor2.
size()*
sizeof(DataType)));
89 sycl_device.memcpyHostToDevice(gpu_data1, tensor1.
data(),(tensor1.
size())*
sizeof(DataType));
91 sycl_device.memcpyDeviceToHost(tensor2.
data(), gpu_data2,(tensor2.
size())*
sizeof(DataType));
103 for (IndexType
i = 0;
i < 2; ++
i) {
104 for (IndexType
j = 0;
j < 3; ++
j) {
105 for (IndexType k = 0; k < 7; ++k) {
110 sycl_device.deallocate(gpu_data1);
111 sycl_device.deallocate(gpu_data2);
116 QueueInterface queueInterface(s);
117 auto sycl_device = Eigen::SyclDevice(&queueInterface);
118 test_simple_swap_sycl<DataType, int64_t>(sycl_device);
119 test_swap_as_lvalue_sycl<DataType, int64_t>(sycl_device);
123 for (
const auto& device :Eigen::get_sycl_supported_devices()) {
124 CALL_SUBTEST(sycl_tensor_layout_swap_test_per_device<float>(device));
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor< Scalar_, NumIndices_, Options_, IndexType_ > & setRandom()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorLayoutSwapOp< const TensorMap< PlainObjectType, Options_, MakePointer_ > > swap_layout() const
static void test_swap_as_lvalue_sycl(const Eigen::SyclDevice &sycl_device)
#define VERIFY_IS_EQUAL(a, b)
A tensor expression mapping an existing array of data.
TensorDevice< TensorMap< PlainObjectType, Options_, MakePointer_ >, DeviceType > device(const DeviceType &dev)
void sycl_tensor_layout_swap_test_per_device(dev_Selector s)
EIGEN_DECLARE_TEST(cxx11_tensor_layout_swap_sycl)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar * data()
#define CALL_SUBTEST(FUNC)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(std::size_t n) const
static void test_simple_swap_sycl(const Eigen::SyclDevice &sycl_device)