Skip to content

Filters: Add cmake instantiations generator

Vicente Bolea requested to merge vbolea/vtk-m:add-cmake-instantiatior into master

TL;DR

  • Automatize the generation of VTK-m filter instantiation source files.
  • Port all the current instantiation files to use this new framework.
  • Extra: Small unrelated change to remove warnings with CUDA device code.

Background

I have already opened months ago another MRs attempting to solve this issue with a different approach which consisted in creating a c++ small program that parses the filters headers and generates the instantiation files in the project source code.

Approach

This time, in this MR, the approach is to have CMake doing this and also creating those instantiation files in the build directory so that they do not populate the vtkm source code.

Example:

In the header file:

VTKM_INSTANTIATION_BEGIN
#ifdef VTKM_ADD_XGC_DEFAULT_TYPES
extern template VTKM_FILTER_GRADIENT_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
  const vtkm::cont::DataSet&,
  const vtkm::cont::ArrayHandle<vtkm::Vec<float, 3>, vtkm::cont::StorageTagXGCCoordinates>&,
  const vtkm::filter::FieldMetadata&,
  vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
#endif
VTKM_INSTANTIATION_END

in CMakeLists.txt :

vtkm_add_instantiations(GradientInstantiationFiles FILTER Gradient)

Results in the following transient file:

#define vtkm_filter_GradientInstantiation9_cxx

/* Needed for linking errors when no instantiations */
int __vtkm_filter_GradientInstantiation9_cxx;

#include <vtkm/filter/Gradient.h>
#include <vtkm/filter/Gradient.hxx>

namespace vtkm
{
namespace filter
{

#ifdef VTKM_ADD_XGC_DEFAULT_TYPES
template VTKM_FILTER_GRADIENT_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
  const vtkm::cont::DataSet&,
  const vtkm::cont::ArrayHandle<vtkm::Vec<float, 3>, vtkm::cont::StorageTagXGCCoordinates>&,
  const vtkm::filter::FieldMetadata&,
  vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
#endif

}
}

Evaluation

TBD

Signed-off-by: Vicente Adolfo Bolea Sanchez vicente.bolea@kitware.com

Edited by Vicente Bolea

Merge request reports

Loading