12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #ifndef BOOST_COMPUTE_MEMORY_LOCAL_BUFFER_HPP
- #define BOOST_COMPUTE_MEMORY_LOCAL_BUFFER_HPP
- #include <boost/compute/cl.hpp>
- #include <boost/compute/kernel.hpp>
- namespace boost {
- namespace compute {
- template<class T>
- class local_buffer
- {
- public:
-
- local_buffer(const size_t size)
- : m_size(size)
- {
- }
-
- local_buffer(const local_buffer &other)
- : m_size(other.m_size)
- {
- }
-
- local_buffer& operator=(const local_buffer &other)
- {
- if(this != &other){
- m_size = other.m_size;
- }
- return *this;
- }
-
- ~local_buffer()
- {
- }
-
- size_t size() const
- {
- return m_size;
- }
- private:
- size_t m_size;
- };
- namespace detail {
- template<class T>
- struct set_kernel_arg<local_buffer<T> >
- {
- void operator()(kernel &kernel_, size_t index, const local_buffer<T> &buffer)
- {
- kernel_.set_arg(index, buffer.size() * sizeof(T), 0);
- }
- };
- }
- }
- }
- #endif
|