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
22 #include <unsupported/Eigen/CXX11/Tensor>
29 return coordinates[0];
33 template <
typename DataType,
int DataLayout,
typename IndexType>
37 IndexType sizeDim1 = 6;
42 const size_t tensorBuffSize =vec.
size()*
sizeof(DataType);
43 DataType* gpu_data_vec =
static_cast<DataType*
>(sycl_device.allocate(tensorBuffSize));
44 DataType* gpu_data_result =
static_cast<DataType*
>(sycl_device.allocate(tensorBuffSize));
49 sycl_device.memcpyHostToDevice(gpu_data_vec, vec.
data(), tensorBuffSize);
50 gpu_result.device(sycl_device)=gpu_vec.generate(
Generator1D());
51 sycl_device.memcpyDeviceToHost(
result.data(), gpu_data_result, tensorBuffSize);
53 for (IndexType
i = 0;
i < 6; ++
i) {
63 return 3 * coordinates[0] + 11 * coordinates[1];
67 template <
typename DataType,
int DataLayout,
typename IndexType>
70 IndexType sizeDim1 = 5;
71 IndexType sizeDim2 = 7;
76 const size_t tensorBuffSize =
matrix.size()*
sizeof(DataType);
77 DataType* gpu_data_matrix =
static_cast<DataType*
>(sycl_device.allocate(tensorBuffSize));
78 DataType* gpu_data_result =
static_cast<DataType*
>(sycl_device.allocate(tensorBuffSize));
83 sycl_device.memcpyHostToDevice(gpu_data_matrix,
matrix.data(), tensorBuffSize);
84 gpu_result.device(sycl_device)=gpu_matrix.generate(
Generator2D());
85 sycl_device.memcpyDeviceToHost(
result.data(), gpu_data_result, tensorBuffSize);
87 for (IndexType
i = 0;
i < 5; ++
i) {
88 for (IndexType
j = 0;
j < 5; ++
j) {
94 template <
typename DataType,
int DataLayout,
typename IndexType>
105 internal::GaussianGenerator<DataType, Eigen::DenseIndex, 2> gaussian_gen(
means, std_devs);
111 const size_t tensorBuffSize =
matrix.size()*
sizeof(DataType);
112 DataType* gpu_data_matrix =
static_cast<DataType*
>(sycl_device.allocate(tensorBuffSize));
113 DataType* gpu_data_result =
static_cast<DataType*
>(sycl_device.allocate(tensorBuffSize));
118 sycl_device.memcpyHostToDevice(gpu_data_matrix,
matrix.data(), tensorBuffSize);
119 gpu_result.device(sycl_device)=gpu_matrix.generate(gaussian_gen);
120 sycl_device.memcpyDeviceToHost(
result.data(), gpu_data_result, tensorBuffSize);
122 for (IndexType
i = 0;
i <
rows; ++
i) {
123 for (IndexType
j = 0;
j <
cols; ++
j) {
124 DataType g_rows = powf(
rows/2.0
f -
i, 2) / (3.14f * 3.14f) * 0.5
f;
125 DataType g_cols = powf(
cols/2.0
f -
j, 2) / (2.7f * 2.7f) * 0.5
f;
126 DataType gaussian = expf(-g_rows - g_cols);
133 QueueInterface queueInterface(
s);
134 auto sycl_device = Eigen::SyclDevice(&queueInterface);
135 test_1D_sycl<DataType, RowMajor, int64_t>(sycl_device);
136 test_1D_sycl<DataType, ColMajor, int64_t>(sycl_device);
137 test_2D_sycl<DataType, RowMajor, int64_t>(sycl_device);
138 test_2D_sycl<DataType, ColMajor, int64_t>(sycl_device);
139 test_gaussian_sycl<DataType, RowMajor, int64_t>(sycl_device);
140 test_gaussian_sycl<DataType, ColMajor, int64_t>(sycl_device);
144 for (
const auto& device :Eigen::get_sycl_supported_devices()) {
145 CALL_SUBTEST(sycl_generator_test_per_device<float>(device));