mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-30 17:40:05 +08:00
Fixed the cxx11_tensor_device_sycl test
This commit is contained in:
parent
15e226d7d3
commit
7335c49204
@ -19,12 +19,14 @@
|
||||
|
||||
#include "main.h"
|
||||
#include <unsupported/Eigen/CXX11/Tensor>
|
||||
#include<stdint.h>
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
|
||||
template <typename DataType, int DataLayout>
|
||||
void test_device_sycl(const Eigen::SyclDevice &sycl_device) {
|
||||
std::cout <<"Hello from ComputeCpp: the requested device exists and the device name is : "
|
||||
<< sycl_device.sycl_queue().get_device(). template get_info<cl::sycl::info::device::name>() <<std::endl;
|
||||
void test_device_memory(const Eigen::SyclDevice &sycl_device) {
|
||||
std::cout << "Running on : "
|
||||
<< sycl_device.sycl_queue().get_device(). template get_info<cl::sycl::info::device::name>()
|
||||
<<std::endl;
|
||||
int sizeDim1 = 100;
|
||||
array<int, 1> tensorRange = {{sizeDim1}};
|
||||
Tensor<DataType, 1, DataLayout> in(tensorRange);
|
||||
@ -34,7 +36,7 @@ void test_device_sycl(const Eigen::SyclDevice &sycl_device) {
|
||||
sycl_device.memset(gpu_in_data, 1,in.size()*sizeof(DataType) );
|
||||
sycl_device.memcpyDeviceToHost(in.data(), gpu_in_data, in.size()*sizeof(DataType) );
|
||||
for (int i=0; i<in.size(); i++) {
|
||||
VERIFY_IS_APPROX(in(i), in1(i));
|
||||
VERIFY_IS_EQUAL(in(i), in1(i));
|
||||
}
|
||||
sycl_device.deallocate(gpu_in_data);
|
||||
}
|
||||
@ -56,20 +58,19 @@ void test_device_exceptions(const Eigen::SyclDevice &sycl_device) {
|
||||
template<typename DataType, typename dev_Selector> void sycl_device_test_per_device(dev_Selector s){
|
||||
QueueInterface queueInterface(s);
|
||||
auto sycl_device = Eigen::SyclDevice(&queueInterface);
|
||||
test_device_sycl<DataType, RowMajor>(sycl_device);
|
||||
test_device_sycl<DataType, ColMajor>(sycl_device);
|
||||
/// this test throw an exeption. enable it if you want to see the exception
|
||||
// test_device_exceptions<DataType, RowMajor>(sycl_device);
|
||||
/// this test throw an exeption. enable it if you want to see the exception
|
||||
// test_device_exceptions<DataType, ColMajor>(sycl_device);
|
||||
|
||||
test_device_memory<DataType, RowMajor>(sycl_device);
|
||||
test_device_memory<DataType, ColMajor>(sycl_device);
|
||||
/// this test throw an exception. enable it if you want to see the exception
|
||||
//test_device_exceptions<DataType, RowMajor>(sycl_device);
|
||||
/// this test throw an exception. enable it if you want to see the exception
|
||||
//test_device_exceptions<DataType, ColMajor>(sycl_device);
|
||||
}
|
||||
|
||||
void test_cxx11_tensor_device_sycl() {
|
||||
printf("Test on GPU: OpenCL\n");
|
||||
CALL_SUBTEST(sycl_device_test_per_device<int>((cl::sycl::gpu_selector())));
|
||||
printf("repeating the test on CPU: OpenCL\n");
|
||||
CALL_SUBTEST(sycl_device_test_per_device<int>((cl::sycl::cpu_selector())));
|
||||
// printf("repeating the test on CPU: OpenCL\n");
|
||||
// CALL_SUBTEST(sycl_device_test_per_device<int>((cl::sycl::cpu_selector())));
|
||||
printf("repeating the test on CPU: HOST\n");
|
||||
CALL_SUBTEST(sycl_device_test_per_device<int>((cl::sycl::host_selector())));
|
||||
printf("Test Passed******************\n" );
|
||||
|
Loading…
Reference in New Issue
Block a user