Commit Graph

9 Commits

Author SHA1 Message Date
Kenneth Moreland
ac889b5004 Implement VecTraits class for all types
The `VecTraits` class allows templated functions, methods, and classes to
treat type arguments uniformly as `Vec` types or to otherwise differentiate
between scalar and vector types. This only works for types that `VecTraits`
is defined for.

The `VecTraits` templated class now has a default implementation that will
be used for any type that does not have a `VecTraits` specialization. This
removes many surprise compiler errors when using a template that, unknown
to you, has `VecTraits` in its implementation.

One potential issue is that if `VecTraits` gets defined for a new type, the
behavior of `VecTraits` could change for that type in backward-incompatible
ways. If `VecTraits` is used in a purely generic way, this should not be an
issue. However, if assumptions were made about the components and length,
this could cause problems.

Fixes #589
2023-03-16 12:59:38 -06:00
Kenneth Moreland
5b34e6f70b Better fallback for ArrayGetValue
To avoid having to use a device compiler every time you wish to use
`ArrayGetValue`, the actual implementation is compiled into the `vtkm_cont`
library. To allow this to work for all the templated versions of
`ArrayHandle`, the implementation uses the extract component features of
`UnknownArrayHandle`. This works for most common arrays, but not all
arrays.

For arrays that cannot be directly represented by an `ArrayHandleStride`,
the fallback is bad. The entire array has to be pulled to the host and then
copied serially to a basic array.

For `ArrayGetValue`, this is just silly. So, for arrays that cannot be
simply represented by `ArrayHandleStride`, make a fallback that just uses
`ReadPortal` to get the data. Often this is not the most efficient method,
but it is better than the current alternative.
2022-01-03 10:08:39 -07:00
Sujin Philip
4a37e02ffe Add ArrayGetValues specilization for ArrayHandleCast
ArrayGetValues for ArrayHandleCast needs to be handled specially as an
`UnknownArrayHandle::IsBaseComponentType` check inside the implementation
gives unexpected results for ArrayHandleCast.

With this fix, the values are first copied from the source array type and
then casted to the appropriate type before returning.
2021-11-08 14:37:49 -05:00
Kenneth Moreland
c17a5569f5 Do not try to use ArrayGetValue on arrays of non-basic types
This is no longer supported.
2021-08-11 07:56:32 -06:00
Kenneth Moreland
e1ac918bc7 Compile ArrayGetValues implementation in library
Previously, all of the `ArrayGetValues` implementations were templated
functions that had to be built. That meant that any code using them had
to be compiled with a device compiler and create special code for it.
This change uses an `UnknownArrayHandle` to encapsulate the
`ArrayHandle` and call a per-compiled library function. This means that
the code only has to be compiled once.
2021-08-11 07:56:32 -06:00
Kenneth Moreland
34615a9858 Deprecate ArrayHandle::GetDeviceAdapterId
This method is a remenant of when `ArrayHandle` could only store data on
one device at a time. It is now capable of storing data on any number of
devices (as well as the host), so asking for "the" device no longer
makes sense. Thus, this method is deprecated in favor of
`ArrayHandle::IsOnDevice`.

This deprecation leads to fixing some older functionality that still
assumed data could only be on one device at a time.

Fixes #592.
2021-07-28 12:51:51 -06:00
Kitware Robot
cf0cdcf7d1 clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
Kenneth Moreland
ec34cb56c4 Use new ways to get array portal in control environment
Also fix deadlocks that occur when portals are not destroyed
in time.
2020-02-26 13:10:46 -07:00
Allison Vacanti
399f23963e Add ArrayGetValue[s] to address issue #355. 2019-08-22 11:16:16 -04:00