title: triSYCL throws non_cl_error, when tricycle::device::~device is called
body: <p>I'm trying to run a parallel for loop with triSYCL. This is my code:</p>
  <pre><code>#define TRISYCL_OPENCL
  #define OMP_NUM_THREADS 8
  #define BOOST_COMPUTE_USE_CPP11
  
  //standart libraries
  #include &lt;iostream&gt;
  #include &lt;functional&gt;
  
  //deps
  #include &quot;CL/sycl.hpp&quot;
  
  struct Color
  {
      float r, g, b, a;
  
      friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const Color&amp; c)
      {
          os &lt;&lt; &quot;(&quot; &lt;&lt; c.r &lt;&lt; &quot;, &quot; &lt;&lt; c.g &lt;&lt; &quot;, &quot; &lt;&lt; c.b &lt;&lt; &quot;, &quot; &lt;&lt; c.a &lt;&lt; &quot;)&quot;;
          return os;
      }
  };
  
  struct Vertex
  {
      float x, y;
      Color color;
  
      friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const Vertex&amp; v)
      {
          os &lt;&lt; &quot;x: &quot; &lt;&lt; v.x &lt;&lt; &quot;, y: &quot; &lt;&lt; v.y &lt;&lt; &quot;, color: &quot; &lt;&lt; v.color;
          return os;
      }
  };
  
  template&lt;typename T&gt;
  T mapNumber(T x, T a, T b, T c, T d)
  {
      return (x - a) / (b - a) * (d - c) + c;
  }
  
  int windowWidth = 640;
  int windowHeight = 720;
  
  int main()
  {
      auto exception_handler = [](cl::sycl::exception_list exceptions) {
          for (std::exception_ptr const&amp; e : exceptions)
          {
              try
              {
                  std::rethrow_exception(e);
              } catch (cl::sycl::exception const&amp; e)
              {
                  std::cout &lt;&lt; &quot;Caught asynchronous SYCL exception: &quot; &lt;&lt; e.what() &lt;&lt; std::endl;
              }
          }
      };
  
      cl::sycl::default_selector defaultSelector;
      cl::sycl::context context(defaultSelector, exception_handler);
      cl::sycl::queue queue(context, defaultSelector, exception_handler);
  
          auto* pixelColors = new Color[windowWidth * windowHeight];
          {
              cl::sycl::buffer&lt;Color, 2&gt; color_buffer(pixelColors, cl::sycl::range &lt; 2 &gt; {(unsigned long) windowWidth,
                                                                                          (unsigned long) windowHeight});
  
              cl::sycl::buffer&lt;int, 1&gt; b_windowWidth(&amp;windowWidth, cl::sycl::range &lt; 1 &gt; {1});
              cl::sycl::buffer&lt;int, 1&gt; b_windowHeight(&amp;windowHeight, cl::sycl::range &lt; 1 &gt; {1});
  
              queue.submit([&amp;](cl::sycl::handler&amp; cgh) {
                  auto color_buffer_acc = color_buffer.get_access&lt;cl::sycl::access::mode::write&gt;(cgh);
                  auto width_buffer_acc = b_windowWidth.get_access&lt;cl::sycl::access::mode::read&gt;(cgh);
                  auto height_buffer_acc = b_windowHeight.get_access&lt;cl::sycl::access::mode::read&gt;(cgh);
  
                  cgh.parallel_for&lt;class init_pixelColors&gt;(
                          cl::sycl::range&lt;2&gt;((unsigned long) width_buffer_acc[0], (unsigned long) height_buffer_acc[0]),
                          [=](cl::sycl::id&lt;2&gt; index) {
                              color_buffer_acc[index[0]][index[1]] = {
                                      mapNumber&lt;float&gt;(index[0], 0.f, width_buffer_acc[0], 0.f, 1.f),
                                      mapNumber&lt;float&gt;(index[1], 0.f, height_buffer_acc[0], 0.f, 1.f),
                                      0.f,
                                      1.f};
                          });
              });
  
              std::cout &lt;&lt; &quot;cl::sycl::queue check - selected device: &quot;
                        &lt;&lt; queue.get_device().get_info&lt;cl::sycl::info::device::name&gt;() &lt;&lt; std::endl;
          }//here the error appears 
  
          delete[] pixelColors;
      return 0;
  }
  </code></pre>
  <p>I'm building it with this CMakeLists.txt file:</p>
  <pre><code>cmake_minimum_required(VERSION 3.16.2)
  
  project(acMandelbrotSet_stackoverflow)
  
  set(CMAKE_CXX_STANDARD 17)
  
  set(SRC_FILES
          path/to/main.cpp
          )
  find_package(OpenCL REQUIRED)
  
  set(Boost_INCLUDE_DIR path/to/boost)
  include_directories(${Boost_INCLUDE_DIR})
  
  include_directories(path/to/SYCL/include)
  
  set(LIBS PRIVATE ${Boost_LIBRARIES} OpenCL::OpenCL)
  
  
  add_executable(${PROJECT_NAME} ${SRC_FILES})
  
  set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX _d)
  target_link_libraries(${PROJECT_NAME} ${LIBS})
  </code></pre>
  <p>When I try to run it, I get this message: <code>libc++abi.dylib: terminating with uncaught exception of type trisycl::non_cl_error</code> from path/to/SYCL/include/triSYCL/command_group/detail/task.hpp line: 278 function: <code>trisycl::detail::task::get_kernel</code>, the message was: &quot;Cannot use an OpenCL kernel in this context&quot;.</p>
  <p>I've tried to create a lambda of <code>mapNumber</code> in the kernel but that didn't make any difference. I've also tried to use this before the end of the scope to catch errors:</p>
  <pre><code>try
  {
      queue.wait_and_throw();
  } catch (cl::sycl::exception const&amp; e)
  {
      std::cout &lt;&lt; &quot;Caught synchronous SYCL exception: &quot; &lt;&lt; e.what() &lt;&lt; std::endl;
  }
  </code></pre>
  <p>but nothing was printed to the console except the error from before. And I've also tried to make an event of the <code>queue.submit</code> call and then call <code>event.wait()</code> before the end of the scope but again the exact same output.</p>
  <p>Does any body have an idea what else I could try?</p>