15 #define EIGEN_TEST_NO_LONGDOUBLE 16 #define EIGEN_TEST_NO_COMPLEX 18 #define EIGEN_DEFAULT_DENSE_INDEX_TYPE int64_t 19 #define EIGEN_USE_SYCL 22 #include <unsupported/Eigen/CXX11/Tensor> 25 using Eigen::SyclDevice;
29 template <
typename DataType,
int DataLayout,
typename IndexType>
31 IndexType sizeDim1 = 2;
32 IndexType sizeDim2 = 3;
33 IndexType sizeDim3 = 5;
34 IndexType sizeDim4 = 7;
40 const size_t buffSize = tensor.
size() *
sizeof(DataType);
46 DataType* gpu_data1 =
static_cast<DataType*
>(sycl_device.allocate(buffSize));
47 DataType* gpu_data2 =
static_cast<DataType*
>(sycl_device.allocate(buffSize));
54 sycl_device.memcpyHostToDevice(gpu_data1, tensor.
data(), buffSize);
57 sycl_device.memcpyDeviceToHost(no_shuffle.
data(), gpu_data2, buffSize);
58 sycl_device.synchronize();
65 for (IndexType
i = 0;
i < sizeDim1; ++
i) {
66 for (IndexType
j = 0;
j < sizeDim2; ++
j) {
67 for (IndexType k = 0; k < sizeDim3; ++k) {
68 for (IndexType
l = 0;
l < sizeDim4; ++
l) {
80 {sizeDim3, sizeDim4, sizeDim2, sizeDim1}};
82 DataType* gpu_data3 =
static_cast<DataType*
>(sycl_device.allocate(buffSize));
84 gpu_data3, tensorrangeShuffle);
87 sycl_device.memcpyDeviceToHost(shuffle.
data(), gpu_data3, buffSize);
88 sycl_device.synchronize();
95 for (IndexType
i = 0;
i < sizeDim1; ++
i) {
96 for (IndexType
j = 0;
j < sizeDim2; ++
j) {
97 for (IndexType k = 0; k < sizeDim3; ++k) {
98 for (IndexType
l = 0;
l < sizeDim4; ++
l) {
106 template <
typename DataType,
typename dev_Selector>
108 QueueInterface queueInterface(s);
109 auto sycl_device = Eigen::SyclDevice(&queueInterface);
110 test_simple_shuffling_sycl<DataType, RowMajor, int64_t>(sycl_device);
111 test_simple_shuffling_sycl<DataType, ColMajor, int64_t>(sycl_device);
114 for (
const auto& device : Eigen::get_sycl_supported_devices()) {
115 CALL_SUBTEST(sycl_shuffling_test_per_device<float>(device));
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor< Scalar_, NumIndices_, Options_, IndexType_ > & setRandom()
static void test_simple_shuffling_sycl(const Eigen::SyclDevice &sycl_device)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorShufflingOp< const Shuffle, const TensorMap< PlainObjectType, Options_, MakePointer_ > > shuffle(const Shuffle &shfl) const
static const Line3 l(Rot3(), 1, 1)
#define VERIFY_IS_EQUAL(a, b)
A tensor expression mapping an existing array of data.
void sycl_shuffling_test_per_device(dev_Selector s)
TensorDevice< TensorMap< PlainObjectType, Options_, MakePointer_ >, DeviceType > device(const DeviceType &dev)
EIGEN_DECLARE_TEST(cxx11_tensor_shuffling_sycl)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar * data()
#define CALL_SUBTEST(FUNC)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(std::size_t n) const