14 #define EIGEN_TEST_NO_LONGDOUBLE
15 #define EIGEN_TEST_NO_COMPLEX
17 #define EIGEN_DEFAULT_DENSE_INDEX_TYPE int64_t
18 #define EIGEN_USE_SYCL
25 #include <unsupported/Eigen/CXX11/Tensor>
28 using Eigen::SyclDevice;
33 template <
typename DataType,
int DataLayout,
typename IndexType>
49 DataType * d_tensor =
static_cast<DataType*
>(sycl_device.allocate(tensor_bytes));
50 DataType * d_no_stride =
static_cast<DataType*
>(sycl_device.allocate(no_stride_bytes));
51 DataType * d_stride =
static_cast<DataType*
>(sycl_device.allocate(stride_bytes));
64 sycl_device.memcpyHostToDevice(d_tensor, tensor.
data(), tensor_bytes);
65 gpu_no_stride.device(sycl_device)=gpu_tensor.stride(
strides);
66 sycl_device.memcpyDeviceToHost(no_stride.
data(), d_no_stride, no_stride_bytes);
75 for (IndexType
i = 0;
i < 2; ++
i) {
76 for (IndexType
j = 0;
j < 3; ++
j) {
77 for (IndexType k = 0; k < 5; ++k) {
78 for (IndexType
l = 0;
l < 7; ++
l) {
92 gpu_stride.device(sycl_device)=gpu_tensor.stride(
strides);
93 sycl_device.memcpyDeviceToHost(stride.
data(), d_stride, stride_bytes);
100 for (IndexType
i = 0;
i < 1; ++
i) {
101 for (IndexType
j = 0;
j < 1; ++
j) {
102 for (IndexType k = 0; k < 3; ++k) {
103 for (IndexType
l = 0;
l < 3; ++
l) {
110 sycl_device.deallocate(d_tensor);
111 sycl_device.deallocate(d_no_stride);
112 sycl_device.deallocate(d_stride);
115 template <
typename DataType,
int DataLayout,
typename IndexType>
132 DataType * d_tensor =
static_cast<DataType*
>(sycl_device.allocate(tensor_bytes));
133 DataType * d_no_stride =
static_cast<DataType*
>(sycl_device.allocate(no_stride_bytes));
134 DataType * d_stride =
static_cast<DataType*
>(sycl_device.allocate(stride_bytes));
150 sycl_device.memcpyHostToDevice(d_tensor, tensor.
data(), tensor_bytes);
151 gpu_stride.stride(
strides).device(sycl_device)=gpu_tensor;
152 sycl_device.memcpyDeviceToHost(stride.
data(), d_stride, stride_bytes);
154 for (IndexType
i = 0;
i < 2; ++
i) {
155 for (IndexType
j = 0;
j < 3; ++
j) {
156 for (IndexType k = 0; k < 5; ++k) {
157 for (IndexType
l = 0;
l < 7; ++
l) {
172 gpu_no_stride.stride(
strides).device(sycl_device)=gpu_tensor.stride(no_strides);
173 sycl_device.memcpyDeviceToHost(no_stride.
data(), d_no_stride, no_stride_bytes);
175 for (IndexType
i = 0;
i < 2; ++
i) {
176 for (IndexType
j = 0;
j < 3; ++
j) {
177 for (IndexType k = 0; k < 5; ++k) {
178 for (IndexType
l = 0;
l < 7; ++
l) {
184 sycl_device.deallocate(d_tensor);
185 sycl_device.deallocate(d_no_stride);
186 sycl_device.deallocate(d_stride);
191 QueueInterface queueInterface(
s);
192 auto sycl_device=Eigen::SyclDevice(&queueInterface);
193 test_simple_striding<float, ColMajor, int64_t>(sycl_device);
194 test_simple_striding<float, RowMajor, int64_t>(sycl_device);
195 test_striding_as_lvalue<float, ColMajor, int64_t>(sycl_device);
196 test_striding_as_lvalue<float, RowMajor, int64_t>(sycl_device);
200 for (
const auto& device :Eigen::get_sycl_supported_devices()) {