Add an AllocateAndFill method to ArrayHandle
It is common to need to allocate an ArrayHandle
and initialize the array to a particular fill value. Thus, it would be helpful to have a new method named something like AllocateAndFill
, which fills the array with a given value.
It should be noted that the implementation of such an array is not straightforward. The method must have the following features.
CopyFlag
Support a A use case for this method is to grow an array and fill the expanded part with an initial value. AllocateAndFill
should take 3 arguments: the new size (in values), the fill value, and a vtkm::CopyFlag
. If the last argument is CopyFlag::Off
, then the array is cleared out to the new value. If the last argument is CopyFlag::On
, then if the array gets larger the new entries will be initialized to the given fill value.
Set on device
The array should be filled efficiently on a device. If the CopyFlag
is On
and data originally existed on a device, then the fill should happen where the data already are. Otherwise, the fill should happen on the "best" device.
ArrayHandle.h
depend on device code
Do not make We have worked very hard to allow code to include ArrayHandle.h
without having to use a device compiler. This means that all device code has been removed from this header file. Thus, the filling of the array on a device has to be done without adding this dependency back. This means that the filling will likely have to happen inside the Buffer
object. The fill value will have to be converted to a short array of bytes and then passed to a library method in Buffer
.