From 75c080b1762b8b83f6c2bb7baf95478a049b45d4 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Wed, 9 Nov 2016 06:23:42 -0800 Subject: [PATCH 1/4] Added a test to validate memory transfers between host and sycl device --- unsupported/test/cxx11_tensor_sycl.cpp | 71 ++++++++++++++++++++------ 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/unsupported/test/cxx11_tensor_sycl.cpp b/unsupported/test/cxx11_tensor_sycl.cpp index 6a9c33422..05fbf9e62 100644 --- a/unsupported/test/cxx11_tensor_sycl.cpp +++ b/unsupported/test/cxx11_tensor_sycl.cpp @@ -27,7 +27,46 @@ using Eigen::SyclDevice; using Eigen::Tensor; using Eigen::TensorMap; -void test_sycl_cpu(const Eigen::SyclDevice &sycl_device) { +void test_sycl_mem_transfers(const Eigen::SyclDevice &sycl_device) { + int sizeDim1 = 100; + int sizeDim2 = 100; + int sizeDim3 = 100; + array tensorRange = {{sizeDim1, sizeDim2, sizeDim3}}; + Tensor in1(tensorRange); + Tensor out1(tensorRange); + Tensor out2(tensorRange); + Tensor out3(tensorRange); + + in1 = in1.random(); + + float* gpu_data1 = static_cast(sycl_device.allocate(in1.size()*sizeof(float))); + float* gpu_data2 = static_cast(sycl_device.allocate(out1.size()*sizeof(float))); + //float* gpu_data = static_cast(sycl_device.allocate(out2.size()*sizeof(float))); + + TensorMap> gpu1(gpu_data1, tensorRange); + TensorMap> gpu2(gpu_data2, tensorRange); + //TensorMap> gpu_out2(gpu_out2_data, tensorRange); + + sycl_device.memcpyHostToDevice(gpu_data1, in1.data(),(in1.size())*sizeof(float)); + sycl_device.memcpyHostToDevice(gpu_data2, in1.data(),(in1.size())*sizeof(float)); + gpu1.device(sycl_device) = gpu1 * 3.14f; + gpu2.device(sycl_device) = gpu2 * 2.7f; + sycl_device.memcpyDeviceToHost(out1.data(), gpu_data1,(out1.size())*sizeof(float)); + sycl_device.memcpyDeviceToHost(out2.data(), gpu_data1,(out2.size())*sizeof(float)); + sycl_device.memcpyDeviceToHost(out3.data(), gpu_data2,(out3.size())*sizeof(float)); + // sycl_device.Synchronize(); + + for (int i = 0; i < in1.size(); ++i) { + VERIFY_IS_APPROX(out1(i), in1(i) * 3.14f); + VERIFY_IS_APPROX(out2(i), in1(i) * 3.14f); + VERIFY_IS_APPROX(out3(i), in1(i) * 2.7f); + } + + sycl_device.deallocate(gpu_data1); + sycl_device.deallocate(gpu_data2); +} + +void test_sycl_computations(const Eigen::SyclDevice &sycl_device) { int sizeDim1 = 100; int sizeDim2 = 100; @@ -41,10 +80,10 @@ void test_sycl_cpu(const Eigen::SyclDevice &sycl_device) { in2 = in2.random(); in3 = in3.random(); - float * gpu_in1_data = static_cast(sycl_device.allocate(in1.dimensions().TotalSize()*sizeof(float))); - float * gpu_in2_data = static_cast(sycl_device.allocate(in2.dimensions().TotalSize()*sizeof(float))); - float * gpu_in3_data = static_cast(sycl_device.allocate(in3.dimensions().TotalSize()*sizeof(float))); - float * gpu_out_data = static_cast(sycl_device.allocate(out.dimensions().TotalSize()*sizeof(float))); + float * gpu_in1_data = static_cast(sycl_device.allocate(in1.size()*sizeof(float))); + float * gpu_in2_data = static_cast(sycl_device.allocate(in2.size()*sizeof(float))); + float * gpu_in3_data = static_cast(sycl_device.allocate(in3.size()*sizeof(float))); + float * gpu_out_data = static_cast(sycl_device.allocate(out.size()*sizeof(float))); TensorMap> gpu_in1(gpu_in1_data, tensorRange); TensorMap> gpu_in2(gpu_in2_data, tensorRange); @@ -53,7 +92,7 @@ void test_sycl_cpu(const Eigen::SyclDevice &sycl_device) { /// a=1.2f gpu_in1.device(sycl_device) = gpu_in1.constant(1.2f); - sycl_device.memcpyDeviceToHost(in1.data(), gpu_in1_data ,(in1.dimensions().TotalSize())*sizeof(float)); + sycl_device.memcpyDeviceToHost(in1.data(), gpu_in1_data ,(in1.size())*sizeof(float)); for (int i = 0; i < sizeDim1; ++i) { for (int j = 0; j < sizeDim2; ++j) { for (int k = 0; k < sizeDim3; ++k) { @@ -65,7 +104,7 @@ void test_sycl_cpu(const Eigen::SyclDevice &sycl_device) { /// a=b*1.2f gpu_out.device(sycl_device) = gpu_in1 * 1.2f; - sycl_device.memcpyDeviceToHost(out.data(), gpu_out_data ,(out.dimensions().TotalSize())*sizeof(float)); + sycl_device.memcpyDeviceToHost(out.data(), gpu_out_data ,(out.size())*sizeof(float)); for (int i = 0; i < sizeDim1; ++i) { for (int j = 0; j < sizeDim2; ++j) { for (int k = 0; k < sizeDim3; ++k) { @@ -77,9 +116,9 @@ void test_sycl_cpu(const Eigen::SyclDevice &sycl_device) { printf("a=b*1.2f Test Passed\n"); /// c=a*b - sycl_device.memcpyHostToDevice(gpu_in2_data, in2.data(),(in2.dimensions().TotalSize())*sizeof(float)); + sycl_device.memcpyHostToDevice(gpu_in2_data, in2.data(),(in2.size())*sizeof(float)); gpu_out.device(sycl_device) = gpu_in1 * gpu_in2; - sycl_device.memcpyDeviceToHost(out.data(), gpu_out_data,(out.dimensions().TotalSize())*sizeof(float)); + sycl_device.memcpyDeviceToHost(out.data(), gpu_out_data,(out.size())*sizeof(float)); for (int i = 0; i < sizeDim1; ++i) { for (int j = 0; j < sizeDim2; ++j) { for (int k = 0; k < sizeDim3; ++k) { @@ -93,7 +132,7 @@ void test_sycl_cpu(const Eigen::SyclDevice &sycl_device) { /// c=a+b gpu_out.device(sycl_device) = gpu_in1 + gpu_in2; - sycl_device.memcpyDeviceToHost(out.data(), gpu_out_data,(out.dimensions().TotalSize())*sizeof(float)); + sycl_device.memcpyDeviceToHost(out.data(), gpu_out_data,(out.size())*sizeof(float)); for (int i = 0; i < sizeDim1; ++i) { for (int j = 0; j < sizeDim2; ++j) { for (int k = 0; k < sizeDim3; ++k) { @@ -107,7 +146,7 @@ void test_sycl_cpu(const Eigen::SyclDevice &sycl_device) { /// c=a*a gpu_out.device(sycl_device) = gpu_in1 * gpu_in1; - sycl_device.memcpyDeviceToHost(out.data(), gpu_out_data,(out.dimensions().TotalSize())*sizeof(float)); + sycl_device.memcpyDeviceToHost(out.data(), gpu_out_data,(out.size())*sizeof(float)); for (int i = 0; i < sizeDim1; ++i) { for (int j = 0; j < sizeDim2; ++j) { for (int k = 0; k < sizeDim3; ++k) { @@ -121,7 +160,7 @@ void test_sycl_cpu(const Eigen::SyclDevice &sycl_device) { //a*3.14f + b*2.7f gpu_out.device(sycl_device) = gpu_in1 * gpu_in1.constant(3.14f) + gpu_in2 * gpu_in2.constant(2.7f); - sycl_device.memcpyDeviceToHost(out.data(),gpu_out_data,(out.dimensions().TotalSize())*sizeof(float)); + sycl_device.memcpyDeviceToHost(out.data(),gpu_out_data,(out.size())*sizeof(float)); for (int i = 0; i < sizeDim1; ++i) { for (int j = 0; j < sizeDim2; ++j) { for (int k = 0; k < sizeDim3; ++k) { @@ -134,9 +173,9 @@ void test_sycl_cpu(const Eigen::SyclDevice &sycl_device) { printf("a*3.14f + b*2.7f Test Passed\n"); ///d= (a>0.5? b:c) - sycl_device.memcpyHostToDevice(gpu_in3_data, in3.data(),(in3.dimensions().TotalSize())*sizeof(float)); + sycl_device.memcpyHostToDevice(gpu_in3_data, in3.data(),(in3.size())*sizeof(float)); gpu_out.device(sycl_device) =(gpu_in1 > gpu_in1.constant(0.5f)).select(gpu_in2, gpu_in3); - sycl_device.memcpyDeviceToHost(out.data(), gpu_out_data,(out.dimensions().TotalSize())*sizeof(float)); + sycl_device.memcpyDeviceToHost(out.data(), gpu_out_data,(out.size())*sizeof(float)); for (int i = 0; i < sizeDim1; ++i) { for (int j = 0; j < sizeDim2; ++j) { for (int k = 0; k < sizeDim3; ++k) { @@ -152,8 +191,10 @@ void test_sycl_cpu(const Eigen::SyclDevice &sycl_device) { sycl_device.deallocate(gpu_in3_data); sycl_device.deallocate(gpu_out_data); } + void test_cxx11_tensor_sycl() { cl::sycl::gpu_selector s; Eigen::SyclDevice sycl_device(s); - CALL_SUBTEST(test_sycl_cpu(sycl_device)); + CALL_SUBTEST(test_sycl_mem_transfers(sycl_device)); + CALL_SUBTEST(test_sycl_computations(sycl_device)); } From 2e704d4257f235dd1f3224cd590e4fca4e3aaf96 Mon Sep 17 00:00:00 2001 From: Mehdi Goli Date: Thu, 10 Nov 2016 18:45:12 +0000 Subject: [PATCH 2/4] Adding Memset; optimising MecopyDeviceToHost by removing double copying; --- .../Eigen/CXX11/src/Tensor/TensorDeviceSycl.h | 72 +++++++++++++++---- .../CXX11/src/Tensor/TensorReductionSycl.h | 13 +--- .../Eigen/CXX11/src/Tensor/TensorSyclRun.h | 12 +--- unsupported/test/cxx11_tensor_device_sycl.cpp | 13 ++++ 4 files changed, 78 insertions(+), 32 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h index 7c039890e..e767d8965 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h @@ -72,9 +72,14 @@ struct SyclDevice { template inline std::pair>::iterator,bool> add_sycl_buffer(const T *ptr, size_t num_bytes) const { using Type = cl::sycl::buffer; - std::pair>::iterator,bool> ret = buffer_map.insert(std::pair>(ptr, std::shared_ptr(new Type(cl::sycl::range<1>(num_bytes)), - [](void *dataMem) { delete static_cast(dataMem); }))); - (static_cast(buffer_map.at(ptr).get()))->set_final_data(nullptr); + std::pair>::iterator,bool> ret; + if(ptr!=nullptr){ + ret= buffer_map.insert(std::pair>(ptr, std::shared_ptr(new Type(cl::sycl::range<1>(num_bytes)), + [](void *dataMem) { delete static_cast(dataMem); }))); + (static_cast(ret.first->second.get()))->set_final_data(nullptr); + } else { + eigen_assert("The Device memory is not allocated please call allocate on the device is not initialised!!") + } return ret; } @@ -83,36 +88,77 @@ struct SyclDevice { } /// allocating memory on the cpu - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void *allocate(size_t) const { + void *allocate(size_t) const { return internal::aligned_malloc(8); } // some runtime conditions that can be applied here bool isDeviceSuitable() const { return true; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpy(void *dst, const void *src, size_t n) const { + void memcpy(void *dst, const void *src, size_t n) const { ::memcpy(dst, src, n); } - template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpyHostToDevice(T *dst, const T *src, size_t n) const { + template void memcpyHostToDevice(T *dst, const T *src, size_t n) const { auto host_acc= (static_cast*>(add_sycl_buffer(dst, n).first->second.get()))-> template get_access(); memcpy(host_acc.get_pointer(), src, n); } - /// whith the current implementation of sycl, the data is copied twice from device to host. This will be fixed soon. - template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memcpyDeviceToHost(T *dst, const T *src, size_t n) const { + + inline void parallel_for_setup(size_t n, size_t &tileSize, size_t &rng, size_t &GRange) const { + tileSize =m_queue.get_device(). template get_info()/2; + rng = n; + if (rng==0) rng=1; + GRange=rng; + if (tileSize>GRange) tileSize=GRange; + else if(GRange>tileSize){ + size_t xMode = GRange % tileSize; + if (xMode != 0) GRange += (tileSize - xMode); + } + } + + template void memcpyDeviceToHost(T *dst, const T *src, size_t n) const { auto it = buffer_map.find(src); if (it != buffer_map.end()) { - auto host_acc= (static_cast*>(it->second.get()))-> template get_access(); - memcpy(dst,host_acc.get_pointer(), n); + size_t rng, GRange, tileSize; + parallel_for_setup(n/sizeof(T), tileSize, rng, GRange); + + auto dest_buf = cl::sycl::buffer>(dst, cl::sycl::range<1>(rng)); + typedef decltype(dest_buf) SYCLDTOH; + m_queue.submit([&](cl::sycl::handler &cgh) { + auto src_acc= (static_cast*>(it->second.get()))-> template get_access(cgh); + auto dst_acc =dest_buf.template get_access(cgh); + cgh.parallel_for( cl::sycl::nd_range<1>(cl::sycl::range<1>(GRange), cl::sycl::range<1>(tileSize)), [=](cl::sycl::nd_item<1> itemID) { + auto globalid=itemID.get_global_linear_id(); + if (globalid< dst_acc.get_size()) { + dst_acc[globalid] = src_acc[globalid]; + } + }); + }); + m_queue.throw_asynchronous(); + } else{ eigen_assert("no device memory found. The memory might be destroyed before creation"); } } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void memset(void *buffer, int c, size_t n) const { - ::memset(buffer, c, n); + template void memset(T *buff, int c, size_t n) const { + + size_t rng, GRange, tileSize; + parallel_for_setup(n/sizeof(T), tileSize, rng, GRange); + m_queue.submit([&](cl::sycl::handler &cgh) { + auto buf_acc =(static_cast*>(add_sycl_buffer(buff, n).first->second.get()))-> template get_access(cgh); + cgh.parallel_for( cl::sycl::nd_range<1>(cl::sycl::range<1>(GRange), cl::sycl::range<1>(tileSize)), [=](cl::sycl::nd_item<1> itemID) { + auto globalid=itemID.get_global_linear_id(); + auto buf_ptr= reinterpret_cast::pointer_t>((&(*buf_acc.get_pointer()))); + if (globalid< buf_acc.get_size()) { + for(size_t i=0; i { typedef const typename Self::ChildType HostExpr; /// this is the child of reduction typedef typename TensorSycl::internal::createPlaceHolderExpression::Type PlaceHolderExpr; auto functors = TensorSycl::internal::extractFunctors(self.impl()); - - size_t tileSize =dev.m_queue.get_device(). template get_info()/2; - - size_t GRange=num_coeffs_to_preserve; - if (tileSize>GRange) tileSize=GRange; - else if(GRange>tileSize){ - size_t xMode = GRange % tileSize; - if (xMode != 0) GRange += (tileSize - xMode); - } + size_t range, GRange, tileSize; + dev.parallel_for_setup(num_coeffs_to_preserve, tileSize, range, GRange); // getting final out buffer at the moment the created buffer is true because there is no need for assign /// creating the shared memory for calculating reduction. /// This one is used to collect all the reduced value of shared memory as we dont have global barrier on GPU. Once it is saved we can @@ -223,7 +216,7 @@ struct InnerReducer { auto device_self_evaluator = Eigen::TensorEvaluator(device_self_expr, Eigen::DefaultDevice()); /// const cast added as a naive solution to solve the qualifier drop error auto globalid=itemID.get_global_linear_id(); - if (globalid< static_cast(num_coeffs_to_preserve)) { + if (globalid< range) { typename DeiceSelf::CoeffReturnType accum = functor.initialize(); GenericDimReducer::reduce(device_self_evaluator, device_self_evaluator.firstInput(globalid),const_cast(functor), &accum); functor.finalize(accum); diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorSyclRun.h b/unsupported/Eigen/CXX11/src/Tensor/TensorSyclRun.h index 7914b6fad..724eebd83 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorSyclRun.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorSyclRun.h @@ -37,18 +37,12 @@ void run(Expr &expr, Dev &dev) { typedef typename internal::createPlaceHolderExpression::Type PlaceHolderExpr; auto functors = internal::extractFunctors(evaluator); - size_t tileSize =dev.m_queue.get_device(). template get_info()/2; dev.m_queue.submit([&](cl::sycl::handler &cgh) { - // create a tuple of accessors from Evaluator auto tuple_of_accessors = internal::createTupleOfAccessors(cgh, evaluator); - const auto range = utility::tuple::get<0>(tuple_of_accessors).get_range()[0]; - size_t GRange=range; - if (tileSize>GRange) tileSize=GRange; - else if(GRange>tileSize){ - size_t xMode = GRange % tileSize; - if (xMode != 0) GRange += (tileSize - xMode); - } + size_t range, GRange, tileSize; + dev.parallel_for_setup(utility::tuple::get<0>(tuple_of_accessors).get_range()[0], tileSize, range, GRange); + // run the kernel cgh.parallel_for( cl::sycl::nd_range<1>(cl::sycl::range<1>(GRange), cl::sycl::range<1>(tileSize)), [=](cl::sycl::nd_item<1> itemID) { typedef typename internal::ConvertToDeviceExpression::Type DevExpr; diff --git a/unsupported/test/cxx11_tensor_device_sycl.cpp b/unsupported/test/cxx11_tensor_device_sycl.cpp index 7f79753c5..820bc88d0 100644 --- a/unsupported/test/cxx11_tensor_device_sycl.cpp +++ b/unsupported/test/cxx11_tensor_device_sycl.cpp @@ -19,10 +19,23 @@ #include "main.h" #include +#include void test_device_sycl(const Eigen::SyclDevice &sycl_device) { std::cout <<"Helo from ComputeCpp: the requested device exists and the device name is : " << sycl_device.m_queue.get_device(). template get_info() < tensorRange = {{sizeDim1}}; + Tensor in(tensorRange); + Tensor in1(tensorRange); + memset(in1.data(), 1,in1.dimensions().TotalSize()*sizeof(int)); + int * gpu_in_data = static_cast(sycl_device.allocate(in.dimensions().TotalSize()*sizeof(int))); + sycl_device.memset(gpu_in_data, 1,in.dimensions().TotalSize()*sizeof(int) ); + sycl_device.memcpyDeviceToHost(in.data(), gpu_in_data, in.dimensions().TotalSize()*sizeof(int) ); + for (int i=0; i Date: Thu, 10 Nov 2016 18:58:08 +0000 Subject: [PATCH 3/4] adding the missing in eigen_assert! --- unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h index e767d8965..2be1a5ad6 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h @@ -78,7 +78,7 @@ struct SyclDevice { [](void *dataMem) { delete static_cast(dataMem); }))); (static_cast(ret.first->second.get()))->set_final_data(nullptr); } else { - eigen_assert("The Device memory is not allocated please call allocate on the device is not initialised!!") + eigen_assert("The device memory is not allocated. Please call allocate on the device!!"); } return ret; } From 3be3963021ca0b1725bda2251e641c8561d707f7 Mon Sep 17 00:00:00 2001 From: Mehdi Goli Date: Thu, 10 Nov 2016 19:16:31 +0000 Subject: [PATCH 4/4] Adding EIGEN_STRONG_INLINE back; using size() instead of dimensions.TotalSize() on Tensor. --- .../Eigen/CXX11/src/Tensor/TensorDeviceSycl.h | 20 +++++++++---------- unsupported/test/cxx11_tensor_device_sycl.cpp | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h index 2be1a5ad6..844cec199 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h @@ -44,14 +44,14 @@ struct SyclDevice { // destructor ~SyclDevice() { deallocate_all(); } - template void deallocate(T *p) const { + template EIGEN_STRONG_INLINE void deallocate(T *p) const { auto it = buffer_map.find(p); if (it != buffer_map.end()) { buffer_map.erase(it); internal::aligned_free(p); } } - void deallocate_all() const { + EIGEN_STRONG_INLINE void deallocate_all() const { std::map>::iterator it=buffer_map.begin(); while (it!=buffer_map.end()) { auto p=it->first; @@ -88,23 +88,23 @@ struct SyclDevice { } /// allocating memory on the cpu - void *allocate(size_t) const { + EIGEN_STRONG_INLINE void *allocate(size_t) const { return internal::aligned_malloc(8); } // some runtime conditions that can be applied here - bool isDeviceSuitable() const { return true; } + EIGEN_STRONG_INLINE bool isDeviceSuitable() const { return true; } - void memcpy(void *dst, const void *src, size_t n) const { + EIGEN_STRONG_INLINE void memcpy(void *dst, const void *src, size_t n) const { ::memcpy(dst, src, n); } - template void memcpyHostToDevice(T *dst, const T *src, size_t n) const { + template EIGEN_STRONG_INLINE void memcpyHostToDevice(T *dst, const T *src, size_t n) const { auto host_acc= (static_cast*>(add_sycl_buffer(dst, n).first->second.get()))-> template get_access(); memcpy(host_acc.get_pointer(), src, n); } - inline void parallel_for_setup(size_t n, size_t &tileSize, size_t &rng, size_t &GRange) const { + EIGEN_STRONG_INLINE void parallel_for_setup(size_t n, size_t &tileSize, size_t &rng, size_t &GRange) const { tileSize =m_queue.get_device(). template get_info()/2; rng = n; if (rng==0) rng=1; @@ -116,7 +116,7 @@ struct SyclDevice { } } - template void memcpyDeviceToHost(T *dst, const T *src, size_t n) const { + template EIGEN_STRONG_INLINE void memcpyDeviceToHost(T *dst, const T *src, size_t n) const { auto it = buffer_map.find(src); if (it != buffer_map.end()) { size_t rng, GRange, tileSize; @@ -141,7 +141,7 @@ struct SyclDevice { } } - template void memset(T *buff, int c, size_t n) const { + template EIGEN_STRONG_INLINE void memset(T *buff, int c, size_t n) const { size_t rng, GRange, tileSize; parallel_for_setup(n/sizeof(T), tileSize, rng, GRange); @@ -158,7 +158,7 @@ struct SyclDevice { }); m_queue.throw_asynchronous(); } - int majorDeviceVersion() const { + EIGEN_STRONG_INLINE int majorDeviceVersion() const { return 1; } }; diff --git a/unsupported/test/cxx11_tensor_device_sycl.cpp b/unsupported/test/cxx11_tensor_device_sycl.cpp index 820bc88d0..584fa8026 100644 --- a/unsupported/test/cxx11_tensor_device_sycl.cpp +++ b/unsupported/test/cxx11_tensor_device_sycl.cpp @@ -29,11 +29,11 @@ void test_device_sycl(const Eigen::SyclDevice &sycl_device) { array tensorRange = {{sizeDim1}}; Tensor in(tensorRange); Tensor in1(tensorRange); - memset(in1.data(), 1,in1.dimensions().TotalSize()*sizeof(int)); - int * gpu_in_data = static_cast(sycl_device.allocate(in.dimensions().TotalSize()*sizeof(int))); - sycl_device.memset(gpu_in_data, 1,in.dimensions().TotalSize()*sizeof(int) ); - sycl_device.memcpyDeviceToHost(in.data(), gpu_in_data, in.dimensions().TotalSize()*sizeof(int) ); - for (int i=0; i(sycl_device.allocate(in.size()*sizeof(int))); + sycl_device.memset(gpu_in_data, 1,in.size()*sizeof(int) ); + sycl_device.memcpyDeviceToHost(in.data(), gpu_in_data, in.size()*sizeof(int) ); + for (int i=0; i