mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Merge topic 'array-range-instantiations'
46a613d18 Speed up compilation of ArrayRangeCompute.cxx Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3079
This commit is contained in:
commit
05ff345b1f
@ -658,6 +658,10 @@ function(vtkm_add_instantiations instantiations_list)
|
||||
set(file_template_source ${instantiations_file})
|
||||
endif()
|
||||
|
||||
set_property(DIRECTORY
|
||||
APPEND
|
||||
PROPERTY CMAKE_CONFIGURE_DEPENDS ${instantiations_file})
|
||||
|
||||
# Extract explicit instantiations
|
||||
_vtkm_extract_instantiations(instantiations ${instantiations_file})
|
||||
|
||||
|
14
docs/changelog/array-range-instantiations.md
Normal file
14
docs/changelog/array-range-instantiations.md
Normal file
@ -0,0 +1,14 @@
|
||||
# Sped up compilation of ArrayRangeCompute.cxx
|
||||
|
||||
The file `ArrayRangeCompute.cxx` was taking a long time to compile with
|
||||
some device compilers. This is because it precompiles the range computation
|
||||
for many types of array structures. It thus compiled the same operation
|
||||
many times over.
|
||||
|
||||
The new implementation compiles just as many cases. However, the
|
||||
compilation is split into many different translation units using the
|
||||
instantiations feature of VTK-m's configuration. Although this rarely
|
||||
reduces the overall CPU time spent during compiling, it prevents parallel
|
||||
compiles from waiting for this one build to complete. It also avoids
|
||||
potential issues with compilers running out of resources as it tries to
|
||||
build a monolithic file.
|
@ -16,6 +16,8 @@
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
#include <vtkm/internal/Instantiations.h>
|
||||
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
|
||||
#include <limits>
|
||||
@ -114,7 +116,7 @@ struct ArrayRangeComputeImpl
|
||||
|
||||
|
||||
template <typename ArrayHandleType>
|
||||
inline vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeComputeTemplate(
|
||||
vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeComputeTemplate(
|
||||
const ArrayHandleType& input,
|
||||
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny{})
|
||||
{
|
||||
@ -134,4 +136,156 @@ inline vtkm::cont::ArrayHandle<vtkm::Range> ArrayRangeCompute(
|
||||
}
|
||||
} // namespace vtkm::cont
|
||||
|
||||
#define VTK_M_ARRAY_RANGE_COMPUTE_ALL_SCALARS(modifiers, ...) \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int8, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int16, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt16, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int32, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt32, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int64, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt64, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float32, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Float64, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<bool, __VA_ARGS__>& input, vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<char, __VA_ARGS__>& input, vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<signed VTKM_UNUSED_INT_TYPE, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<unsigned VTKM_UNUSED_INT_TYPE, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
|
||||
#define VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(modifiers, N, ...) \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Int8, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<UInt8, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<Int16, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<UInt16, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<Int32, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<UInt32, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<Int64, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<UInt64, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<Float32, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<Float64, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<bool, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<char, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<signed VTKM_UNUSED_INT_TYPE, N>, __VA_ARGS__>& input, \
|
||||
vtkm::cont::DeviceAdapterId device); \
|
||||
modifiers vtkm::cont::ArrayHandle<vtkm::Range> vtkm::cont::ArrayRangeComputeTemplate( \
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<unsigned VTKM_UNUSED_INT_TYPE, N>, __VA_ARGS__>& \
|
||||
input, \
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_SCALARS(extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
vtkm::cont::StorageTagBasic);
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
2,
|
||||
vtkm::cont::StorageTagBasic);
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
3,
|
||||
vtkm::cont::StorageTagBasic);
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
4,
|
||||
vtkm::cont::StorageTagBasic);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
2,
|
||||
vtkm::cont::StorageTagSOA);
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
3,
|
||||
vtkm::cont::StorageTagSOA);
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
4,
|
||||
vtkm::cont::StorageTagSOA);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(
|
||||
extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
3,
|
||||
vtkm::cont::StorageTagCartesianProduct<vtkm::cont::StorageTagBasic,
|
||||
vtkm::cont::StorageTagBasic,
|
||||
vtkm::cont::StorageTagBasic>);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_SCALARS(extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
vtkm::cont::StorageTagConstant);
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
2,
|
||||
vtkm::cont::StorageTagConstant);
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
3,
|
||||
vtkm::cont::StorageTagConstant);
|
||||
VTKM_INSTANTIATION_END
|
||||
VTKM_INSTANTIATION_BEGIN
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_ALL_VECN(extern template VTKM_CONT_TEMPLATE_EXPORT,
|
||||
4,
|
||||
vtkm::cont::StorageTagConstant);
|
||||
VTKM_INSTANTIATION_END
|
||||
|
||||
#endif //vtk_m_cont_ArrayRangeComputeTemplate_h
|
||||
|
@ -263,6 +263,14 @@ vtkm_install_headers(vtkm/cont
|
||||
${VTKm_BINARY_INCLUDE_DIR}/${kit_dir}/DefaultTypes.h
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Some operations are pre-compiled for many different types. Improve parallel
|
||||
# compiles by breaking them up into smaller units.
|
||||
vtkm_add_instantiations(array_range_instantiations
|
||||
INSTANTIATIONS_FILE ArrayRangeComputeTemplate.h
|
||||
)
|
||||
list(APPEND device_sources ${array_range_instantiations})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
vtkm_library( NAME vtkm_cont
|
||||
SOURCES ${sources}
|
||||
|
Loading…
Reference in New Issue
Block a user