Commit Graph

87 Commits

Author SHA1 Message Date
Kenneth Moreland
b085cde358 Fix runaway deprecation suppression
Field.h had a runaway deprecation suppression where the pragmas to
suppress deprecation warnings were turned on but not properly turned
off. This caused deprecation warnings to be turned off for anything
including Field.h (directly or indirectly), and consequently lots of use
of deprecated features went unnoticed.
2021-01-25 15:25:12 -07:00
Kenneth Moreland
11a4c9867e Change Field to hold UnknownArrayHandle rather than VariantArrayHandle
The `VariantArrayHandle` will soon be deprecated for its replacement of
`UnknownArrayHandle`. Thus, `Field` and related classes should start
using the new `UnknownArrayHandle`.
2021-01-14 17:01:22 -07:00
Kenneth Moreland
06c59fed13 Update MapFieldMergeAverage/Permuation to use new CastAndCall
These functions now use
`UnknownArrayHandle::CastAndCallWithExtractedArray` to reduce the number
of times the worklet is run.
2021-01-13 09:19:33 -07:00
Kenneth Moreland
7d681fb585 Deprecate templated versions of Field::GetRange
Instead, always use precompiled versions of range computing. This means
you won't be able to specify the type. Currently, types are limited to
scalars vecs up to size 4.

The main motivation for this change is to allow you to include Field.h
with a non-device compiler. This is an important feature for our
customers.

I plan in the future to implement a mechanism to pull out a component of
most ArrayHandle's as a single array. This would enable us to support a
precompiled version that can compute the range of arbitrarily sized
Vecs.
2020-11-09 12:28:29 -07:00
Kenneth Moreland
f5c5b61880 Log the computation of ranges in fields and arrays 2020-10-12 15:51:09 -06:00
Kenneth Moreland
5f541d2515 Drop log message when ignoring copy in move
For `make_ArrayHandle` and `make_Field` when it is determined that the
data can be safely moved, just silently move instead of copy instead of
printing a log message saying the copy flag will be ignored.

Also fix an issue with `make_ArrayHandle` when the data was not moved
when it could have been.
2020-07-23 17:59:50 -06:00
Kenneth Moreland
d1a4aecc59 Improvements to moving data into ArrayHandle
We have made several improvements to adding data into an `ArrayHandle`.

## Moving data from an `std::vector`

For numerous reasons, it is convenient to define data in a `std::vector`
and then wrap that into an `ArrayHandle`. It is often the case that an
`std::vector` is filled and then becomes unused once it is converted to an
`ArrayHandle`. In this case, what we really want is to pass the data off to
the `ArrayHandle` so that the `ArrayHandle` is now managing the data and
not the `std::vector`.

C++11 has a mechanism to do this: move semantics. You can now pass
variables to functions as an "rvalue" (right-hand value). When something is
passed as an rvalue, it can pull state out of that variable and move it
somewhere else. `std::vector` implements this movement so that an rvalue
can be moved to another `std::vector` without actually copying the data.
`make_ArrayHandle` now also takes advantage of this feature to move rvalue
`std::vector`s.

There is a special form of `make_ArrayHandle` named `make_ArrayHandleMove`
that takes an rvalue. There is also a special overload of
`make_ArrayHandle` itself that handles an rvalue `vector`. (However, using
the explicit move version is better if you want to make sure the data is
actually moved.)

## Make `ArrayHandle` from initalizer list

A common use case for using `std::vector` (particularly in our unit tests)
is to quickly add an initalizer list into an `ArrayHandle`. Now you can
by simply passing an initializer list to `make_ArrayHandle`.

## Deprecated `make_ArrayHandle` with default shallow copy

For historical reasons, passing an `std::vector` or a pointer to
`make_ArrayHandle` does a shallow copy (i.e. `CopyFlag` defaults to `Off`).
Although more efficient, this mode is inherintly unsafe, and making it the
default is asking for trouble.

To combat this, calling `make_ArrayHandle` without a copy flag is
deprecated. In this way, if you wish to do the faster but more unsafe
creation of an `ArrayHandle` you should explicitly express that.

This requried quite a few changes through the VTK-m source (particularly in
the tests).

## Similar changes to `Field`

`vtkm::cont::Field` has a `make_Field` helper function that is similar to
`make_ArrayHandle`. It also features the ability to create fields from
`std::vector`s and C arrays. It also likewise had the same unsafe behavior
by default of not copying from the source of the arrays.

That behavior has similarly been depreciated. You now have to specify a
copy flag.

The ability to construct a `Field` from an initializer list of values has
also been added.
2020-07-23 10:53:38 -06:00
Kenneth Moreland
be7f06bbe7 CoordinateSystem data is VariantArrayHandle
`CoordinateSystem` differed from `Field` in that its `GetData`
method returned an `ArrayHandleVirtualCoordinates` instead of
a `VariantArrayHandle`. This is probably confusing since
`CoordianteSystem` inherits `Field` and has a pretty dramatic
difference in this behavior.

In preparation to deprecate `ArrayHandleVirtualCoordinates`, this
changes `CoordiantSystem` to be much more like `Field`. (In the
future, we may change the `CoordinateSystem` to point to a `Field`
rather than be a special `Field`.)

A method named `GetDataAsMultiplexer` has been added to
`CoordinateSystem`. This method allows you to get data from
`CoordinateSystem` as a single array type without worrying
about creating functors to handle different types and without
needing virtual methods.
2020-07-14 08:50:39 -06:00
Kenneth Moreland
5498ecd35b Properly handle global (whole mesh) fields in data set filters
Generally, fields that have a WHOLE_MESH association might be valid even
if the structure of the mesh changes. Thus, it makes sense for filters
to pass this data pretty much all the time.

Also cleaned up some code and comments to make the relationship between
`MapFieldOntoOutput` and `DoMapField` more clear.
2020-05-21 08:34:34 -06:00
NAThompson
46faf574fa ReadPortal().Get(idx) is slow in a loop. 2020-05-08 11:30:59 -04:00
Kenneth Moreland
ddf038742d Use finite types when serializing fields
When serializing fields, you have to select what underlying data types
of the field you want to support serializing. With recent changes in the
default policy, attempts to serialize a field often resulted in trying
to use the `vtkm::ListUniversal` type list, which is infinite.
Obviously, this cannot be compiled.

Instead, when the `vtkm::ListUniversal` list is encountered, use
`vtkm::TypeListAll` instead.
2020-05-07 13:58:08 -06:00
Kenneth Moreland
882dcacca4 Have filter specify its own field types
Previously, the policy specified which field types the filter should
operate on. The filter could remove some types, but it was not able to
add any types.

This is backward. Instead, the filter should specify what types its
supports and the policy may cull out some of those.
2020-04-28 10:31:44 -06: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
Kenneth Moreland
cd302effb3 Update lists in TypeListTag.h
A new header named TypeList.h and the type lists have been redefined in
this new file. All the types have been renamed from `TypeListTag*` to
`TypeList*`. TypeListTag.h has been gutted to provide deprecated
versions of the old type list names.

There were also some other type lists that were changed from using the
old `ListTagBase` to the new `List`.
2019-12-05 11:05:19 -07:00
Kenneth Moreland
6fc883213c Deprecate ListTag operations
The newer List operations should still work on the old ListTags, so make
those changes first to ensure that everything still works as expected if
given an old ListTag.

Next step is to deprecate ListTagBase itself and move all the lists to
the new types.
2019-12-05 11:27:31 -05:00
Robert Maynard
f2a3ecd014 Don't generate doxygen for serialization helpers 2019-09-12 17:29:05 -04:00
Robert Maynard
89fa2c0293 Remove multiple vtkm::cont::CellSet from vtkm::cont::DataSet
By removing the ability to have multiple CellSets in a DataSet
we can simplify the following things:

  - Cell Fields now don't require a CellSet name when being constructed
  - Filters don't need to manage what the active cellset is
2019-09-02 09:04:51 -04:00
Robert Maynard
031407443d Provide simplified way to construct point and cell fields 2019-08-15 11:03:41 -04:00
nadavi
fbcea82e78 conslidate the license statement 2019-04-17 10:57:13 -06:00
Sujin Philip
7b072b1593 Add useful Get functions to Fields and Coordinates
Avoid having to call 'GetData()' to query 'NumberOfValues'/'NumberOfPoints'.
2019-03-15 13:28:55 -04:00
Robert Maynard
ad98d818ce VTK-m now doesn't clobber external DIY installations
Fixes #334
2019-02-05 13:05:14 -05:00
Robert Maynard
0a40c620ac Rename ArrayHandleVariant to VariantArrayHandle. 2018-12-27 14:35:56 -05:00
Robert Maynard
ef83adf3bd Field, CoordinateSystem, VirtualCoordinates all use the new virtual code 2018-12-27 14:35:56 -05:00
Robert Maynard
0da7830d9a Make sure important vtkm::cont classes have noexcept move ops.
This is important so they can be stored efficiently inside
containers such as std::vector that require strong move guarantees.
2018-12-10 10:33:18 -05:00
Robert Maynard
dadfeab00a Simplify vtkm::cont::Field by using delegating constructors. 2018-11-02 14:18:09 -04:00
Sujin Philip
365d3d3921 Implement DataSet Serialization 2018-09-25 13:58:39 -04:00
Haocheng LIU
7d226a4666 Add a common API for CoordinateSystem to unload execution resources
This commit also fixes a bug that ArrayTransfer of ArrayHandleVirtualCoordinate
does not release execution resources properly.
2018-05-30 17:25:54 -04:00
Haocheng LIU
5c797169ec Use the strong typed enums for vtkm::cont::Field
Since Field association is used either when creating or working
with 'vtkm::cont::Field', it's put in the class itself.
2018-05-22 11:44:51 -04:00
Robert Maynard
bed777f078 Add missing virtual destructor to vtkm::cont::Field 2018-05-02 13:31:30 -04:00
luz.paz
80b11afa24 Misc. typos
Found via `codespell -q 3` via downstream VTK
2018-01-30 06:51:47 -05:00
Sujin Philip
4810cef78f Field::SetData should accept any ArrayHandle type 2018-01-09 14:25:47 -05:00
Sujin Philip
334262db16 Fix Field constructors
1. Add option to copy user supplied array in make_ArrayHandle.
2. Replace Field constructors that take user supplied arrays with make_Field.
3. Replace CoordinateSystem constructors that take user supplied arrays with
   make_CoordinateSystem.
2017-12-21 12:48:15 -05:00
Robert Maynard
7b1b9e445a Correctly forward rvalue functors when passed to CastAndCall 2017-12-08 12:02:01 -05:00
Robert Maynard
7f76220427 Redesign the Dispatcher to not need FunctionInterface to convert dynamic types 2017-11-28 11:01:02 -05:00
Robert Maynard
2ff14a811f Allow users to pass multiple arguments to CastAndCall 2017-11-08 13:19:05 -05:00
Kenneth Moreland
c3a3184d51 Update copyright for Sandia
Sandia National Laboratories recently changed management from the
Sandia Corporation to the National Technology & Engineering Solutions
of Sandia, LLC (NTESS). The copyright statements need to be updated
accordingly.
2017-09-20 15:33:44 -06:00
Robert Maynard
b85cdd9080 Convert VTK-m over to use 'using' instead of 'typedef' 2017-08-07 14:05:43 -04:00
Robert Maynard
5dd346007b Respect VTK-m convention of parameters all or nothing on a line
clang-format BinPack settings have been disabled to make sure that the
VTK-m style guideline is obeyed.
2017-05-26 13:53:28 -04:00
Kitware Robot
4ade5f5770 clang-format: apply to the entire tree 2017-05-25 07:51:37 -04:00
Kitware Robot
efbde1d54b clang-format: sort include directives 2017-05-18 12:59:33 -04:00
Kenneth Moreland
6fdc7eb8c0 Add Field::GetRange and CoordinateSystem::GetBounds to library
Following what was done with ArrayRangeCompute, the GetRange and
GetBounds methods are embedded into the vtkm_cont library for the most
common type lists.

Also, and probably more importantly, the device adapter is no longer one
of the arguments for either of these methods. It is no longer needed as
ArrayRangeCompute no longer needs it.
2017-03-09 13:18:36 -05:00
Kenneth Moreland
c16236ce69 Use ArrayRangeCompute without specifying a device
Most uses of ArrayRangeCompute just want to get the range of the data
and probably don't have a particular device in mind. Thus, it is better
to use a TryExecute internally use whatever devices are available.

Note that when using TryExecute, the calling code is expected to be able
to support all devices. That might not always be the case. Thus, I am
experimenting a bit with how we incorporate this in a library. The
advantage of having the code compiled in a library is that you only have
to compile it once and the calling code does not need to worry about
CUDA, etc.

However, because ArrayRangeCompute is templated, we can only pre-compile
some subset of array handle types. The most common are compiled into the
code (matching all the predefined ArrayHandles as well as some special
cases). If the code wants to use some other type, it has to include
ArrayRangeCompute.hxx. The only place where this is necessary is a test
that intentially trys to find the range on an uncommon type.

If array portals were to support virtual methods, then we should be able
to modify this code so that we could precompile for all array handle
types.
2017-03-09 13:18:36 -05:00
Kenneth Moreland
3d2e15b4c0 Move ComputeRange for ArrayHandle to its own header
It will be convenient to make this accessible outside of Field.
2017-02-01 09:06:42 -05:00
Robert Maynard
2dc23cf1a8 Correct compilation errors on Windows with CUDA. 2017-01-19 14:02:35 -05:00
Robert Maynard
3c07c77fa7 Introduce vtkm_cont library to reduce weak vtable creation.
This reduces the number of weak vtables vtkm generates, resulting in
a reduction of binary sizes for projects that include vtkm classes in
multiple translation units.
2017-01-16 09:17:38 -05:00
Robert Maynard
64bcc34389 Refactor MinAndMax to use vtkm::Vec<T,2> instead of Pair.
The types are the same which makes Vec a more suitable container.
2016-11-25 13:11:19 -05:00
Robert Maynard
8d60ed57ad Refactor MinAndMax to be a shared binary operator. 2016-11-25 11:40:46 -05:00
Robert Maynard
18375b5424 Update Bound computations to always use a single Reduce call 2016-11-25 11:40:46 -05:00
Kenneth Moreland
fdaccc22db Remove exports for header-only functions/methods
Change the VTKM_CONT_EXPORT to VTKM_CONT. (Likewise for EXEC and
EXEC_CONT.) Remove the inline from these macros so that they can be
applied to everything, including implementations in a library.

Because inline is not declared in these modifies, you have to add the
keyword to functions and methods where the implementation is not inlined
in the class.
2016-11-15 22:22:13 -07:00
Robert Maynard
146d800968 make CastAndCall a free function instead of a class.
Overloading the function serves the same purpose of specializing the
class, but requires less syntax sugar to do.
2016-08-05 15:18:22 -04:00