VTK-m
2.2
vtkm
Swap.h
Go to the documentation of this file.
1
//============================================================================
2
// Copyright (c) Kitware, Inc.
3
// All rights reserved.
4
// See LICENSE.txt for details.
5
//
6
// This software is distributed WITHOUT ANY WARRANTY; without even
7
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8
// PURPOSE. See the above copyright notice for more information.
9
//============================================================================
10
11
#ifndef vtk_m_Swap_h
12
#define vtk_m_Swap_h
13
14
#include <
vtkm/internal/ExportMacros.h
>
15
16
#include <algorithm>
17
18
namespace
vtkm
19
{
20
22
#if defined(VTKM_CUDA) && defined(VTKM_CUDA_DEVICE_PASS)
23
// CUDA 12 adds a `cub::Swap` function that creates ambiguity with `vtkm::Swap`.
24
// This happens when a function from the `cub` namespace is called with an object of a class
25
// defined in the `vtkm` namespace as an argument. If that function has an unqualified call to
26
// `Swap`, it results in ADL being used, causing the templated functions `cub::Swap` and
27
// `vtkm::Swap` to conflict.
28
#if defined(VTKM_CUDA_VERSION_MAJOR) && (VTKM_CUDA_VERSION_MAJOR >= 12)
29
using
cub::Swap
;
30
#else
31
template
<
typename
T>
32
VTKM_EXEC_CONT
inline
void
Swap
(T& a, T& b)
33
{
34
T temp = a;
35
a = b;
36
b = temp;
37
}
38
#endif
39
#elif defined(VTKM_HIP)
40
template
<
typename
T>
41
__host__
inline
void
Swap
(T& a, T& b)
42
{
43
using
std::swap;
44
swap(a, b);
45
}
46
template
<
typename
T>
47
__device__
inline
void
Swap
(T& a, T& b)
48
{
49
T temp = a;
50
a = b;
51
b = temp;
52
}
53
#else
54
template
<
typename
T>
55
VTKM_EXEC_CONT
inline
void
Swap
(T& a, T& b)
56
{
57
using
std::swap;
58
swap(a, b);
59
}
60
#endif
61
62
}
// end namespace vtkm
63
64
#endif //vtk_m_Swap_h
vtkm
Groups connected points that have the same field value.
Definition:
Atomic.h:19
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition:
ExportMacros.h:52
ExportMacros.h
vtkm::Swap
void Swap(T &a, T &b)
Performs a swap operation. Safe to call from cuda code.
Definition:
Swap.h:55
Generated by
1.8.17