From e46e7223817cfd982edec6d8e25c77e8e2493d78 Mon Sep 17 00:00:00 2001 From: Mehdi Goli Date: Mon, 16 Jan 2017 13:58:49 +0000 Subject: Adding Tensor ReverseOp; TensorStriding; TensorConversionOp; Modifying Tensor Contractsycl to be located in any place in the expression tree. --- unsupported/test/cxx11_tensor_sycl.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'unsupported/test/cxx11_tensor_sycl.cpp') diff --git a/unsupported/test/cxx11_tensor_sycl.cpp b/unsupported/test/cxx11_tensor_sycl.cpp index d5c0cbaad..5992a306d 100644 --- a/unsupported/test/cxx11_tensor_sycl.cpp +++ b/unsupported/test/cxx11_tensor_sycl.cpp @@ -229,6 +229,36 @@ void test_sycl_computations(const Eigen::SyclDevice &sycl_device) { sycl_device.deallocate(gpu_in3_data); sycl_device.deallocate(gpu_out_data); } +template +static void test_sycl_cast(const Eigen::SyclDevice& sycl_device){ + int size = 20; + array tensorRange = {{size}}; + Tensor in(tensorRange); + Tensor out(tensorRange); + Tensor out_host(tensorRange); + + in = in.random(); + + Scalar1* gpu_in_data = static_cast(sycl_device.allocate(in.size()*sizeof(Scalar1))); + Scalar2 * gpu_out_data = static_cast(sycl_device.allocate(out.size()*sizeof(Scalar2))); + + + + + TensorMap> gpu_in(gpu_in_data, tensorRange); + TensorMap> gpu_out(gpu_out_data, tensorRange); + sycl_device.memcpyHostToDevice(gpu_in_data, in.data(),(in.size())*sizeof(Scalar1)); + gpu_out.device(sycl_device) = gpu_in. template cast(); + sycl_device.memcpyDeviceToHost(out.data(), gpu_out_data, out.size()*sizeof(Scalar2)); + out_host = in. template cast(); + for(int i=0; i< size; i++) + { + VERIFY_IS_APPROX(out(i), out_host(i)); + } + printf("cast Test Passed\n"); + sycl_device.deallocate(gpu_in_data); + sycl_device.deallocate(gpu_out_data); +} template void sycl_computing_test_per_device(dev_Selector s){ QueueInterface queueInterface(s); auto sycl_device = Eigen::SyclDevice(&queueInterface); @@ -238,6 +268,8 @@ template void sycl_computing_test_per_ test_sycl_mem_transfers(sycl_device); test_sycl_computations(sycl_device); test_sycl_mem_sync(sycl_device); + test_sycl_cast(sycl_device); + test_sycl_cast(sycl_device); } void test_cxx11_tensor_sycl() { -- cgit v1.2.3