Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:58

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_ALLOCATOR_PINNED_ALLOCATOR_HPP
0012 #define BOOST_COMPUTE_ALLOCATOR_PINNED_ALLOCATOR_HPP
0013 
0014 #include <boost/compute/allocator/buffer_allocator.hpp>
0015 
0016 namespace boost {
0017 namespace compute {
0018 
0019 template<class T>
0020 class pinned_allocator : public buffer_allocator<T>
0021 {
0022 public:
0023     explicit pinned_allocator(const context &context)
0024         : buffer_allocator<T>(context)
0025     {
0026         buffer_allocator<T>::set_mem_flags(
0027             buffer::read_write | buffer::alloc_host_ptr
0028         );
0029     }
0030 
0031     pinned_allocator(const pinned_allocator<T> &other)
0032         : buffer_allocator<T>(other)
0033     {
0034     }
0035 
0036     pinned_allocator<T>& operator=(const pinned_allocator<T> &other)
0037     {
0038         if(this != &other){
0039             buffer_allocator<T>::operator=(other);
0040         }
0041 
0042         return *this;
0043     }
0044 
0045     ~pinned_allocator()
0046     {
0047     }
0048 };
0049 
0050 } // end compute namespace
0051 } // end boost namespace
0052 
0053 #endif // BOOST_COMPUTE_ALLOCATOR_PINNED_ALLOCATOR_HPP