pinned_allocator.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef BOOST_COMPUTE_ALLOCATOR_PINNED_ALLOCATOR_HPP
  11. #define BOOST_COMPUTE_ALLOCATOR_PINNED_ALLOCATOR_HPP
  12. #include <boost/compute/allocator/buffer_allocator.hpp>
  13. namespace boost {
  14. namespace compute {
  15. template<class T>
  16. class pinned_allocator : public buffer_allocator<T>
  17. {
  18. public:
  19. explicit pinned_allocator(const context &context)
  20. : buffer_allocator<T>(context)
  21. {
  22. buffer_allocator<T>::set_mem_flags(
  23. buffer::read_write | buffer::alloc_host_ptr
  24. );
  25. }
  26. pinned_allocator(const pinned_allocator<T> &other)
  27. : buffer_allocator<T>(other)
  28. {
  29. }
  30. pinned_allocator<T>& operator=(const pinned_allocator<T> &other)
  31. {
  32. if(this != &other){
  33. buffer_allocator<T>::operator=(other);
  34. }
  35. return *this;
  36. }
  37. ~pinned_allocator()
  38. {
  39. }
  40. };
  41. } // end compute namespace
  42. } // end boost namespace
  43. #endif // BOOST_COMPUTE_ALLOCATOR_PINNED_ALLOCATOR_HPP