I’m using the open source intel/LLVM sycl compiler on Linux and I have successfully worked with a sycl buffer of std::variant
’s on device code, but I have not been successful in using std::visit
on a variant object in device code. In particular, if I try std::visit(visitor, vars);
in kernel code, I get an error: SYCL kernel cannot use exceptions. I suppose this is because std::visit
can throw a bad_variant_access
.
: Is there a workaround to std functions that throw exceptions? Is my compiler messed up? Is this functionality implemented in a library (oneapi/DPL
)?
In fact, the khronos blog post : ‘sycl-2020-what-do-you-need-to-know’ suggests CRTP for dynamic polymorphism, (I don’t think the author of that blog post knew what dynamic polymorphism was…) or “or you can use for example some C++17 std::variant
with std::visit
” leading me to believe that std::visit
is allowed in kernel code.