diff --git a/docs/changelog/swap-cub-include.md b/docs/changelog/swap-cub-include.md new file mode 100644 index 0000000000000000000000000000000000000000..f68367b093d4b2995fdaa5d5926ffa08e8f20ac5 --- /dev/null +++ b/docs/changelog/swap-cub-include.md @@ -0,0 +1,10 @@ +Fix include for cub::Swap + +A problem we have with the `vtkm::Swap` method is that it can be +ambiguous with the `cub::Swap` method that is part of the CUDA CUB +library. We get around this problem by using the CUB version of the +function when it is available. + +However, we were missing an include statement that necessarily provided +`cub::Swap`. This function is now explicitly provided so that we no +longer rely on including it indirectly elsewhere. diff --git a/vtkm/Swap.h b/vtkm/Swap.h index 342c5a20c97bb451a4dca8a8bc1a0bebf2190b21..6a77e1ec298bdd81c9139b1af8f5654683c89993 100644 --- a/vtkm/Swap.h +++ b/vtkm/Swap.h @@ -19,6 +19,14 @@ #include #endif +// Below there is some code to deal with conflicts between VTK-m's Swap and the Swap that comes +// with CUDA's CUB. We need to make sure that the Swap function gets included so that our +// defensive code works either way. +#if defined(VTKM_CUDA) && defined(VTKM_CUDA_DEVICE_PASS) && defined(VTKM_CUDA_VERSION_MAJOR) && \ + (VTKM_CUDA_VERSION_MAJOR >= 12) +#include +#endif + namespace vtkm {