Commit Graph

7807 Commits

Author SHA1 Message Date
Kenneth Moreland
4c56797c5d Remove ArrayHandleSOA constructors with ambiguous move semantics
Also correct some constructors/functions that should be
deprecated.
2020-07-23 17:54:42 -06:00
Kenneth Moreland
0d484505e7 Fix bad gcc compiler warning about static definition (again) 2020-07-23 17:53:15 -06:00
Kenneth Moreland
2163077441 Fix errors with memory access 2020-07-23 11:02:40 -06:00
Kenneth Moreland
e23989bde1 Use data method to get pointer from std::vector
Do not use `&v.front()` to get the pointer from an `std::vector`. That
behavior is undefined when the vector is empty. Instead, use `v.data()`.
2020-07-23 11:02:40 -06:00
Kenneth Moreland
2e243cbbac Fix issue with using std::string in ArrayHandle
The recent version of ArrayHandleBasic allocates typeless arrays without
any initialization. This can cause issues with types that require a
constructor. The UnitTestVariantArrayHandle was trying to create an
ArrayHandle with an std::string, and the uninitialized strings were
causing crashes on some platforms.
2020-07-23 11:02:38 -06:00
Kenneth Moreland
46f253b927 Fix compiler issue with MSVC 2020-07-23 10:53:42 -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
744edbf428 Merge topic 'gcc-static-function-warning'
b1f648bfd Remove gcc warning about static declared function

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2193
2020-07-22 15:20:45 -04:00
Li-Ta Lo
537557ef91 Merge topic 'worket_invoker_dispatcher2'
0dcc6cc16 reverse #include on CellNeighborhood
2489da125 restore comment, add needed #include
f33318247 Reverse Invoker, Dispatcher and Worklet dependency

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Kenneth Moreland <kmorel@sandia.gov>
Merge-request: !2192
2020-07-22 14:20:35 -04:00
Dave Pugmire
da5f7083c7 Merge topic 'generalizeField'
e60d89953 Use the ResetTypes spell to fix the ArrayCopy issue.
0a4d18420 fix compile error in array copy
246be1b7f Merge branch 'master' of https://gitlab.kitware.com/vtk/vtk-m into generalizeField
415e2a5ac Fix to deal with float data when double enabled.
5ad32f486 enable reading data files.
2e3fe059b replace vtkm::Particle with vtkm::Massless
5fc822082 replace vtkm::Particle with vtkm::Massless
31c97bed8 Generalize fields for particle advection

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2188
2020-07-22 14:17:48 -04:00
dpugmire
e60d899536 Use the ResetTypes spell to fix the ArrayCopy issue. 2020-07-22 12:03:11 -04:00
Kenneth Moreland
b1f648bfdf Remove gcc warning about static declared function
While compiling UnitTestVariantArrayHandle, some versions of gcc
(between 6 and 8, I think) gave a warning like the following:

```
../vtkm/cont/StorageVirtual.h:227:12: warning: 'vtkm::Id vtkm::cont::internal::detail::StorageVirtualImpl<T, S>::GetNumberOfValues() const [with T = std::__cxx11::basic_string<char>; S = vtkm::cont::StorageTagImplicit<{anonymous}::UnusualPortal<std::__cxx11::basic_string<char> > >]' declared 'static' but never defined [-Wunused-function]
```

This warning makes no sense because it is refering to a method that is
not declared static. (In fact, it overrides a virtual method.)

I believe this is an obscure bug in these versions of gcc. I found a
[stackoverflow post] that seems to have the same problem, but no
workaround was found.

The warning originated from code that had little effect. It was part of
a test with a custom ArrayHandle storage type that was already disabled
for other reasons. Just removed the code.

[stackoverflow post]: https://stackoverflow.com/questions/56615695/how-to-fix-declared-static-but-never-defined-on-member-function
2020-07-22 08:28:28 -06:00
dpugmire
0a4d184205 fix compile error in array copy 2020-07-22 09:59:20 -04:00
Li-Ta Lo
0dcc6cc160 reverse #include on CellNeighborhood 2020-07-21 18:49:57 -06:00
Li-Ta Lo
2489da1259 restore comment, add needed #include 2020-07-21 18:21:44 -06:00
Li-Ta Lo
f333182476 Reverse Invoker, Dispatcher and Worklet dependency 2020-07-21 17:25:43 -06:00
dpugmire
246be1b7f0 Merge branch 'master' of https://gitlab.kitware.com/vtk/vtk-m into generalizeField 2020-07-21 15:03:08 -04:00
dpugmire
415e2a5ac8 Fix to deal with float data when double enabled. 2020-07-21 15:00:47 -04:00
Li-Ta Lo
567b1fedd2 Merge topic 'cell_neighbor'
9cd70a7dc Install WorkletNeighborhood.h
f66c782b1 Extract WorkletNeighborhood base class
760c51ed6 install ThreadIndicesNeighborhood.h
e52b8fa88 Add CellNeighborhood

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Kenneth Moreland <kmorel@sandia.gov>
Merge-request: !2181
2020-07-21 13:45:40 -04:00
dpugmire
5ad32f4860 enable reading data files. 2020-07-21 11:23:58 -04:00
dpugmire
2e3fe059b6 replace vtkm::Particle with vtkm::Massless 2020-07-21 11:19:47 -04:00
dpugmire
5fc822082e replace vtkm::Particle with vtkm::Massless 2020-07-21 11:14:31 -04:00
Li-Ta Lo
9cd70a7dc5 Install WorkletNeighborhood.h 2020-07-21 08:48:49 -06:00
dpugmire
31c97bed89 Generalize fields for particle advection 2020-07-20 21:15:46 -04:00
Li-Ta Lo
f66c782b14 Extract WorkletNeighborhood base class 2020-07-20 17:50:14 -06:00
Kenneth Moreland
502c310cf8 Merge topic 'deprecate-arrayhandlevirtualcoordinates'
c689a68c5 Suppress bad deprecation warnings in MSVC
a3f23a03b Do not cast to ArrayHandleVirtual in VariantArrayHandle::CastAndCall
f6b13df51 Support coordinates of both float32 and float64
453e31404 Deprecate ArrayHandleVirtualCoordinates
be7f06bbe CoordinateSystem data is VariantArrayHandle

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2177
2020-07-16 17:25:43 -04:00
Kenneth Moreland
a663514044 Merge topic 'filter-benchmark-help'
fbeea75f3 Print out all options to BenchmarkFilters

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Vicente Bolea <vicente.bolea@kitware.com>
Merge-request: !2176
2020-07-16 13:45:35 -04:00
Ben Boeckel
882832db6f Merge topic 'gitlab-ci-doxygen-to-site'
ca91cdee4 gitlab-ci: upload doxygen docs to the public website
09973e66f gitlab-ci: use the keyfile directly

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !2183
2020-07-16 12:57:44 -04:00
Sujin Philip
f88bccde08 Merge topic 'update-to-latest-diy'
c35323ae4 Merge branch 'upstream-diy' into update-to-latest-diy
ec6fef447 diy 2020-07-15 (4ea1241e)
78221a09e Update diy tag name

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !2182
2020-07-16 10:48:16 -04:00
Li-Ta Lo
760c51ed62 install ThreadIndicesNeighborhood.h 2020-07-16 08:06:17 -06:00
Ben Boeckel
ca91cdee44 gitlab-ci: upload doxygen docs to the public website
It had been copied to a runner-local directory and then dropped.
2020-07-16 09:30:43 -04:00
Ben Boeckel
09973e66f9 gitlab-ci: use the keyfile directly 2020-07-16 09:30:27 -04:00
Li-Ta Lo
e52b8fa88a Add CellNeighborhood 2020-07-15 14:41:32 -06:00
Sujin Philip
c35323ae42 Merge branch 'upstream-diy' into update-to-latest-diy
* upstream-diy:
  diy 2020-07-15 (4ea1241e)
2020-07-15 15:36:03 -05:00
Diy Upstream
ec6fef4472 diy 2020-07-15 (4ea1241e)
Code extracted from:

    https://gitlab.kitware.com/third-party/diy2.git

at commit 4ea1241e7d9d4f20b6f359dcfec1d52d3ad50bde (for/vtk-m-20200715-master).
2020-07-15 15:36:03 -05:00
Sujin Philip
78221a09ed Update diy tag name 2020-07-15 15:35:48 -05:00
Kenneth Moreland
a08b3ac018 Merge topic 'array-portal-value-ref-error'
ea340ed9c Fix UnitTestArrayPortalValueReference

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !2180
2020-07-15 08:29:09 -04:00
Kenneth Moreland
c689a68c5c Suppress bad deprecation warnings in MSVC
The Microsoft compiler has this annoying and stupid behavior where if
you have a generic templated method/function and that method is
instantiated with a deprecated class, then the compiler will issue a
C4996 warning even if the calling code is suppressing that warning
(because, for example, you are implementing other deprecated code and
the use is correct). There is no way around this other than suppressing
the warnings for all uses of the templated method.
2020-07-14 16:25:04 -06:00
Kenneth Moreland
ea340ed9cb Fix UnitTestArrayPortalValueReference
A recent change to the continuous integration setup has caused
`UnitTestArrayPortalValueReference` to fail on one platform.

The problem was that the test was doing two unsafe things with the
right-shift assignment operator. The first unsafe thing was using itself
as the operand.

```cpp
  ref >>= ref;
```

This causes clang to give a "self assign overload" warning. Using a
variable as its own operand for a compute assign operation isn't great
style, but for some operations it can cause weird errors. The reason for
the warning is that for a true integer shift operation, the compiler
will recognize that the result should be 0. So, when using this on base
integer types, you will get 0. But overloads can give you something
different, so that might lead to unexpected results. Because we _are_
using an overload (for the `ArrayPortalValueReference` class), the
compiler tells us we can get potentially unexpected results.

OK. That seems like something we can safely ignore (and were ignoring
for some time). After all, the whole point of the
`ArrayPortalValueReference` operators is to behave exactly the same as
the values they wrap. That brings us to the second unsafe thing the test
was doing: using an invalid value as the right hand operation. And this
is where things get weird.

The test was specifically failing when being run on `Int32`. It was
setting the underlying value for `ref` to be `1000` to start with. So
the expression `ref >>= ref` was trying to right shift `ref` by 1000
bits. Logically, this should of course give you 0. However, shifting a
number by more bits than exist causes undefined behavior (c.f.
https://wiki.sei.cmu.edu/confluence/display/c/INT34-C.+Do+not+shift+an+expression+by+a+negative+number+of+bits+or+by+greater+than+or+equal+to+the+number+of+bits+that+exist+in+the+operand).
You might not get back the expected value, and this is exactly what was
happening.

What I think happened was that the compiler determined that any valid
shift would be contained in 5 bits, so it truncated the value (1000) to
the least signifcant 5 bits (which happens to be 8). It then shifted
1000 by 8 and got the value 3 instead of 0.

The fix picks an operand number that is sure to be valid.
2020-07-14 16:13:12 -06:00
Kenneth Moreland
a3f23a03b6 Do not cast to ArrayHandleVirtual in VariantArrayHandle::CastAndCall
We are moving to deprecate `ArrayHandleVirtual`, so we are removing the
feature where `VariantArrayHandle::CastAndCall` automatically casts to
an `ArrayHandleVirtual` if possible.

The big reason to make this change now (as opposed to later when
`ArrayHandleVirtual` is deprecated) is to improve compile times.
This prevents us from having to compile an extra code path using
`ArrayHandleVirtual`.
2020-07-14 08:53:03 -06:00
Kenneth Moreland
f6b13df513 Support coordinates of both float32 and float64
Previously there were issues if the coordinate system was using floating
point values that were not FloatDefault. This remedies that issue.
2020-07-14 08:53:01 -06:00
Kenneth Moreland
453e314044 Deprecate ArrayHandleVirtualCoordinates
We are in the process of deprecating virtual classes in VTK-m
(that run in the execution environment).
2020-07-14 08:51:47 -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
Dave Pugmire
e66986dabe Merge topic 'worldAnnotationsOptional'
cabaf3e26 Add option to enable/disable world annotations.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Matt Larsen <larsen30@llnl.gov>
Merge-request: !2175
2020-07-14 10:19:48 -04:00
Robert Maynard
29bac212c7 Merge topic 'extrude-fix'
a428d75e0 adding CellSetExtrude to DefaultTypesVTK
235d9ce14 add GetThreadIndex to ThreadIndicesExtrude classes

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2172
2020-07-13 14:24:58 -04:00
Kenneth Moreland
fbeea75f32 Print out all options to BenchmarkFilters
Previously, if you used the `--help` option, you would get VTK-m's
initialize options and Google benchmark's options, but you would not get
the special options for the algorithms in this benchmark. Now, all the
potential options should be printed when `--help` is added to the
command line.
2020-07-13 10:20:19 -06:00
dpugmire
cabaf3e269 Add option to enable/disable world annotations. 2020-07-09 14:38:39 -04:00
Sujin Philip
b32cc894b6 Merge topic 'fix-gitlab-ci'
2f7ae83c9 Fix warnings
e67fc619c Fix setting build type in gitlab ci

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !2171
2020-07-09 14:38:32 -04:00
Kenneth Moreland
e2027da0c3 Merge topic 'write-uniform-rectilinear'
058927c82 Write uniform and rectilinear grids to legacy VTK files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Sujin Philip <sujin.philip@kitware.com>
Merge-request: !2173
2020-07-09 10:53:20 -04:00
Sujin Philip
2f7ae83c9f Fix warnings 2020-07-09 08:10:54 -05:00