Search code examples
sycl

Is it better to pass a sycl::vec by value or by reference?


In Sycl,if I want to pass a sycl::vec<double 3> to another function, is it better to pass it by value or by const reference?

How can I see the output of the target code? Is there something like compiler explorer for sycl cuda? (I'm using the Intell Clang / DPC++ compiler)


Solution

  • Generally the best practice in C++ has been to pass cheap copied types by value and other types by const reference. The idea being that the compiler can optimize more if passed by value, but larger types can be expensive to copy if not passed by reference. I think for the vec class it should be fine to copy by value as (on the device side at least) it's treated as a built-in type.