MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / buffer

Class buffer

compute/include/boost/compute/buffer.hpp:54–191  ·  view source on GitHub ↗

\class buffer \brief A memory buffer on a compute device. The buffer class represents a memory buffer on a compute device. Buffers are allocated within a compute context. For example, to allocate a memory buffer for 32 float's: \snippet test/test_buffer.cpp constructor Once created, data can be copied to and from the buffer using the \c enqueue_*_buffer() methods in the command_queue class. Fo

Source from the content-addressed store, hash-verified

52///
53/// \see context, command_queue
54class buffer : public memory_object
55{
56public:
57 /// Creates a null buffer object.
58 buffer()
59 : memory_object()
60 {
61 }
62
63 /// Creates a buffer object for \p mem. If \p retain is \c true, the
64 /// reference count for \p mem will be incremented.
65 explicit buffer(cl_mem mem, bool retain = true)
66 : memory_object(mem, retain)
67 {
68 }
69
70 /// Create a new memory buffer in of \p size with \p flags in
71 /// \p context.
72 ///
73 /// \see_opencl_ref{clCreateBuffer}
74 buffer(const context &context,
75 size_t size,
76 cl_mem_flags flags = read_write,
77 void *host_ptr = 0)
78 {
79 cl_int error = 0;
80 m_mem = clCreateBuffer(context,
81 flags,
82 (std::max)(size, size_t(1)),
83 host_ptr,
84 &error);
85 if(!m_mem){
86 BOOST_THROW_EXCEPTION(opencl_error(error));
87 }
88 }
89
90 /// Creates a new buffer object as a copy of \p other.
91 buffer(const buffer &other)
92 : memory_object(other)
93 {
94 }
95
96 /// Copies the buffer object from \p other to \c *this.
97 buffer& operator=(const buffer &other)
98 {
99 if(this != &other){
100 memory_object::operator=(other);
101 }
102
103 return *this;
104 }
105
106 #ifndef BOOST_COMPUTE_NO_RVALUE_REFERENCES
107 /// Move-constructs a new buffer object from \p other.
108 buffer(buffer&& other) BOOST_NOEXCEPT
109 : memory_object(std::move(other))
110 {
111 }

Callers 8

AllocateGPUMemoryMethod · 0.85
AllocateGPUMemoryMethod · 0.85
test_transform.cppFile · 0.85
create_subbufferMethod · 0.85
valarrayClass · 0.85
resizeMethod · 0.85
_make_mapped_bufferMethod · 0.85
opencv_ocl_get_bufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected