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 21 #include <unsupported/Eigen/CXX11/Tensor> 25 template <
typename DataType,
int DataLayout,
typename IndexType>
27 std::cout <<
"Running on : " 28 << sycl_device.sycl_queue().get_device().
template get_info<cl::sycl::info::device::name>()
30 IndexType sizeDim1 = 100;
34 memset(in1.
data(), 1, in1.
size() *
sizeof(DataType));
35 DataType* gpu_in_data =
static_cast<DataType*
>(sycl_device.allocate(in.
size()*
sizeof(DataType)));
36 sycl_device.memset(gpu_in_data, 1, in.
size()*
sizeof(DataType));
37 sycl_device.memcpyDeviceToHost(in.
data(), gpu_in_data, in.
size()*
sizeof(DataType));
38 for (IndexType
i=0;
i<in.
size();
i++) {
41 sycl_device.deallocate(gpu_in_data);
44 template <
typename DataType,
int DataLayout,
typename IndexType>
47 IndexType sizeDim1 = 100;
49 DataType* gpu_data =
static_cast<DataType*
>(sycl_device.allocate(sizeDim1*
sizeof(DataType)));
50 sycl_device.memset(gpu_data, 1, sizeDim1*
sizeof(DataType));
54 out.
device(sycl_device) = in / in.constant(0);
56 sycl_device.synchronize();
58 sycl_device.deallocate(gpu_data);
62 std::cout <<
"Running on " << d.template get_info<cl::sycl::info::device::name>() << std::endl;
63 QueueInterface queueInterface(d);
64 auto sycl_device = Eigen::SyclDevice(&queueInterface);
65 test_device_memory<DataType, RowMajor, int64_t>(sycl_device);
66 test_device_memory<DataType, ColMajor, int64_t>(sycl_device);
74 for (
const auto& device :Eigen::get_sycl_supported_devices()) {
75 CALL_SUBTEST(sycl_device_test_per_device<float>(device));
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const
std::ofstream out("Result.txt")
EIGEN_DECLARE_TEST(cxx11_tensor_device_sycl)
void test_device_memory(const Eigen::SyclDevice &sycl_device)
#define VERIFY_IS_EQUAL(a, b)
A tensor expression mapping an existing array of data.
void test_device_exceptions(const Eigen::SyclDevice &sycl_device)
TensorDevice< TensorMap< PlainObjectType, Options_, MakePointer_ >, DeviceType > device(const DeviceType &dev)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar * data()
#define CALL_SUBTEST(FUNC)
void sycl_device_test_per_device(const cl::sycl::device &d)