vtk-m2/vtkm/cont
Robert Maynard c1560e2d3f Perform less unnecessary copies when deducing a worklets parameters.
One of the causes of the large library size and slow compile times has been
that vtkm has been creating unnecessary copies when not needed. When the
objects being copied use shared_ptr this causes a bloom in library size. I
presume this bloom is caused by the atomic increment/decrement that is
required by shared_ptr.

For testing I used the following example:
```
struct ExampleFieldWorklet : public vtkm::worklet::WorkletMapField
{
  typedef void ControlSignature( FieldIn<>, FieldIn<>, FieldIn<>,
                                 FieldOut<>, FieldOut<>, FieldOut<> );
  typedef void ExecutionSignature( _1, _2, _3, _4, _5, _6 );

  template<typename T, typename U, typename V>
  VTKM_EXEC_EXPORT
  void operator()( const vtkm::Vec< T, 3 > & vec,
                   const U & scalar1,
                   const V& scalar2,
                   vtkm::Vec<T, 3>& out_vec,
                   U& out_scalar1,
                   V& out_scalar2 ) const
  {
    out_vec = vec * scalar1;
    out_scalar1 = scalar1 + scalar2;
    out_scalar2 = scalar2;
  }

  template<typename T, typename U, typename V, typename W, typename X, typename Y>
  VTKM_EXEC_EXPORT
  void operator()( const T & vec,
                   const U & scalar1,
                   const V& scalar2,
                   W& out_vec,
                   X& out_scalar,
                   Y& ) const
  {
  //no-op
  }
};

int main(int argc, char** argv)
{
  std::vector< vtkm::Vec<vtkm::Float32, 3> > inputVec;
  std::vector< vtkm::Int32 > inputScalar1;
  std::vector< vtkm::Float64 > inputScalar2;

  vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32, 3> > handleV =
    vtkm::cont::make_ArrayHandle(inputVec);

  vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32, 3> > handleS1 =
    vtkm::cont::make_ArrayHandle(inputVec);

  vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32, 3> > handleS2 =
    vtkm::cont::make_ArrayHandle(inputVec);

  vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32, 3> > handleOV;
  vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32, 3> > handleOS1;
  vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32, 3> > handleOS2;

  std::cout << "Making 3 output DynamicArrayHandles " << std::endl;
  vtkm::cont::DynamicArrayHandle out1(handleOV), out2(handleOS1), out3(handleOS2);

  typedef vtkm::worklet::DispatcherMapField<ExampleFieldWorklet> DispatcherType;

  std::cout << "Invoking ExampleFieldWorklet" << std::endl;
  DispatcherType dispatcher;

  dispatcher.Invoke(handleV, handleS1, handleS2, out1, out2, out3);

}
```

Original vtkm would generate a binary of size 4684kb and would perform 91
ArrayHandle copies or assignments. With this branch the binary size is
reduced to 2392kb and will perform 36 copies or assignments.
2016-01-19 09:20:49 -05:00
..
arg Add WholeArray* ControlSignature tags 2015-12-07 09:52:29 -07:00
cuda Add ErrorControlCuda for better CUDA error checking. 2016-01-12 15:19:54 -07:00
internal Serial SortByKey works now when the key is a ArrayHandleZip. 2015-12-31 14:45:18 -05:00
tbb FunctorsTBB now uses VTKM_VECTORIZATION_X macros everywhere. 2016-01-12 08:43:06 -05:00
testing Fix warning about uninitialized value. 2016-01-18 15:58:07 -07:00
ArrayHandle.h Perform less unnecessary copies when deducing a worklets parameters. 2016-01-19 09:20:49 -05:00
ArrayHandleCartesianProduct.h Fix support for CoordinateSystems using ArrayHandleCartesianProduct. 2016-01-07 14:17:23 -05:00
ArrayHandleCast.h Replace ArrayHandleCastForInput with the more versatile ArrayHandleCast. 2015-11-11 17:13:04 -05:00
ArrayHandleCompositeVector.h Support control array portals in composite vector. 2016-01-04 12:53:56 -07:00
ArrayHandleConstant.h Add default constructors/destructors/assignment to ArrayHandle classes 2015-10-21 13:36:27 -06:00
ArrayHandleCounting.h Add default constructors/destructors/assignment to ArrayHandle classes 2015-10-21 13:36:27 -06:00
ArrayHandleGroupVec.h Change Isosurface algorithm to work with scatter counting 2015-11-06 18:05:20 -07:00
ArrayHandleImplicit.h Add default constructors/destructors/assignment to ArrayHandle classes 2015-10-21 13:36:27 -06:00
ArrayHandleIndex.h Add default constructors/destructors/assignment to ArrayHandle classes 2015-10-21 13:36:27 -06:00
ArrayHandlePermutation.h Add default constructors/destructors/assignment to ArrayHandle classes 2015-10-21 13:36:27 -06:00
ArrayHandleTransform.h Add support for bidirectional array transforms. 2015-11-10 15:13:02 -05:00
ArrayHandleUniformPointCoordinates.h Add default constructors/destructors/assignment to ArrayHandle classes 2015-10-21 13:36:27 -06:00
ArrayHandleZip.h Add default constructors/destructors/assignment to ArrayHandle classes 2015-10-21 13:36:27 -06:00
ArrayPortal.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
ArrayPortalToIterators.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
Assert.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
CellSet.h Add GetNumberOfPoints to CellSet. 2015-12-21 17:27:54 -07:00
CellSetExplicit.h Update vtkm tests and examples to use DataSetBuilders. 2016-01-15 15:44:56 -05:00
CellSetListTag.h Add CellSetSingleType 2015-09-25 13:41:41 -04:00
CellSetPermutation.h Add GetNumberOfPoints to CellSet. 2015-12-21 17:27:54 -07:00
CellSetSingleType.h Update vtkm tests and examples to use DataSetBuilders. 2016-01-15 15:44:56 -05:00
CellSetStructured.h Merge branch 'exporter' into 'master' 2015-10-30 17:39:04 -04:00
CMakeLists.txt Merge topic 'dataset-builder2' 2016-01-14 14:57:02 -05:00
CoordinateSystem.h Fix support for CoordinateSystems using ArrayHandleCartesianProduct. 2016-01-07 14:17:23 -05:00
DataSet.h Cleanup and fix an issue in Explicit dataset testing with the initial merge. 2015-12-04 16:15:51 -05:00
DataSetBuilderExplicit.h Fixed some warnings in the DataSetBuilder code. 2016-01-18 15:04:18 -05:00
DataSetBuilderRectilinear.h Rectilinear coordinates (created with DataSetBuilderRectilinear) are now converted to vtkm::FloatDefault. 2016-01-07 10:23:52 -05:00
DataSetBuilderRegular.h This commit has several changes. 2015-12-30 12:34:04 -05:00
DataSetFieldAdd.h Add tests for DataSetBuilderExplicit. 2016-01-05 16:28:57 -05:00
DeviceAdapter.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
DeviceAdapterAlgorithm.h Adding vtkm::cont::RuntimeDeviceInformation. 2015-12-15 17:25:27 -05:00
DeviceAdapterSerial.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
DynamicArrayHandle.h Perform less unnecessary copies when deducing a worklets parameters. 2016-01-19 09:20:49 -05:00
DynamicCellSet.h Simplify and unify cast interface. 2016-01-18 15:58:04 -07:00
Error.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
ErrorControl.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
ErrorControlAssert.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
ErrorControlBadAllocation.h Add Bad Allocation error. 2015-09-22 10:54:22 -04:00
ErrorControlBadType.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
ErrorControlBadValue.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
ErrorControlInternal.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
ErrorExecution.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00
Field.h Allow vtkm::cont::Field to have a default constructor. 2016-01-04 15:40:37 -05:00
LogicalStructure.h fleshing out cell set and data set more. 2015-05-11 16:54:16 -04:00
RuntimeDeviceInformation.h Adding vtkm::cont::RuntimeDeviceInformation. 2015-12-15 17:25:27 -05:00
Storage.h Replace ErrorControlOutOfMemory with ErrorControlBadAllocation. 2015-10-01 14:25:28 -04:00
StorageBasic.h Replace ErrorControlOutOfMemory with ErrorControlBadAllocation. 2015-10-01 14:25:28 -04:00
StorageImplicit.h Add additional control logic for CopyInto function 2015-09-17 14:26:19 -04:00
StorageListTag.h Created DynamicCellSet 2015-07-27 16:58:29 -06:00
Timer.h The Copyright statement now has all the periods in the correct location. 2015-05-21 10:30:11 -04:00