本人 CUDA小白一枚,要是有什么不对,还望各位大佬指点。
本文及后面的几篇将分别从几个方面来大概阐述一下Thrust的一些接口。原来的网址在这里
6.1 Allocators
templateclass thrust::device_ptr_memory_resource; template class thrust::device_allocator; template class thrust::device_malloc_allocator; template class thrust::device_new_allocator; template class thrust::mr::allocator; template class thrust::mr::stateless_resource_allocator; template using thrust::mr::polymorphic_allocator = see below; template __host__ __device__ bool thrust::mr::operator==(const allocator< T, MR > & lhs, const allocator< T, MR > & rhs); template __host__ __device__ bool thrust::mr::operator!=(const allocator< T, MR > & lhs, const allocator< T, MR > & rhs);
6.2 Memory Resources
templateclass thrust::mr::disjoint_unsynchronized_pool_resource; template struct thrust::mr::disjoint_synchronized_pool_resource; template class thrust::mr::memory_resource; class thrust::mr::memory_resource< void * >; class thrust::mr::new_delete_resource; template class thrust::mr::unsynchronized_pool_resource; struct thrust::mr::pool_options; template struct thrust::mr::synchronized_pool_resource;
6.3 device_ptr
templateclass thrust::device_reference; template class thrust::device_ptr; // 删除 device_reference template void thrust::device_delete(thrust::device_ptr< T > ptr, const size_t n = 1); // 释放 device_reference void thrust::device_free(thrust::device_ptr< void > ptr); // malloc device_reference 与 device_free thrust::device_ptr< void > thrust::device_malloc(const std::size_t n); // malloc device_reference 与 device_free template thrust::device_ptr< T > thrust::device_malloc(const std::size_t n); // new device_reference 与 device_delete template device_ptr< T > thrust::device_new( device_ptr< void > p, const size_t n = 1); // new device_reference 与 device_delete template device_ptr< T > thrust::device_new( device_ptr< void > p, const T & exemplar, const size_t n = 1); template device_ptr< T > thrust::device_new(const size_t n = 1); template __host__ std::basic_ostream< CharT, Traits > & thrust::operator<<(std::basic_ostream< CharT, Traits > & os, device_ptr< T > const & dp); // 类型转换 template __host__ __device__ device_ptr< T > thrust::device_pointer_cast(T * ptr); // 类型转换 template __host__ __device__ device_ptr< T > thrust::device_pointer_cast(device_ptr< T > const & dptr); // 元素交换 template __host__ __device__ void thrust::swap( device_reference< T > & x, device_reference< T > & y); template std::basic_ostream< charT, traits > & thrust::operator<<(std::basic_ostream< charT, traits > & os, const device_reference< T > & y); // malloc template __host__ __device__ pointer< void, DerivedPolicy > thrust::malloc( const thrust::detail::execution_policy_base< DerivedPolicy > & system, std::size_t n); // malloc template __host__ __device__ pointer< T, DerivedPolicy > thrust::malloc( const thrust::detail::execution_policy_base< DerivedPolicy > & system, std::size_t n); template __host__ __device__ thrust::pair< thrust::pointer< T, DerivedPolicy >, typename thrust::pointer< T, DerivedPolicy >::difference_type > thrust::get_temporary_buffer( const thrust::detail::execution_policy_base< DerivedPolicy > & system, typename thrust::pointer< T, DerivedPolicy >::difference_type n); // free 与 malloc 对应 template __host__ __device__ void thrust::free( const thrust::detail::execution_policy_base< DerivedPolicy > & system, Pointer ptr); template __host__ __device__ void thrust::return_temporary_buffer( const thrust::detail::execution_policy_base< DerivedPolicy > & system, Pointer p, std::ptrdiff_t n); template __host__ __device__ thrust::detail::pointer_traits< Pointer >::raw_pointer thrust::raw_pointer_cast(Pointer ptr); template __host__ __device__ detail::raw_reference< T >::type thrust::raw_reference_cast(T & ref); template __host__ __device__ detail::raw_reference< constT >::type thrust::raw_reference_cast(const T & ref);



