mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Fix compile issues when using cuda 12
CUDA 12 adds a `cub::Swap` function that creates ambiguity with `vtkm::Swap`. This happens when a function from the `cub` namespace is called with an object of a class defined in the `vtkm` namespace as an argument. If that function has an unqualified call to `Swap`, it results in ADL being used, causing the templated functions `cub::Swap` and `vtkm::Swap` to conflict.
This commit is contained in:
parent
146b051436
commit
5d0481342a
24
vtkm/Swap.h
24
vtkm/Swap.h
@ -24,21 +24,31 @@ namespace vtkm
|
|||||||
|
|
||||||
/// Performs a swap operation. Safe to call from cuda code.
|
/// Performs a swap operation. Safe to call from cuda code.
|
||||||
#if defined(VTKM_CUDA)
|
#if defined(VTKM_CUDA)
|
||||||
|
// CUDA 12 adds a `cub::Swap` function that creates ambiguity with `vtkm::Swap`.
|
||||||
|
// This happens when a function from the `cub` namespace is called with an object of a class
|
||||||
|
// defined in the `vtkm` namespace as an argument. If that function has an unqualified call to
|
||||||
|
// `Swap`, it results in ADL being used, causing the templated functions `cub::Swap` and
|
||||||
|
// `vtkm::Swap` to conflict.
|
||||||
|
#if defined(VTKM_CUDA_VERSION_MAJOR) && (VTKM_CUDA_VERSION_MAJOR >= 12) && \
|
||||||
|
defined(VTKM_CUDA_DEVICE_PASS)
|
||||||
|
using cub::Swap;
|
||||||
|
#else
|
||||||
template <typename T>
|
template <typename T>
|
||||||
VTKM_EXEC_CONT void Swap(T& a, T& b)
|
VTKM_EXEC_CONT inline void Swap(T& a, T& b)
|
||||||
{
|
{
|
||||||
using namespace thrust;
|
using thrust::swap;
|
||||||
swap(a, b);
|
swap(a, b);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#elif defined(VTKM_HIP)
|
#elif defined(VTKM_HIP)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
__host__ void Swap(T& a, T& b)
|
__host__ inline void Swap(T& a, T& b)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using std::swap;
|
||||||
swap(a, b);
|
swap(a, b);
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
__device__ void Swap(T& a, T& b)
|
__device__ inline void Swap(T& a, T& b)
|
||||||
{
|
{
|
||||||
T temp = a;
|
T temp = a;
|
||||||
a = b;
|
a = b;
|
||||||
@ -46,9 +56,9 @@ __device__ void Swap(T& a, T& b)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
template <typename T>
|
template <typename T>
|
||||||
VTKM_EXEC_CONT void Swap(T& a, T& b)
|
VTKM_EXEC_CONT inline void Swap(T& a, T& b)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using std::swap;
|
||||||
swap(a, b);
|
swap(a, b);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <vtkm/exec/cuda/internal/ThrustPatches.h>
|
#include <vtkm/exec/cuda/internal/ThrustPatches.h>
|
||||||
VTKM_THIRDPARTY_PRE_INCLUDE
|
VTKM_THIRDPARTY_PRE_INCLUDE
|
||||||
#include <thrust/execution_policy.h>
|
#include <thrust/execution_policy.h>
|
||||||
|
#include <thrust/sort.h>
|
||||||
#include <thrust/system/cuda/execution_policy.h>
|
#include <thrust/system/cuda/execution_policy.h>
|
||||||
#include <thrust/system/cuda/memory.h>
|
#include <thrust/system/cuda/memory.h>
|
||||||
VTKM_THIRDPARTY_POST_INCLUDE
|
VTKM_THIRDPARTY_POST_INCLUDE
|
||||||
|
Loading…
Reference in New Issue
Block a user