0

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;

}
ZSA
  • 85
  • 1
  • 13
  • We tried the code and it works without error. When you see this error it can often be where the application has seg faulted for some reason and so cleanup didn't happen properly. It's possible this is happening in the OpenCL driver. What hardware and OpenCL drivers are you using? – Rod Burns Jul 01 '19 at 15:13
  • My system specs are Intel Core(TM) i7-7700HQ @ 2.80Ghz, Intel HD Graphics 630 and Nvidia GTX 1050 – ZSA Jul 01 '19 at 15:31
  • I have installed intel SDK for OpenCL 2019 https://software.intel.com/en-us/opencl-sdk/choose-download – ZSA Jul 01 '19 at 15:32
  • If there is some other drivers that i need to install then kindly post a link. It will be very helpful for me. thanks – ZSA Jul 01 '19 at 15:33
  • Are you targetting SPIR for Intel or PTX for NVIDIA though? Can you try what I suggested in the answer and see if you can catch any errors? – Rod Burns Jul 01 '19 at 15:35
  • I am targetting SPIR for intel and i will work on your suggestion. Thanks – ZSA Jul 01 '19 at 15:38

1 Answers1

0

It's possible to write SYCL code that includes error and exception handling. There is a guide on the ComputeCpp developer website. Additionally using gdb to gather a backtrace may offer some clues as to where things are going wrong.

In this case the code executes successfully for us, so the problem is most likely in the OpenCL drivers.

Rod Burns
  • 2,104
  • 13
  • 24