Commit Graph

32 Commits

Author SHA1 Message Date
Kenneth Moreland
170a10e4b4 Fix slow ArrayCopy calls
The `ArrayCopy` method has been changed to be precompiled. It handles
most standard array types. But there are some special `ArrayHandle`
types that are not correctly handled, and these go to a slow fallback.
Find places in the code that use that fallback and fix them.

There are also some instances of replacing an `ArrayHandleCounting` with
an `ArrayHandleIndex`. This change is probably not strictly necessary to
make the `ArrayCopy` faster, but when it can be used `ArrayHandleIndex`
is generally better.
2022-01-24 14:15:45 -07:00
Li-Ta Lo
04b05ac84c remove ArrayCopy from CopyInto 2021-12-14 15:18:23 -07: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
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
Robert Maynard
3b89bc0db2 CellSet classes don't require a name 2019-09-02 10:39:58 -04:00
Robert Maynard
5cd47a7065 DataSetBuilders don't require a cellset name 2019-09-02 09:05:56 -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
nadavi
fbcea82e78 conslidate the license statement 2019-04-17 10:57:13 -06:00
Kenneth Moreland
d879188de0 Make DispatcherBase invoke using a TryExecute
Rather than force all dispatchers to be templated on a device adapter,
instead use a TryExecute internally within the invoke to select a device
adapter.

Because this removes the need to declare a device when invoking a
worklet, this commit also removes the need to declare a device in
several other areas of the code.
2018-08-29 19:18:54 -07:00
luz.paz
940c891886 Misc. typos
Found via `codespell` and `grep`
more typos

includes source typo change and a typo that needs further review
follow-up typos


Follow-up typos


Revert a commit
2018-06-14 16:49:11 -04:00
Allison Vacanti
158f57c9a1 Split the DataSetBuilders into h/cxx files. 2018-05-29 16:49:34 -04: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
f68635941e Convert VTK-m over to use 'using' instead of 'typedef' 2017-08-17 10:47:25 -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
Sujin Philip
5751ed7a13 Fix DataSetBuilder for Uniform and Rectilinear
Allow 1 and 2 dimensional data along any orthogonal plane/axis.
2017-05-25 17:07:14 -04:00
Kitware Robot
4ade5f5770 clang-format: apply to the entire tree 2017-05-25 07:51:37 -04:00
David C. Lonie
f601e38ba8 Simplify exception hierarchy.
Remove the ErrorControl class such that all subclasses now inherit from
error. Renamed all exception classes via s/ErrorControl/Error/.

See issue #57.
2017-02-07 15:42:38 -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
Mark Kim
464da87d5a Merge branch 'master' of gitlab.kitware.com:vtk/vtk-m 2016-10-12 14:40:32 -04:00
Robert Maynard
0f58d6fc54 Add vtkm/cont/serial directory for the serial backend. 2016-09-28 14:22:53 -04:00
Dave Pugmire
7a2874cf44 Add 1D support for uniform and rectilinear data. 2016-09-23 09:00:40 -04:00
Kenneth Moreland
cc497e6a1b Remove cont/Assert.h and exec/Assert.h
These asserts are consolidated into the unified Assert.h. Also made some
minor edits to add asserts where appropriate and a little bit of
reconfiguring as found.
2016-04-20 15:41:14 -06:00
Jeremy Meredith
ba8517eb67 removing all references to field order. 2016-03-23 10:38:14 -04:00
Kenneth Moreland
f4e4dc9ebe Use serial device for copies in DataSetBuilderRectilinear
A previous change used the Copy method of DeviceAdapterAlgorithm to
perform the actual copy in the CopyInto method. This works fine, except
that it uses the default device adapter, and the default device adapter
may need to copy the data to the device just to copy it to another
array. Instead, use the serial device adapter, which is guaranteed to
only perform one copy of the data.
2016-01-27 08:45:29 -07:00
Kenneth Moreland
cadf0e53ab Fix MSVC warnings
Fix your typical batch of MSVC warnings including picky type conversions
and using "unsafe" std functions on pointers for iterators.
2016-01-26 16:23:00 -07:00
Kenneth Moreland
d626f7317d Make DataSetBuilder methods static
This makes is slightly easier to use as you do not actually have to
construct the DataSetBuilder object but just call its static method.

The DataSetBuilderExplicitIterative methods are not static because they
use state of the builder object to create the data.
2016-01-21 10:45:33 -07:00
Robert Maynard
2ae3f13a79 Don't use DeviceAdapter inside DataSetBuilderRectilinear.
No need to use the device adapter, just do a manual host side copy.
2016-01-19 15:43:49 -05:00
dpugmire
b225ae97a2 Rectilinear coordinates (created with DataSetBuilderRectilinear) are now converted to vtkm::FloatDefault.
This reduces the number of types to consider when casting inside CoordinateSystem, and was felt by all to be a reasonable restriction.
2016-01-07 10:23:52 -05:00
dpugmire
fe1ab945a2 This commit has several changes.
1. Additional ASSERT calls to validate arguments in: DataSetBuilderRegular
2. Fix some untested compile errors in DataSetBuilderRectilinear
3. Added a new unit test, cont/testing/UnitTestDataSetBuilderRectilinear.cxx
4. Provided additional tests for UnitTestDataSetBuilderRegular.cxx.
The new tests in (4) were also included in (3), and provide a much more robust way of validating datasets created. It has nested for loops to do an all-all test on various ways to specify the X,Y, and Z coordinates.  It computes the bounds on the coordinate system and make sure they are correct.
Note: The GetBounds() call for Rectilinear is not working, and is an item for future discussion. It is disabled for now.
2015-12-30 12:34:04 -05:00
dpugmire
482341562f Add more robust testing for DataSetBuilderRegular class. Also, add options for creating rectilinear dataset from ArrayHandle. 2015-12-29 12:17:46 -05:00
dpugmire
25a1e3c36f Cleanup and fix an issue in Explicit dataset testing with the initial merge. 2015-12-04 16:15:51 -05:00
dpugmire
62bd2394b0 Add support for rectilinear coordinates via ArrayHandleCartesianProduct.
It consists of 3 ArrayHandles, and handles indexing to give each point in the grid.
Added some examples to the test dataset class, and a basic test.
2015-12-01 17:24:56 -05:00