Fixed an issue with copying array from a disabled device

The internal array copy has an optimization to use the device the array
exists on to do the copy. However, if that device is disabled the copy
would fail. This problem has been fixed.
This commit is contained in:
Kenneth Moreland 2023-05-29 20:55:48 -04:00
parent 61f123be22
commit b6e61f9447
3 changed files with 25 additions and 1 deletions

@ -0,0 +1,5 @@
# Fix an issue with copying array from a disabled device
The internal array copy has an optimization to use the device the array
exists on to do the copy. However, if that device is disabled the copy
would fail. This problem has been fixed.

@ -52,7 +52,8 @@ struct UnknownCopyOnDevice
// by pulling out one of the component arrays and querying that.
if (!this->Called &&
((device == vtkm::cont::DeviceAdapterTagAny{}) ||
(in.GetComponentArray(0).IsOnDevice(device))))
(in.GetComponentArray(0).IsOnDevice(device) &&
vtkm::cont::GetRuntimeDeviceTracker().CanRunOn(device))))
{
vtkm::cont::Invoker invoke(device);
invoke(CopyWorklet{}, in, out);

@ -199,6 +199,24 @@ void TryCopy()
TestValues(input, output);
}
{
std::cout << "unknown -> basic (different type, unsupported device)" << std::endl;
// Force the source to be on the Serial device. If the --vtkm-device argument was
// given with a different device (which is how ctest is set up if compiled with
// any device), then Serial will be turned off.
using SourceType = typename VTraits::template ReplaceComponentType<vtkm::UInt8>;
auto rawInput = MakeInputArray<SourceType>();
{
// Force moving the data to the Serial device.
vtkm::cont::Token token;
rawInput.PrepareForInput(vtkm::cont::DeviceAdapterTagSerial{}, token);
}
vtkm::cont::UnknownArrayHandle input = rawInput;
vtkm::cont::ArrayHandle<ValueType> output;
vtkm::cont::ArrayCopy(input, output);
TestValues(input, output);
}
// Test the copy methods in UnknownArrayHandle. Although this would be appropriate in
// UnitTestUnknownArrayHandle, it is easier to test copies here.
{