1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 // This software is distributed WITHOUT ANY WARRANTY; without even
6 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7 // PURPOSE. See the above copyright notice for more information.
8 //
9 // Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10 // Copyright 2018 UT-Battelle, LLC.
11 // Copyright 2018 Los Alamos National Security.
12 //
13 // Under the terms of Contract DE-NA0003525 with NTESS,
14 // the U.S. Government retains certain rights in this software.
15 //
16 // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
17 // Laboratory (LANL), the U.S. Government retains certain rights in
18 // this software.
19 //============================================================================
20
21 #ifndef vtk_m_Swap_h
22 #define vtk_m_Swap_h
23
24 #include <vtkm/internal/ExportMacros.h>
25
26 #ifdef __CUDACC__
27 #include <thrust/swap.h>
28 #else
29 #include <algorithm>
30 #endif
31
32 namespace vtkm
33 {
34
35 /// Performs a swap operation. Safe to call from cuda code.
36 #ifdef __CUDACC__
37 template <typename T>
Swap(T & a,T & b)38 VTKM_EXEC_CONT void Swap(T& a, T& b)
39 {
40 using namespace thrust;
41 swap(a, b);
42 }
43 #else
44 template <typename T>
45 VTKM_EXEC_CONT void Swap(T& a, T& b)
46 {
47 using namespace std;
48 swap(a, b);
49 }
50 #endif
51
52 } // end namespace vtkm
53
54 #endif //vtk_m_Swap_h
55