2 * Copyright 2008-2013 NVIDIA Corporation
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <thrust/detail/config.h>
18 #include <thrust/system/cuda/memory.h>
19 #include <thrust/system/cuda/detail/malloc_and_free.h>
25 // XXX WAR an issue with MSVC 2005 (cl v14.00) incorrectly implementing
26 // pointer_raw_pointer for pointer by specializing it here
27 // note that we specialize it here, before the use of raw_pointer_cast
28 // below, which causes pointer_raw_pointer's instantiation
29 #if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC) && (_MSC_VER <= 1400)
34 struct pointer_raw_pointer< thrust::cuda::pointer<T> >
36 typedef typename thrust::cuda::pointer<T>::raw_pointer type;
37 }; // end pointer_raw_pointer
49 template<typename OtherT>
52 ::operator=(const reference<OtherT> &other)
54 return super_t::operator=(other);
55 } // end reference::operator=()
60 ::operator=(const value_type &x)
62 return super_t::operator=(x);
63 } // end reference::operator=()
67 void swap(reference<T> a, reference<T> b)
72 pointer<void> malloc(std::size_t n)
75 return pointer<void>(thrust::system::cuda::detail::malloc(cuda_tag, n));
79 pointer<T> malloc(std::size_t n)
81 pointer<void> raw_ptr = thrust::system::cuda::malloc(sizeof(T) * n);
82 return pointer<T>(reinterpret_cast<T*>(raw_ptr.get()));
85 void free(pointer<void> ptr)
88 return thrust::system::cuda::detail::free(cuda_tag, ptr.get());