~ubuntu-branches/ubuntu/utopic/libthrust/utopic

« back to all changes in this revision

Viewing changes to system/cuda/detail/iter_swap.h

  • Committer: Package Import Robot
  • Author(s): Andreas Beckmann
  • Date: 2013-07-10 12:57:33 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130710125733-my19jic71sqsabaj
Tags: 1.7.0-1
* New upstream release.  (Closes: #715362)
* Update watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright 2008-2012 NVIDIA Corporation
 
3
 *
 
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
 
5
 *  you may not use this file except in compliance with the License.
 
6
 *  You may obtain a copy of the License at
 
7
 *
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 *  Unless required by applicable law or agreed to in writing, software
 
11
 *  distributed under the License is distributed on an "AS IS" BASIS,
 
12
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 *  See the License for the specific language governing permissions and
 
14
 *  limitations under the License.
 
15
 */
 
16
 
 
17
#pragma once
 
18
 
 
19
#include <thrust/detail/config.h>
 
20
#include <thrust/detail/raw_pointer_cast.h>
 
21
#include <thrust/swap.h>
 
22
 
 
23
namespace thrust
 
24
{
 
25
namespace system
 
26
{
 
27
namespace cuda
 
28
{
 
29
namespace detail
 
30
{
 
31
 
 
32
 
 
33
template<typename Pointer1, typename Pointer2>
 
34
inline __host__ __device__
 
35
void iter_swap(tag, Pointer1 a, Pointer2 b)
 
36
{
 
37
  // XXX war nvbugs/881631
 
38
  struct war_nvbugs_881631
 
39
  {
 
40
    __host__ inline static void host_path(Pointer1 a, Pointer2 b)
 
41
    {
 
42
      thrust::swap_ranges(a, a + 1, b);
 
43
    }
 
44
 
 
45
    __device__ inline static void device_path(Pointer1 a, Pointer2 b)
 
46
    {
 
47
      using thrust::swap;
 
48
      swap(*thrust::raw_pointer_cast(a),
 
49
           *thrust::raw_pointer_cast(b));
 
50
    }
 
51
  };
 
52
 
 
53
#ifndef __CUDA_ARCH__
 
54
  return war_nvbugs_881631::host_path(a,b);
 
55
#else
 
56
  return war_nvbugs_881631::device_path(a,b);
 
57
#endif // __CUDA_ARCH__
 
58
} // end iter_swap()
 
59
 
 
60
 
 
61
} // end detail
 
62
} // end cuda
 
63
} // end system
 
64
} // end thrust
 
65