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

« back to all changes in this revision

Viewing changes to detail/temporary_buffer.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/execution_policy.h>
 
21
#include <thrust/pair.h>
 
22
#include <thrust/detail/pointer.h>
 
23
#include <thrust/detail/raw_pointer_cast.h>
 
24
#include <thrust/system/detail/generic/temporary_buffer.h>
 
25
#include <thrust/system/detail/adl/temporary_buffer.h>
 
26
 
 
27
namespace thrust
 
28
{
 
29
namespace detail
 
30
{
 
31
namespace get_temporary_buffer_detail
 
32
{
 
33
 
 
34
 
 
35
template<typename T, typename DerivedPolicy, typename Pair>
 
36
  thrust::pair<thrust::pointer<T,DerivedPolicy>, typename thrust::pointer<T,DerivedPolicy>::difference_type>
 
37
    down_cast_pair(Pair p)
 
38
{
 
39
  // XXX should use a hypothetical thrust::static_pointer_cast here
 
40
  thrust::pointer<T,DerivedPolicy> ptr = thrust::pointer<T,DerivedPolicy>(static_cast<T*>(thrust::raw_pointer_cast(p.first)));
 
41
 
 
42
  typedef thrust::pair<thrust::pointer<T,DerivedPolicy>, typename thrust::pointer<T,DerivedPolicy>::difference_type> result_type;
 
43
  return result_type(ptr, p.second);
 
44
} // end down_cast_pair()
 
45
 
 
46
 
 
47
} // end get_temporary_buffer_detail
 
48
} // end detail
 
49
 
 
50
 
 
51
template<typename T, typename DerivedPolicy>
 
52
  thrust::pair<thrust::pointer<T,DerivedPolicy>, typename thrust::pointer<T,DerivedPolicy>::difference_type>
 
53
    get_temporary_buffer(const thrust::detail::execution_policy_base<DerivedPolicy> &exec, typename thrust::pointer<T,DerivedPolicy>::difference_type n)
 
54
{
 
55
  using thrust::system::detail::generic::get_temporary_buffer;
 
56
 
 
57
  return thrust::detail::get_temporary_buffer_detail::down_cast_pair<T,DerivedPolicy>(get_temporary_buffer<T>(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), n));
 
58
} // end get_temporary_buffer()
 
59
 
 
60
 
 
61
template<typename DerivedPolicy, typename Pointer>
 
62
  void return_temporary_buffer(const thrust::detail::execution_policy_base<DerivedPolicy> &exec, Pointer p)
 
63
{
 
64
  using thrust::system::detail::generic::return_temporary_buffer;
 
65
 
 
66
  return return_temporary_buffer(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), p);
 
67
} // end return_temporary_buffer()
 
68
 
 
69
 
 
70
} // end thrust
 
71