aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/test/cxx11_tensor_reduction_sycl.cpp
diff options
context:
space:
mode:
authorGravatar Mehdi Goli <mehdi.goli@codeplay.com>2017-02-01 15:29:53 +0000
committerGravatar Mehdi Goli <mehdi.goli@codeplay.com>2017-02-01 15:29:53 +0000
commitbab29936a1cf0a68ffe4ccb1fd9b4807a3ec87ae (patch)
treec750b36227a31ddb2a1e0d5fd11f0036fda775db /unsupported/test/cxx11_tensor_reduction_sycl.cpp
parent48a20b7d956433713a39e04d39cba443b7a763de (diff)
Reducing warnings in Sycl backend.
Diffstat (limited to 'unsupported/test/cxx11_tensor_reduction_sycl.cpp')
-rw-r--r--unsupported/test/cxx11_tensor_reduction_sycl.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/unsupported/test/cxx11_tensor_reduction_sycl.cpp b/unsupported/test/cxx11_tensor_reduction_sycl.cpp
index 941469029..98a59a14c 100644
--- a/unsupported/test/cxx11_tensor_reduction_sycl.cpp
+++ b/unsupported/test/cxx11_tensor_reduction_sycl.cpp
@@ -14,23 +14,23 @@
#define EIGEN_TEST_NO_LONGDOUBLE
#define EIGEN_TEST_NO_COMPLEX
#define EIGEN_TEST_FUNC cxx11_tensor_reduction_sycl
-#define EIGEN_DEFAULT_DENSE_INDEX_TYPE int
+#define EIGEN_DEFAULT_DENSE_INDEX_TYPE int64_t
#define EIGEN_USE_SYCL
#include "main.h"
#include <unsupported/Eigen/CXX11/Tensor>
-template <typename DataType, int DataLayout>
+template <typename DataType, int DataLayout, typename IndexType>
static void test_full_reductions_sycl(const Eigen::SyclDevice& sycl_device) {
- const int num_rows = 452;
- const int num_cols = 765;
- array<int, 2> tensorRange = {{num_rows, num_cols}};
+ const IndexType num_rows = 452;
+ const IndexType num_cols = 765;
+ array<IndexType, 2> tensorRange = {{num_rows, num_cols}};
- Tensor<DataType, 2, DataLayout> in(tensorRange);
- Tensor<DataType, 0, DataLayout> full_redux;
- Tensor<DataType, 0, DataLayout> full_redux_gpu;
+ Tensor<DataType, 2, DataLayout, IndexType> in(tensorRange);
+ Tensor<DataType, 0, DataLayout, IndexType> full_redux;
+ Tensor<DataType, 0, DataLayout, IndexType> full_redux_gpu;
in.setRandom();
@@ -39,8 +39,8 @@ static void test_full_reductions_sycl(const Eigen::SyclDevice& sycl_device) {
DataType* gpu_in_data = static_cast<DataType*>(sycl_device.allocate(in.dimensions().TotalSize()*sizeof(DataType)));
DataType* gpu_out_data =(DataType*)sycl_device.allocate(sizeof(DataType));
- TensorMap<Tensor<DataType, 2, DataLayout> > in_gpu(gpu_in_data, tensorRange);
- TensorMap<Tensor<DataType, 0, DataLayout> > out_gpu(gpu_out_data);
+ TensorMap<Tensor<DataType, 2, DataLayout, IndexType> > in_gpu(gpu_in_data, tensorRange);
+ TensorMap<Tensor<DataType, 0, DataLayout, IndexType> > out_gpu(gpu_out_data);
sycl_device.memcpyHostToDevice(gpu_in_data, in.data(),(in.dimensions().TotalSize())*sizeof(DataType));
out_gpu.device(sycl_device) = in_gpu.sum();
@@ -51,21 +51,21 @@ static void test_full_reductions_sycl(const Eigen::SyclDevice& sycl_device) {
sycl_device.deallocate(gpu_in_data);
sycl_device.deallocate(gpu_out_data);
}
-template <typename DataType, int DataLayout>
+template <typename DataType, int DataLayout, typename IndexType>
static void test_first_dim_reductions_sycl(const Eigen::SyclDevice& sycl_device) {
- int dim_x = 145;
- int dim_y = 1;
- int dim_z = 67;
+ IndexType dim_x = 145;
+ IndexType dim_y = 1;
+ IndexType dim_z = 67;
- array<int, 3> tensorRange = {{dim_x, dim_y, dim_z}};
- Eigen::array<int, 1> red_axis;
+ array<IndexType, 3> tensorRange = {{dim_x, dim_y, dim_z}};
+ Eigen::array<IndexType, 1> red_axis;
red_axis[0] = 0;
- array<int, 2> reduced_tensorRange = {{dim_y, dim_z}};
+ array<IndexType, 2> reduced_tensorRange = {{dim_y, dim_z}};
- Tensor<DataType, 3, DataLayout> in(tensorRange);
- Tensor<DataType, 2, DataLayout> redux(reduced_tensorRange);
- Tensor<DataType, 2, DataLayout> redux_gpu(reduced_tensorRange);
+ Tensor<DataType, 3, DataLayout, IndexType> in(tensorRange);
+ Tensor<DataType, 2, DataLayout, IndexType> redux(reduced_tensorRange);
+ Tensor<DataType, 2, DataLayout, IndexType> redux_gpu(reduced_tensorRange);
in.setRandom();
@@ -74,37 +74,37 @@ static void test_first_dim_reductions_sycl(const Eigen::SyclDevice& sycl_device)
DataType* gpu_in_data = static_cast<DataType*>(sycl_device.allocate(in.dimensions().TotalSize()*sizeof(DataType)));
DataType* gpu_out_data = static_cast<DataType*>(sycl_device.allocate(redux_gpu.dimensions().TotalSize()*sizeof(DataType)));
- TensorMap<Tensor<DataType, 3, DataLayout> > in_gpu(gpu_in_data, tensorRange);
- TensorMap<Tensor<DataType, 2, DataLayout> > out_gpu(gpu_out_data, reduced_tensorRange);
+ TensorMap<Tensor<DataType, 3, DataLayout, IndexType> > in_gpu(gpu_in_data, tensorRange);
+ TensorMap<Tensor<DataType, 2, DataLayout, IndexType> > out_gpu(gpu_out_data, reduced_tensorRange);
sycl_device.memcpyHostToDevice(gpu_in_data, in.data(),(in.dimensions().TotalSize())*sizeof(DataType));
out_gpu.device(sycl_device) = in_gpu.sum(red_axis);
sycl_device.memcpyDeviceToHost(redux_gpu.data(), gpu_out_data, redux_gpu.dimensions().TotalSize()*sizeof(DataType));
// Check that the CPU and GPU reductions return the same result.
- for(int j=0; j<reduced_tensorRange[0]; j++ )
- for(int k=0; k<reduced_tensorRange[1]; k++ )
+ for(IndexType j=0; j<reduced_tensorRange[0]; j++ )
+ for(IndexType k=0; k<reduced_tensorRange[1]; k++ )
VERIFY_IS_APPROX(redux_gpu(j,k), redux(j,k));
sycl_device.deallocate(gpu_in_data);
sycl_device.deallocate(gpu_out_data);
}
-template <typename DataType, int DataLayout>
+template <typename DataType, int DataLayout, typename IndexType>
static void test_last_dim_reductions_sycl(const Eigen::SyclDevice &sycl_device) {
- int dim_x = 567;
- int dim_y = 1;
- int dim_z = 47;
+ IndexType dim_x = 567;
+ IndexType dim_y = 1;
+ IndexType dim_z = 47;
- array<int, 3> tensorRange = {{dim_x, dim_y, dim_z}};
- Eigen::array<int, 1> red_axis;
+ array<IndexType, 3> tensorRange = {{dim_x, dim_y, dim_z}};
+ Eigen::array<IndexType, 1> red_axis;
red_axis[0] = 2;
- array<int, 2> reduced_tensorRange = {{dim_x, dim_y}};
+ array<IndexType, 2> reduced_tensorRange = {{dim_x, dim_y}};
- Tensor<DataType, 3, DataLayout> in(tensorRange);
- Tensor<DataType, 2, DataLayout> redux(reduced_tensorRange);
- Tensor<DataType, 2, DataLayout> redux_gpu(reduced_tensorRange);
+ Tensor<DataType, 3, DataLayout, IndexType> in(tensorRange);
+ Tensor<DataType, 2, DataLayout, IndexType> redux(reduced_tensorRange);
+ Tensor<DataType, 2, DataLayout, IndexType> redux_gpu(reduced_tensorRange);
in.setRandom();
@@ -113,15 +113,15 @@ static void test_last_dim_reductions_sycl(const Eigen::SyclDevice &sycl_device)
DataType* gpu_in_data = static_cast<DataType*>(sycl_device.allocate(in.dimensions().TotalSize()*sizeof(DataType)));
DataType* gpu_out_data = static_cast<DataType*>(sycl_device.allocate(redux_gpu.dimensions().TotalSize()*sizeof(DataType)));
- TensorMap<Tensor<DataType, 3, DataLayout> > in_gpu(gpu_in_data, tensorRange);
- TensorMap<Tensor<DataType, 2, DataLayout> > out_gpu(gpu_out_data, reduced_tensorRange);
+ TensorMap<Tensor<DataType, 3, DataLayout, IndexType> > in_gpu(gpu_in_data, tensorRange);
+ TensorMap<Tensor<DataType, 2, DataLayout, IndexType> > out_gpu(gpu_out_data, reduced_tensorRange);
sycl_device.memcpyHostToDevice(gpu_in_data, in.data(),(in.dimensions().TotalSize())*sizeof(DataType));
out_gpu.device(sycl_device) = in_gpu.sum(red_axis);
sycl_device.memcpyDeviceToHost(redux_gpu.data(), gpu_out_data, redux_gpu.dimensions().TotalSize()*sizeof(DataType));
// Check that the CPU and GPU reductions return the same result.
- for(int j=0; j<reduced_tensorRange[0]; j++ )
- for(int k=0; k<reduced_tensorRange[1]; k++ )
+ for(IndexType j=0; j<reduced_tensorRange[0]; j++ )
+ for(IndexType k=0; k<reduced_tensorRange[1]; k++ )
VERIFY_IS_APPROX(redux_gpu(j,k), redux(j,k));
sycl_device.deallocate(gpu_in_data);
@@ -133,12 +133,12 @@ template<typename DataType> void sycl_reduction_test_per_device(const cl::sycl::
QueueInterface queueInterface(d);
auto sycl_device = Eigen::SyclDevice(&queueInterface);
- test_full_reductions_sycl<DataType, RowMajor>(sycl_device);
- test_first_dim_reductions_sycl<DataType, RowMajor>(sycl_device);
- test_last_dim_reductions_sycl<DataType, RowMajor>(sycl_device);
- test_full_reductions_sycl<DataType, ColMajor>(sycl_device);
- test_first_dim_reductions_sycl<DataType, ColMajor>(sycl_device);
- test_last_dim_reductions_sycl<DataType, ColMajor>(sycl_device);
+ test_full_reductions_sycl<DataType, RowMajor, int64_t>(sycl_device);
+ test_first_dim_reductions_sycl<DataType, RowMajor, int64_t>(sycl_device);
+ test_last_dim_reductions_sycl<DataType, RowMajor, int64_t>(sycl_device);
+ test_full_reductions_sycl<DataType, ColMajor, int64_t>(sycl_device);
+ test_first_dim_reductions_sycl<DataType, ColMajor, int64_t>(sycl_device);
+ test_last_dim_reductions_sycl<DataType, ColMajor, int64_t>(sycl_device);
}
void test_cxx11_tensor_reduction_sycl() {
for (const auto& device :Eigen::get_sycl_supported_devices()) {