cxx11_tensor_random_sycl.cpp File Reference
#include "main.h"
#include <unsupported/Eigen/CXX11/Tensor>

Macros

#define EIGEN_TEST_NO_LONGDOUBLE
 
#define EIGEN_TEST_NO_COMPLEX
 
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE   int64_t
 
#define EIGEN_USE_SYCL
 

Functions

template<typename DataType , int DataLayout, typename IndexType >
static void test_sycl_random_uniform (const Eigen::SyclDevice &sycl_device)
 
template<typename DataType , int DataLayout, typename IndexType >
void test_sycl_random_normal (const Eigen::SyclDevice &sycl_device)
 
template<typename DataType , typename dev_Selector >
void sycl_random_test_per_device (dev_Selector s)
 
 EIGEN_DECLARE_TEST (cxx11_tensor_random_sycl)
 

Macro Definition Documentation

◆ EIGEN_DEFAULT_DENSE_INDEX_TYPE

#define EIGEN_DEFAULT_DENSE_INDEX_TYPE   int64_t

◆ EIGEN_TEST_NO_COMPLEX

#define EIGEN_TEST_NO_COMPLEX

◆ EIGEN_TEST_NO_LONGDOUBLE

#define EIGEN_TEST_NO_LONGDOUBLE

◆ EIGEN_USE_SYCL

#define EIGEN_USE_SYCL

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( cxx11_tensor_random_sycl  )
76  {
77  for (const auto& device : Eigen::get_sycl_supported_devices()) {
78  CALL_SUBTEST(sycl_random_test_per_device<half>(device));
79  CALL_SUBTEST(sycl_random_test_per_device<float>(device));
80 #ifdef EIGEN_SYCL_DOUBLE_SUPPORT
81  CALL_SUBTEST(sycl_random_test_per_device<double>(device));
82 #endif
83  }
84 }
#define CALL_SUBTEST(FUNC)
Definition: main.h:382

References CALL_SUBTEST.

◆ sycl_random_test_per_device()

template<typename DataType , typename dev_Selector >
void sycl_random_test_per_device ( dev_Selector  s)
68  {
69  QueueInterface queueInterface(s);
70  auto sycl_device = Eigen::SyclDevice(&queueInterface);
71  test_sycl_random_uniform<DataType, RowMajor, int64_t>(sycl_device);
72  test_sycl_random_uniform<DataType, ColMajor, int64_t>(sycl_device);
73  test_sycl_random_normal<DataType, RowMajor, int64_t>(sycl_device);
74  test_sycl_random_normal<DataType, ColMajor, int64_t>(sycl_device);
75 }
RealScalar s
Definition: level1_cplx_impl.h:130

References s.

◆ test_sycl_random_normal()

template<typename DataType , int DataLayout, typename IndexType >
void test_sycl_random_normal ( const Eigen::SyclDevice &  sycl_device)
46  {
48  out.setZero();
49  std::size_t out_bytes = out.size() * sizeof(DataType);
50 
51  IndexType sizeDim0 = 72;
52  IndexType sizeDim1 = 97;
53 
54  array<IndexType, 2> tensorRange = {{sizeDim0, sizeDim1}};
55 
56  DataType* d_out = static_cast<DataType*>(sycl_device.allocate(out_bytes));
57  TensorMap<Tensor<DataType, 2, DataLayout, IndexType>> gpu_out(d_out, tensorRange);
59  gpu_out.device(sycl_device) = gpu_out.random(gen);
60  sycl_device.memcpyDeviceToHost(out.data(), d_out, out_bytes);
61 
62  // For now we just check the code doesn't crash.
63  // TODO: come up with a valid test of randomness
64  sycl_device.deallocate(d_out);
65 }
A tensor expression mapping an existing array of data.
Definition: TensorMap.h:33
The tensor class.
Definition: Tensor.h:68
Definition: TensorRandom.h:229
std::array< T, N > array
Definition: EmulateArray.h:231
std::ofstream out("Result.txt")

References Eigen::TensorBase< Derived, AccessLevel >::device(), and out().

◆ test_sycl_random_uniform()

template<typename DataType , int DataLayout, typename IndexType >
static void test_sycl_random_uniform ( const Eigen::SyclDevice &  sycl_device)
static
23  {
25  out.setZero();
26 
27  std::size_t out_bytes = out.size() * sizeof(DataType);
28 
29  IndexType sizeDim0 = 72;
30  IndexType sizeDim1 = 97;
31 
32  array<IndexType, 2> tensorRange = {{sizeDim0, sizeDim1}};
33 
34  DataType* d_out = static_cast<DataType*>(sycl_device.allocate(out_bytes));
35  TensorMap<Tensor<DataType, 2, DataLayout, IndexType>> gpu_out(d_out, tensorRange);
36 
37  gpu_out.device(sycl_device) = gpu_out.random();
38  sycl_device.memcpyDeviceToHost(out.data(), d_out, out_bytes);
39 
40  // For now we just check the code doesn't crash.
41  // TODO: come up with a valid test of randomness
42  sycl_device.deallocate(d_out);
43 }

References Eigen::TensorBase< Derived, AccessLevel >::device(), and out().