Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:44:33

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013 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_CONTAINER_DETAIL_SCALAR_HPP
0012 #define BOOST_COMPUTE_CONTAINER_DETAIL_SCALAR_HPP
0013 
0014 #include <boost/compute/buffer.hpp>
0015 #include <boost/compute/event.hpp>
0016 #include <boost/compute/detail/read_write_single_value.hpp>
0017 
0018 namespace boost {
0019 namespace compute {
0020 namespace detail {
0021 
0022 // scalar<T> provides a trivial "container" that stores a
0023 // single value in a memory buffer on a compute device
0024 template<class T>
0025 class scalar
0026 {
0027 public:
0028     typedef T value_type;
0029 
0030     scalar(const context &context)
0031         : m_buffer(context, sizeof(T))
0032     {
0033     }
0034 
0035     ~scalar()
0036     {
0037     }
0038 
0039     T read(command_queue &queue) const
0040     {
0041         return read_single_value<T>(m_buffer, 0, queue);
0042     }
0043 
0044     event write(const T &value, command_queue &queue)
0045     {
0046         return write_single_value<T>(value, m_buffer, 0, queue);
0047     }
0048 
0049     const buffer& get_buffer() const
0050     {
0051         return m_buffer;
0052     }
0053 
0054 private:
0055     buffer m_buffer;
0056 };
0057 
0058 } // end detail namespace
0059 } // end compute namespace
0060 } // end boost namespace
0061 
0062 #endif // BOOST_COMPUTE_CONTAINER_DETAIL_SCALAR_HPP