From 0f70c963ae0e754318eadc79c4f6fc67dad5e586 Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Mon, 3 Feb 2025 09:24:26 -0500 Subject: [PATCH] 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. Thanks to Jens Goebbert for this fix. --- docs/changelog/swap-cub-include.md | 10 ++++++++++ vtkm/Swap.h | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 docs/changelog/swap-cub-include.md diff --git a/docs/changelog/swap-cub-include.md b/docs/changelog/swap-cub-include.md new file mode 100644 index 0000000000..f68367b093 --- /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 342c5a20c9..6a77e1ec29 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 { -- GitLab