cxx11_tensor_image_op_sycl.cpp File Reference
#include "main.h"
#include <unsupported/Eigen/CXX11/Tensor>

Macros

#define EIGEN_TEST_NO_LONGDOUBLE
 
#define EIGEN_TEST_NO_COMPLEX
 
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE   int64_t
 
#define EIGEN_USE_SYCL
 

Functions

template<typename DataType , int DataLayout, typename IndexType >
static void test_image_op_sycl (const Eigen::SyclDevice &sycl_device)
 
template<typename DataType , typename dev_Selector >
void sycl_computing_test_per_device (dev_Selector s)
 
 EIGEN_DECLARE_TEST (cxx11_tensor_image_op_sycl)
 

Macro Definition Documentation

◆ EIGEN_DEFAULT_DENSE_INDEX_TYPE

#define EIGEN_DEFAULT_DENSE_INDEX_TYPE   int64_t

◆ EIGEN_TEST_NO_COMPLEX

#define EIGEN_TEST_NO_COMPLEX

◆ EIGEN_TEST_NO_LONGDOUBLE

#define EIGEN_TEST_NO_LONGDOUBLE

◆ EIGEN_USE_SYCL

#define EIGEN_USE_SYCL

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( cxx11_tensor_image_op_sycl  )
92  {
93  for (const auto& device : Eigen::get_sycl_supported_devices()) {
94  CALL_SUBTEST(sycl_computing_test_per_device<half>(device));
95  CALL_SUBTEST(sycl_computing_test_per_device<float>(device));
96 #ifdef EIGEN_SYCL_DOUBLE_SUPPORT
97  CALL_SUBTEST(sycl_computing_test_per_device<double>(device));
98 #endif
99  }
100 }
#define CALL_SUBTEST(FUNC)
Definition: main.h:382

References CALL_SUBTEST.

◆ sycl_computing_test_per_device()

template<typename DataType , typename dev_Selector >
void sycl_computing_test_per_device ( dev_Selector  s)
86  {
87  QueueInterface queueInterface(s);
88  auto sycl_device = Eigen::SyclDevice(&queueInterface);
89  test_image_op_sycl<DataType, RowMajor, int64_t>(sycl_device);
90 }
RealScalar s
Definition: level1_cplx_impl.h:130

References s.

◆ test_image_op_sycl()

template<typename DataType , int DataLayout, typename IndexType >
static void test_image_op_sycl ( const Eigen::SyclDevice &  sycl_device)
static
31  {
32  IndexType sizeDim1 = 245;
33  IndexType sizeDim2 = 343;
34  IndexType sizeDim3 = 577;
35 
36  array<IndexType, 3> input_range = {{sizeDim1, sizeDim2, sizeDim3}};
37  array<IndexType, 3> slice_range = {{sizeDim1 - 1, sizeDim2, sizeDim3}};
38 
39  Tensor<DataType, 3, DataLayout, IndexType> tensor1(input_range);
40  Tensor<DataType, 3, DataLayout, IndexType> tensor2(input_range);
41  Tensor<DataType, 3, DataLayout, IndexType> tensor3(slice_range);
42  Tensor<DataType, 3, DataLayout, IndexType> tensor3_cpu(slice_range);
43 
44  typedef Eigen::DSizes<IndexType, 3> Index3;
45  Index3 strides1(1L, 1L, 1L);
46  Index3 indicesStart1(1L, 0L, 0L);
47  Index3 indicesStop1(sizeDim1, sizeDim2, sizeDim3);
48 
49  Index3 strides2(1L, 1L, 1L);
50  Index3 indicesStart2(0L, 0L, 0L);
51  Index3 indicesStop2(sizeDim1 - 1, sizeDim2, sizeDim3);
52  Eigen::DSizes<IndexType, 3> sizes(sizeDim1 - 1, sizeDim2, sizeDim3);
53 
54  tensor1.setRandom();
55  tensor2.setRandom();
56 
57  DataType* gpu_data1 = static_cast<DataType*>(sycl_device.allocate(tensor1.size() * sizeof(DataType)));
58  DataType* gpu_data2 = static_cast<DataType*>(sycl_device.allocate(tensor2.size() * sizeof(DataType)));
59  DataType* gpu_data3 = static_cast<DataType*>(sycl_device.allocate(tensor3.size() * sizeof(DataType)));
60 
61  TensorMap<Tensor<DataType, 3, DataLayout, IndexType>> gpu1(gpu_data1, input_range);
62  TensorMap<Tensor<DataType, 3, DataLayout, IndexType>> gpu2(gpu_data2, input_range);
63  TensorMap<Tensor<DataType, 3, DataLayout, IndexType>> gpu3(gpu_data3, slice_range);
64 
65  sycl_device.memcpyHostToDevice(gpu_data1, tensor1.data(), (tensor1.size()) * sizeof(DataType));
66  sycl_device.memcpyHostToDevice(gpu_data2, tensor2.data(), (tensor2.size()) * sizeof(DataType));
67  gpu3.device(sycl_device) = gpu1.slice(indicesStart1, sizes) - gpu2.slice(indicesStart2, sizes);
68  sycl_device.memcpyDeviceToHost(tensor3.data(), gpu_data3, (tensor3.size()) * sizeof(DataType));
69 
70  tensor3_cpu = tensor1.stridedSlice(indicesStart1, indicesStop1, strides1) -
71  tensor2.stridedSlice(indicesStart2, indicesStop2, strides2);
72 
73  for (IndexType i = 0; i < slice_range[0]; ++i) {
74  for (IndexType j = 0; j < slice_range[1]; ++j) {
75  for (IndexType k = 0; k < slice_range[2]; ++k) {
76  VERIFY_IS_EQUAL(tensor3_cpu(i, j, k), tensor3(i, j, k));
77  }
78  }
79  }
80  sycl_device.deallocate(gpu_data1);
81  sycl_device.deallocate(gpu_data2);
82  sycl_device.deallocate(gpu_data3);
83 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
MatrixXd L
Definition: LLT_example.cpp:6
A tensor expression mapping an existing array of data.
Definition: TensorMap.h:33
The tensor class.
Definition: Tensor.h:68
std::vector< Array2i > sizes
Definition: dense_solvers.cpp:12
char char char int int * k
Definition: level2_impl.h:374
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:367
std::array< T, N > array
Definition: EmulateArray.h:231
Definition: TensorDimensions.h:161
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::data(), Eigen::TensorBase< Derived, AccessLevel >::device(), i, j, k, L, Eigen::TensorBase< Derived, AccessLevel >::setRandom(), Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::size(), sizes, Eigen::TensorBase< Derived, AccessLevel >::slice(), Eigen::TensorBase< Derived, AccessLevel >::stridedSlice(), and VERIFY_IS_EQUAL.