CellSet / CoordinateSystem / ArrayHandles and thread safety
Issue
Currently VTK-m design with ArrayHandle
is to allow for thread safe allocation and destruction of memory. This works as designed when using VTK-m in a threaded manner. The outstanding issues are that moving any ArrayHandle
or ArrayHandle
based class to a device is not thread safe; it is not safe for multiple threads to use an ArrayHandle
concurrently on the same device if one or more threads are writing to the ArrayHandle
; it is not safe for multiple threads to use the same ArrayHandle
on different devices.
Why it matters
Obviously the solution is to not write code that uses the same ArrayHandle
from multiple threads! This is actually more complex of a process than one initial expects.
The complications arise in the following situations:
-
You have no way as a vtkm::filter or user to verify that two
vtkm::cont::Field
point to the sameArrayHandle
-
vtkm::cont::DataSet
can sharevtkm::cont::CoordinateSystem
andvtkm::cont::CellSet
with othervtkm::cont::DataSet
instances. This is very common when dealing with filters as they copy input data, and is a specific use case withvtkm::cont::MultiBlock
Possible solutions
to be determined.