aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/test
diff options
context:
space:
mode:
authorGravatar Mehdi Goli <mehdi.goli@codeplay.com>2016-10-14 12:09:55 +0100
committerGravatar Mehdi Goli <mehdi.goli@codeplay.com>2016-10-14 12:09:55 +0100
commit524fa4c46f8c5c1bc01f7754188e6883f669a543 (patch)
tree4e52325e02ed13d361cb28db86a2b6c255aea6e3 /unsupported/test
parentd7f9679a34ef991fa3c9da8f61510d6c48aaa19c (diff)
Reducing the code by generalising sycl backend functions/structs.
Diffstat (limited to 'unsupported/test')
-rw-r--r--unsupported/test/CMakeLists.txt14
-rw-r--r--unsupported/test/cxx11_tensor_broadcast_sycl.cpp4
-rw-r--r--unsupported/test/cxx11_tensor_device_sycl.cpp6
-rw-r--r--unsupported/test/cxx11_tensor_forced_eval_sycl.cpp6
-rw-r--r--unsupported/test/cxx11_tensor_sycl.cpp92
5 files changed, 60 insertions, 62 deletions
diff --git a/unsupported/test/CMakeLists.txt b/unsupported/test/CMakeLists.txt
index 17073dfa7..aeaea162a 100644
--- a/unsupported/test/CMakeLists.txt
+++ b/unsupported/test/CMakeLists.txt
@@ -140,6 +140,12 @@ endif()
endif()
if(EIGEN_TEST_CXX11)
+ if(EIGEN_TEST_SYCL)
+ ei_add_test_sycl(cxx11_tensor_sycl "-std=c++11")
+ ei_add_test_sycl(cxx11_tensor_forced_eval_sycl "-std=c++11")
+ ei_add_test_sycl(cxx11_tensor_broadcast_sycl "-std=c++11")
+ ei_add_test_sycl(cxx11_tensor_device_sycl "-std=c++11")
+ endif(EIGEN_TEST_SYCL)
# It should be safe to always run these tests as there is some fallback code for
# older compiler that don't support cxx11.
set(CMAKE_CXX_STANDARD 11)
@@ -248,11 +254,3 @@ if(CUDA_FOUND AND EIGEN_TEST_CUDA)
unset(EIGEN_ADD_TEST_FILENAME_EXTENSION)
endif()
-
-
-if(EIGEN_TEST_SYCL)
- ei_add_test_sycl(cxx11_tensor_sycl "-std=c++11")
- ei_add_test_sycl(cxx11_tensor_forced_eval_sycl "-std=c++11")
- ei_add_test_sycl(cxx11_tensor_broadcast_sycl "-std=c++11")
- ei_add_test_sycl(cxx11_tensor_device_sycl "-std=c++11")
-endif(EIGEN_TEST_SYCL) \ No newline at end of file
diff --git a/unsupported/test/cxx11_tensor_broadcast_sycl.cpp b/unsupported/test/cxx11_tensor_broadcast_sycl.cpp
index 0179ab243..ecebf7d68 100644
--- a/unsupported/test/cxx11_tensor_broadcast_sycl.cpp
+++ b/unsupported/test/cxx11_tensor_broadcast_sycl.cpp
@@ -28,7 +28,7 @@ using Eigen::TensorMap;
// Types used in tests:
using TestTensor = Tensor<float, 3>;
using TestTensorMap = TensorMap<Tensor<float, 3>>;
-static void test_sycl_broadcast(){
+static void test_broadcast_sycl(){
cl::sycl::gpu_selector s;
cl::sycl::queue q(s, [=](cl::sycl::exception_list l) {
@@ -75,5 +75,5 @@ static void test_sycl_broadcast(){
}
void test_cxx11_tensor_broadcast_sycl() {
- CALL_SUBTEST(test_sycl_broadcast());
+ CALL_SUBTEST(test_broadcast_sycl());
}
diff --git a/unsupported/test/cxx11_tensor_device_sycl.cpp b/unsupported/test/cxx11_tensor_device_sycl.cpp
index b9368cb84..f54fc8786 100644
--- a/unsupported/test/cxx11_tensor_device_sycl.cpp
+++ b/unsupported/test/cxx11_tensor_device_sycl.cpp
@@ -20,7 +20,7 @@
#include "main.h"
#include <unsupported/Eigen/CXX11/Tensor>
-void test_sycl_device() {
+void test_device_sycl() {
cl::sycl::gpu_selector s;
cl::sycl::queue q(s, [=](cl::sycl::exception_list l) {
for (const auto& e : l) {
@@ -31,9 +31,9 @@ void test_sycl_device() {
}
}
});
- SyclDevice sycl_device(q);
+ Eigen::SyclDevice sycl_device(q);
printf("Helo from ComputeCpp: Device Exists\n");
}
void test_cxx11_tensor_device_sycl() {
- CALL_SUBTEST(test_sycl_device());
+ CALL_SUBTEST(test_device_sycl());
}
diff --git a/unsupported/test/cxx11_tensor_forced_eval_sycl.cpp b/unsupported/test/cxx11_tensor_forced_eval_sycl.cpp
index 7c4446192..182ec7fa8 100644
--- a/unsupported/test/cxx11_tensor_forced_eval_sycl.cpp
+++ b/unsupported/test/cxx11_tensor_forced_eval_sycl.cpp
@@ -22,7 +22,7 @@
using Eigen::Tensor;
-void test_sycl_gpu() {
+void test_forced_eval_sycl() {
cl::sycl::gpu_selector s;
cl::sycl::queue q(s, [=](cl::sycl::exception_list l) {
for (const auto& e : l) {
@@ -65,6 +65,4 @@ void test_sycl_gpu() {
printf("(a+b)*b Test Passed\n");
}
-void test_cxx11_tensor_forced_eval_sycl() {
- CALL_SUBTEST(test_sycl_gpu());
-}
+void test_cxx11_tensor_forced_eval_sycl() { CALL_SUBTEST(test_forced_eval_sycl()); }
diff --git a/unsupported/test/cxx11_tensor_sycl.cpp b/unsupported/test/cxx11_tensor_sycl.cpp
index a4dc9f9fa..0f66cd8f0 100644
--- a/unsupported/test/cxx11_tensor_sycl.cpp
+++ b/unsupported/test/cxx11_tensor_sycl.cpp
@@ -6,11 +6,13 @@
// Ralph Potter Codeplay Software Ltd.
// Luke Iwanski Codeplay Software Ltd.
// Contact: <eigen@codeplay.com>
+// Benoit Steiner <benoit.steiner.goog@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
#define EIGEN_TEST_NO_LONGDOUBLE
#define EIGEN_TEST_NO_COMPLEX
#define EIGEN_TEST_FUNC cxx11_tensor_sycl
@@ -30,7 +32,7 @@ using TestTensor = Tensor<float, 3>;
using TestTensorMap = TensorMap<Tensor<float, 3>>;
void test_sycl_cpu() {
- cl::sycl::gpu_selector s;
+ cl::sycl::gpu_selector s;
cl::sycl::queue q(s, [=](cl::sycl::exception_list l) {
for (const auto& e : l) {
try {
@@ -40,7 +42,7 @@ void test_sycl_cpu() {
}
}
});
- SyclDevice sycl_device(q);
+ SyclDevice sycl_device(q);
int sizeDim1 = 100;
int sizeDim2 = 100;
@@ -53,14 +55,14 @@ void test_sycl_cpu() {
in1 = in1.random();
in2 = in2.random();
in3 = in3.random();
- TestTensorMap gpu_in1(in1.data(), tensorRange);
- TestTensorMap gpu_in2(in2.data(), tensorRange);
- TestTensorMap gpu_in3(in3.data(), tensorRange);
- TestTensorMap gpu_out(out.data(), tensorRange);
-
- /// a=1.2f
- gpu_in1.device(sycl_device) = gpu_in1.constant(1.2f);
- sycl_device.deallocate(in1.data());
+ TestTensorMap gpu_in1(in1.data(), tensorRange);
+ TestTensorMap gpu_in2(in2.data(), tensorRange);
+ TestTensorMap gpu_in3(in3.data(), tensorRange);
+ TestTensorMap gpu_out(out.data(), tensorRange);
+
+ /// a=1.2f
+ gpu_in1.device(sycl_device) = gpu_in1.constant(1.2f);
+ sycl_device.deallocate(in1.data());
for (int i = 0; i < sizeDim1; ++i) {
for (int j = 0; j < sizeDim2; ++j) {
for (int k = 0; k < sizeDim3; ++k) {
@@ -68,11 +70,11 @@ void test_sycl_cpu() {
}
}
}
- printf("a=1.2f Test passed\n");
+ printf("a=1.2f Test passed\n");
- /// a=b*1.2f
- gpu_out.device(sycl_device) = gpu_in1 * 1.2f;
- sycl_device.deallocate(out.data());
+ /// a=b*1.2f
+ gpu_out.device(sycl_device) = gpu_in1 * 1.2f;
+ sycl_device.deallocate(out.data());
for (int i = 0; i < sizeDim1; ++i) {
for (int j = 0; j < sizeDim2; ++j) {
for (int k = 0; k < sizeDim3; ++k) {
@@ -81,11 +83,11 @@ void test_sycl_cpu() {
}
}
}
- printf("a=b*1.2f Test Passed\n");
+ printf("a=b*1.2f Test Passed\n");
- /// c=a*b
- gpu_out.device(sycl_device) = gpu_in1 * gpu_in2;
- sycl_device.deallocate(out.data());
+ /// c=a*b
+ gpu_out.device(sycl_device) = gpu_in1 * gpu_in2;
+ sycl_device.deallocate(out.data());
for (int i = 0; i < sizeDim1; ++i) {
for (int j = 0; j < sizeDim2; ++j) {
for (int k = 0; k < sizeDim3; ++k) {
@@ -95,11 +97,11 @@ void test_sycl_cpu() {
}
}
}
- printf("c=a*b Test Passed\n");
+ printf("c=a*b Test Passed\n");
- /// c=a+b
- gpu_out.device(sycl_device) = gpu_in1 + gpu_in2;
- sycl_device.deallocate(out.data());
+ /// c=a+b
+ gpu_out.device(sycl_device) = gpu_in1 + gpu_in2;
+ sycl_device.deallocate(out.data());
for (int i = 0; i < sizeDim1; ++i) {
for (int j = 0; j < sizeDim2; ++j) {
for (int k = 0; k < sizeDim3; ++k) {
@@ -109,11 +111,11 @@ void test_sycl_cpu() {
}
}
}
- printf("c=a+b Test Passed\n");
+ printf("c=a+b Test Passed\n");
- /// c=a*a
- gpu_out.device(sycl_device) = gpu_in1 * gpu_in1;
- sycl_device.deallocate(out.data());
+ /// c=a*a
+ gpu_out.device(sycl_device) = gpu_in1 * gpu_in1;
+ sycl_device.deallocate(out.data());
for (int i = 0; i < sizeDim1; ++i) {
for (int j = 0; j < sizeDim2; ++j) {
for (int k = 0; k < sizeDim3; ++k) {
@@ -124,11 +126,11 @@ void test_sycl_cpu() {
}
}
- printf("c= a*a Test Passed\n");
+ printf("c= a*a Test Passed\n");
- //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.deallocate(out.data());
+ //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.deallocate(out.data());
for (int i = 0; i < sizeDim1; ++i) {
for (int j = 0; j < sizeDim2; ++j) {
for (int k = 0; k < sizeDim3; ++k) {
@@ -138,21 +140,21 @@ void test_sycl_cpu() {
}
}
}
- printf("a*3.14f + b*2.7f Test Passed\n");
-
- ///d= (a>0.5? b:c)
- gpu_out.device(sycl_device) =(gpu_in1 > gpu_in1.constant(0.5f)).select(gpu_in2, gpu_in3);
- sycl_device.deallocate(out.data());
- for (int i = 0; i < sizeDim1; ++i) {
- for (int j = 0; j < sizeDim2; ++j) {
- for (int k = 0; k < sizeDim3; ++k) {
- VERIFY_IS_APPROX(out(i, j, k), (in1(i, j, k) > 0.5f)
- ? in2(i, j, k)
- : in3(i, j, k));
- }
- }
- }
- printf("d= (a>0.5? b:c) Test Passed\n");
+ printf("a*3.14f + b*2.7f Test Passed\n");
+
+ ///d= (a>0.5? b:c)
+ gpu_out.device(sycl_device) =(gpu_in1 > gpu_in1.constant(0.5f)).select(gpu_in2, gpu_in3);
+ sycl_device.deallocate(out.data());
+ for (int i = 0; i < sizeDim1; ++i) {
+ for (int j = 0; j < sizeDim2; ++j) {
+ for (int k = 0; k < sizeDim3; ++k) {
+ VERIFY_IS_APPROX(out(i, j, k), (in1(i, j, k) > 0.5f)
+ ? in2(i, j, k)
+ : in3(i, j, k));
+ }
+ }
+ }
+ printf("d= (a>0.5? b:c) Test Passed\n");
}
void test_cxx11_tensor_sycl() {