14 #define EIGEN_TEST_NO_LONGDOUBLE 15 #define EIGEN_TEST_NO_COMPLEX 16 #define EIGEN_TEST_FUNC cxx11_tensor_forced_eval_sycl 17 #define EIGEN_DEFAULT_DENSE_INDEX_TYPE int 18 #define EIGEN_USE_SYCL 21 #include <unsupported/Eigen/CXX11/Tensor> 35 float * gpu_in1_data =
static_cast<float*
>(sycl_device.allocate(in1.
dimensions().TotalSize()*
sizeof(float)));
36 float * gpu_in2_data =
static_cast<float*
>(sycl_device.allocate(in2.
dimensions().TotalSize()*
sizeof(float)));
37 float * gpu_out_data =
static_cast<float*
>(sycl_device.allocate(out.
dimensions().TotalSize()*
sizeof(float)));
39 in1 = in1.random() + in1.constant(10.0
f);
40 in2 = in2.random() + in2.constant(10.0
f);
46 sycl_device.memcpyHostToDevice(gpu_in1_data, in1.
data(),(in1.
dimensions().TotalSize())*
sizeof(
float));
47 sycl_device.memcpyHostToDevice(gpu_in2_data, in2.
data(),(in1.
dimensions().TotalSize())*
sizeof(
float));
49 gpu_out.
device(sycl_device) =(gpu_in1 + gpu_in2).eval() * gpu_in2;
50 sycl_device.memcpyDeviceToHost(out.
data(), gpu_out_data,(out.
dimensions().TotalSize())*
sizeof(
float));
51 for (
int i = 0; i < sizeDim1; ++i) {
52 for (
int j = 0; j < sizeDim2; ++j) {
53 for (
int k = 0; k < sizeDim3; ++k) {
54 VERIFY_IS_APPROX(out(i, j, k),
55 (in1(i, j, k) + in2(i, j, k)) * in2(i, j, k));
59 printf(
"(a+b)*b Test Passed\n");
60 sycl_device.deallocate(gpu_in1_data);
61 sycl_device.deallocate(gpu_in2_data);
62 sycl_device.deallocate(gpu_out_data);
67 cl::sycl::gpu_selector
s;
68 Eigen::SyclDevice sycl_device(s);
void test_forced_eval_sycl(const Eigen::SyclDevice &sycl_device)
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
TensorDevice< TensorMap< PlainObjectType, Options_, MakePointer_ >, DeviceType > device(const DeviceType &device)
void test_cxx11_tensor_forced_eval_sycl()
A tensor expression mapping an existing array of data.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar * data()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const