Hello everyone,
I’m changing into de SYCL world, but I’ve been having some compiling issues that are making me think to return to traditional OpenCL.
I tried with this code:
#include <iostream>
#include <CL/sycl.hpp>
class vector_addition;
int main(int, char**) {
try
{
cl::sycl::float4 a = { 1.0, 2.0, 3.0, 4.0 };
cl::sycl::float4 b = { 4.0, 3.0, 2.0, 1.0 };
cl::sycl::float4 c = { 0.0, 0.0, 0.0, 0.0 };
cl::sycl::default_selector device_selector;
cl::sycl::queue queue(device_selector);
std::cout << "Running on "
<< queue.get_device().get_info<cl::sycl::info::device::name>()
<< "\n";
{
cl::sycl::buffer<cl::sycl::float4, 1> a_sycl(&a, cl::sycl::range<1>(1));
cl::sycl::buffer<cl::sycl::float4, 1> b_sycl(&b, cl::sycl::range<1>(1));
cl::sycl::buffer<cl::sycl::float4, 1> c_sycl(&c, cl::sycl::range<1>(1));
queue.submit([&] (cl::sycl::handler& cgh) {
auto a_acc = a_sycl.get_access<cl::sycl::access::mode::read>(cgh);
auto b_acc = b_sycl.get_access<cl::sycl::access::mode::read>(cgh);
auto c_acc = c_sycl.get_access<cl::sycl::access::mode::discard_write>(cgh);
cgh.single_task<class vector_addition>([=] () {
c_acc[0] = a_acc[0] + b_acc[0];
});
});
}
std::cout << " A { " << a.x() << ", " << a.y() << ", " << a.z() << ", " << a.w() << " }\n"
<< "+ B { " << b.x() << ", " << b.y() << ", " << b.z() << ", " << b.w() << " }\n"
<< "------------------\n"
<< "= C { " << c.x() << ", " << c.y() << ", " << c.z() << ", " << c.w() << " }"
<< std::endl;
}
catch(std::exception& ex)
{
std::cerr << "exception caught: " << ex.what() << std::endl;
return 1;
}
return 0;
}
and I compiled with:
/usr/local/computecpp/bin/compute++ hello_world.cpp -o HELLO_SYCL -I /usr/local/computecpp/include -lOpenCL -L /usr/local/computecpp/lib/ -lComputeCpp
And I obtained:
Running on GeForce GTX 1060 with Max-Q Design
terminate called after throwing an instance of ‘cl::sycl::invalid_object_error’
Aborted (core dumped)
I noticed that the code recongnized my graphic card. I read some about Bitcode targets, would it be my issue?
I need to say that I couldn’t run the samples of the github page either
Thanks!