thrust
device_reference.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2013 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 
22 #pragma once
23 
24 #include <thrust/detail/config.h>
25 #include <thrust/device_ptr.h>
26 #include <thrust/detail/type_traits.h>
27 #include <thrust/detail/reference.h>
28 
29 namespace thrust
30 {
31 
185 template<typename T>
186  class device_reference
187  : public thrust::reference<
188  T,
189  thrust::device_ptr<T>,
190  thrust::device_reference<T>
191  >
192 {
193  private:
194  typedef thrust::reference<
195  T,
198  > super_t;
199 
200  public:
203  typedef typename super_t::value_type value_type;
204 
207  typedef typename super_t::pointer pointer;
208 
239  template<typename OtherT>
240  __host__ __device__
242  typename thrust::detail::enable_if_convertible<
244  pointer
245  >::type * = 0)
246  : super_t(other)
247  {}
248 
278  __host__ __device__
279  explicit device_reference(const pointer &ptr)
280  : super_t(ptr)
281  {}
282 
290  template<typename OtherT>
291  __host__ __device__
293 
300  __host__ __device__
301  device_reference &operator=(const value_type &x);
302 
303 // declare these members for the purpose of Doxygenating them
304 // they actually exist in a derived-from class
305 #if 0
306 
313  __host__ __device__
314  pointer operator&(void) const;
315 
322  __host__ __device__
323  operator value_type (void) const;
324 
328  __host__ __device__
329  void swap(device_reference &other);
330 
372  device_reference &operator++(void);
373 
420  value_type operator++(int);
421 
464  device_reference &operator+=(const T &rhs);
465 
507  device_reference &operator--(void);
508 
555  value_type operator--(int);
556 
599  device_reference &operator-=(const T &rhs);
600 
643  device_reference &operator*=(const T &rhs);
644 
687  device_reference &operator/=(const T &rhs);
688 
731  device_reference &operator%=(const T &rhs);
732 
775  device_reference &operator<<=(const T &rhs);
776 
819  device_reference &operator>>=(const T &rhs);
820 
863  device_reference &operator&=(const T &rhs);
864 
907  device_reference &operator|=(const T &rhs);
908 
951  device_reference &operator^=(const T &rhs);
952 #endif // end doxygen-only members
953 }; // end device_reference
954 
959 template<typename T>
960 __host__ __device__
962 
963 // declare these methods for the purpose of Doxygenating them
964 // they actually are defined for a derived-from class
965 #if 0
966 
972 template<typename T, typename charT, typename traits>
973 std::basic_ostream<charT, traits> &
974 operator<<(std::basic_ostream<charT, traits> &os, const device_reference<T> &y);
975 #endif
976 
980 } // end thrust
981 
982 #include <thrust/detail/device_reference.inl>
983 
A pointer to a variable which resides in the "device" system&#39;s memory space.
super_t::pointer pointer
Definition: device_reference.h:207
thrust is the top-level namespace which contains all Thrust functions and types.
Definition: addressof.h:14
__host__ __device__ device_reference(const pointer &ptr)
Definition: device_reference.h:279
__host__ __device__ device_reference(const device_reference< OtherT > &other, typename thrust::detail::enable_if_convertible< typename device_reference< OtherT >::pointer, pointer >::type *=0)
Definition: device_reference.h:241
super_t::value_type value_type
Definition: device_reference.h:203
Definition: device_malloc_allocator.h:36
Definition: device_ptr.h:37
__host__ __device__ device_reference & operator=(const device_reference< OtherT > &other)
__host__ __device__ void swap(device_reference< T > x, device_reference< T > y)