• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10 
11 #ifndef BOOST_COMPUTE_ALLOCATOR_PINNED_ALLOCATOR_HPP
12 #define BOOST_COMPUTE_ALLOCATOR_PINNED_ALLOCATOR_HPP
13 
14 #include <boost/compute/allocator/buffer_allocator.hpp>
15 
16 namespace boost {
17 namespace compute {
18 
19 template<class T>
20 class pinned_allocator : public buffer_allocator<T>
21 {
22 public:
pinned_allocator(const context & context)23     explicit pinned_allocator(const context &context)
24         : buffer_allocator<T>(context)
25     {
26         buffer_allocator<T>::set_mem_flags(
27             buffer::read_write | buffer::alloc_host_ptr
28         );
29     }
30 
pinned_allocator(const pinned_allocator<T> & other)31     pinned_allocator(const pinned_allocator<T> &other)
32         : buffer_allocator<T>(other)
33     {
34     }
35 
operator =(const pinned_allocator<T> & other)36     pinned_allocator<T>& operator=(const pinned_allocator<T> &other)
37     {
38         if(this != &other){
39             buffer_allocator<T>::operator=(other);
40         }
41 
42         return *this;
43     }
44 
~pinned_allocator()45     ~pinned_allocator()
46     {
47     }
48 };
49 
50 } // end compute namespace
51 } // end boost namespace
52 
53 #endif // BOOST_COMPUTE_ALLOCATOR_PINNED_ALLOCATOR_HPP
54