Merged ComputeCpp into default.

This commit is contained in:
Luke Iwanski
2016-10-14 13:36:51 +01:00
17 changed files with 755 additions and 1911 deletions

View File

@@ -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)

View File

@@ -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());
}

View File

@@ -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());
}

View File

@@ -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()); }

View File

@@ -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);
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());
/// 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");
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");
///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() {