I am trying to implement a simple vector addition example on SYCL with visual studio. It builds successfully but on execution it gives me SYCL objects are still alive while the runtime is shutting down.. What does it mean and how can i solve it, following is the example code. Thanks in advance
#include <CL/sycl.hpp>
using namespace cl::sycl;
#include <vector>
using std::vector;
vector<int> add_vectors(const vector<int>& a, const vector<int>& b);
int main() {
vector<int> a{ 1, 2, 3, 4, 5 };
vector<int> b{ 6, 7, 8, 9, 10 };
auto c = add_vectors(a, b);
return 0;
}
vector<int> add_vectors(const vector<int>& a, const vector<int>& b) {
const auto N = a.size();
buffer<int, 1> bufA(a.data(), range<1>{N});
buffer<int, 1> bufB(b.data(), range<1>{N});
vector<int> c(N);
buffer<int, 1> bufC(c.data(), range<1>{N});
queue myQueue;
myQueue.submit([&](handler& cgh) {
auto A = bufA.get_access<access::mode::read>(cgh);
auto B = bufB.get_access<access::mode::read>(cgh);
auto C = bufC.get_access<access::mode::write>(cgh);
cgh.parallel_for<class add>(
range<1>{N},
[=](id<1> i) {
C[i] = A[i] + B[i];
}
);
});
return c;
}