VTK-m
2.3
Main Page
Related Pages
Modules
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerations
Enumerator
Related Functions
Files
File List
File Members
All
a
c
d
e
f
h
i
k
m
o
p
q
r
s
t
u
v
w
x
y
Variables
Typedefs
Macros
e
k
m
q
s
t
u
v
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
// Below there is some code to deal with conflicts between VTK-m's Swap and the Swap that comes
19
// with CUDA's CUB. We need to make sure that the Swap function gets included so that our
20
// defensive code works either way.
21
#if defined(VTKM_CUDA) && defined(VTKM_CUDA_DEVICE_PASS) && defined(VTKM_CUDA_VERSION_MAJOR) && \
22
(VTKM_CUDA_VERSION_MAJOR >= 12)
23
#include <cub/thread/thread_sort.cuh>
24
#endif
25
26
namespace
vtkm
27
{
28
30
#if defined(VTKM_CUDA) && defined(VTKM_CUDA_DEVICE_PASS)
31
// CUDA 12 adds a `cub::Swap` function that creates ambiguity with `vtkm::Swap`.
32
// This happens when a function from the `cub` namespace is called with an object of a class
33
// defined in the `vtkm` namespace as an argument. If that function has an unqualified call to
34
// `Swap`, it results in ADL being used, causing the templated functions `cub::Swap` and
35
// `vtkm::Swap` to conflict.
36
#if defined(VTKM_CUDA_VERSION_MAJOR) && (VTKM_CUDA_VERSION_MAJOR >= 12)
37
using
cub::Swap
;
38
#else
39
template
<
typename
T>
40
VTKM_EXEC_CONT
inline
void
Swap
(T& a, T& b)
41
{
42
T temp = a;
43
a = b;
44
b = temp;
45
}
46
#endif
47
#elif defined(VTKM_HIP)
48
template
<
typename
T>
49
__host__
inline
void
Swap
(T& a, T& b)
50
{
51
using
std::swap;
52
swap(a, b);
53
}
54
template
<
typename
T>
55
__device__
inline
void
Swap
(T& a, T& b)
56
{
57
T temp = a;
58
a = b;
59
b = temp;
60
}
61
#else
62
template
<
typename
T>
63
VTKM_EXEC_CONT
inline
void
Swap
(T& a, T& b)
64
{
65
using
std::swap;
66
swap(a, b);
67
}
68
#endif
69
70
}
// end namespace vtkm
71
72
#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:63
Generated by
1.8.17