11 using DataType = float;
15 auto devices = Eigen::get_sycl_supported_devices();
16 const auto device_selector = *devices.begin();
17 Eigen::QueueInterface queueInterface(device_selector);
18 auto sycl_device = Eigen::SyclDevice(&queueInterface);
21 IndexType sizeDim1 = 3;
22 IndexType sizeDim2 = 3;
23 IndexType sizeDim3 = 3;
24 array<IndexType, 3> tensorRange = {{sizeDim1, sizeDim2, sizeDim3}};
36 DataType* gpu_in1_data =
static_cast<DataType*
>(sycl_device.allocate(in1.size() *
sizeof(DataType)));
37 DataType* gpu_in2_data =
static_cast<DataType*
>(sycl_device.allocate(in2.size() *
sizeof(DataType)));
38 DataType* gpu_out_data =
static_cast<DataType*
>(sycl_device.allocate(
out.size() *
sizeof(DataType)));
46 sycl_device.memcpyHostToDevice(gpu_in1_data, in1.data(), (in1.size()) *
sizeof(DataType));
47 sycl_device.memcpyHostToDevice(gpu_in2_data, in2.data(), (in2.size()) *
sizeof(DataType));
48 gpu_out.device(sycl_device) = gpu_in1 * gpu_in2;
49 sycl_device.memcpyDeviceToHost(
out.data(), gpu_out_data, (
out.size()) *
sizeof(DataType));
50 sycl_device.synchronize();
53 for (IndexType
i = 0;
i < sizeDim1; ++
i) {
54 for (IndexType
j = 0;
j < sizeDim2; ++
j) {
55 for (IndexType
k = 0;
k < sizeDim3; ++
k) {
56 std::cout <<
"device_out"
57 <<
"(" <<
i <<
", " <<
j <<
", " <<
k <<
") : " <<
out(
i,
j,
k) <<
" vs host_out"
58 <<
"(" <<
i <<
", " <<
j <<
", " <<
k <<
") : " << in1(
i,
j,
k) * in2(
i,
j,
k) <<
"\n";
62 printf(
"c=a*b Done\n");
int i
Definition: BiCGSTAB_step_by_step.cpp:9
A tensor expression mapping an existing array of data.
Definition: TensorMap.h:33
The tensor class.
Definition: Tensor.h:68
static const int DataLayout
Definition: cxx11_tensor_image_patch_sycl.cpp:24
@ RowMajor
Definition: Constants.h:320
char char char int int * k
Definition: level2_impl.h:374
std::int64_t int64_t
Definition: Meta.h:43
std::ofstream out("Result.txt")
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2