Commit 294a30fd authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Check that all execution objects are trivially copyable

When the dispatcher does it's "transport" phase, it returns an
"execution object", but this object is held in the control environment
(on the host) although it may point to resources in the execution
environment (on the device). For this object to get from host to device,
it must be trivially copyable. If it is not, compile and/or runtime
errors could occur. So force this condition with a static assert.
parent bd5b84fa
......@@ -32,6 +32,8 @@
#include <vtkm/worklet/internal/WorkletBase.h>
#include <vtkmstd/is_trivial.h>
#include <sstream>
namespace vtkm
......@@ -316,6 +318,14 @@ struct DispatcherBaseTransportFunctor
using T = vtkm::internal::remove_pointer_and_decay<ControlParameter>;
using TransportType = typename vtkm::cont::arg::Transport<TransportTag, T, Device>;
using type = typename std::decay<typename TransportType::ExecObjectType>::type;
// If you get a compile error here, it means that an execution object type is not
// trivially copyable. This is strictly disallowed. All execution objects must be
// trivially copyable so that the can be memcpy-ed between host and devices.
// Note that it is still legal for execution objects to have pointers or other
// references to resources on a particular device. It is up to the generating code
// to ensure that all referenced resources are valid on the target device.
template <typename ControlParameter, vtkm::IdComponent Index>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment