ArrayHandleBasicImpl should not toy with execution environment pointers
The implementation of ArrayHandleBasicImpl::GetNumberOfValues
uses the following code if the control array is not valid and the execution array is valid.
auto numBytes =
static_cast<char*>(this->ExecutionArrayEnd) - static_cast<char*>(this->ExecutionArray);
return static_cast<vtkm::Id>(numBytes) / static_cast<vtkm::Id>(sizeOfT);
The problem is that this code is assuming that pointers in the execution environment will work the same as in the execution environment. However, this is not necessarily always the case. For example, this will not work with pointers from OpenMP's omp_target_alloc
.
Instead, the number of values should be retrieved from the ArrayHandleExecutionManagerBase
, which is specifically designed to manage data in the execution environment.