MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / Buffer

Method Buffer

include/CL/opencl.hpp:9118–9166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9116
9117template< typename IteratorType >
9118Buffer::Buffer(
9119 const Context &context,
9120 IteratorType startIterator,
9121 IteratorType endIterator,
9122 bool readOnly,
9123 bool useHostPtr,
9124 cl_int* err)
9125{
9126 typedef typename std::iterator_traits<IteratorType>::value_type DataType;
9127 cl_int error;
9128
9129 cl_mem_flags flags = 0;
9130 if( readOnly ) {
9131 flags |= CL_MEM_READ_ONLY;
9132 }
9133 else {
9134 flags |= CL_MEM_READ_WRITE;
9135 }
9136 if( useHostPtr ) {
9137 flags |= CL_MEM_USE_HOST_PTR;
9138 }
9139
9140 size_type size = sizeof(DataType)*(endIterator - startIterator);
9141
9142 if( useHostPtr ) {
9143 object_ = ::clCreateBuffer(context(), flags, size, const_cast<DataType*>(&*startIterator), &error);
9144 } else {
9145 object_ = ::clCreateBuffer(context(), flags, size, 0, &error);
9146 }
9147
9148 detail::errHandler(error, __CREATE_BUFFER_ERR);
9149 if (err != nullptr) {
9150 *err = error;
9151 }
9152
9153 if( !useHostPtr ) {
9154 CommandQueue queue(context, 0, &error);
9155 detail::errHandler(error, __CREATE_BUFFER_ERR);
9156 if (err != nullptr) {
9157 *err = error;
9158 }
9159
9160 error = cl::copy(queue, startIterator, endIterator, *this);
9161 detail::errHandler(error, __CREATE_BUFFER_ERR);
9162 if (err != nullptr) {
9163 *err = error;
9164 }
9165 }
9166}
9167
9168template< typename IteratorType >
9169Buffer::Buffer(

Callers

nothing calls this directly

Calls 3

clCreateBufferFunction · 0.85
errHandlerFunction · 0.85
copyFunction · 0.70

Tested by

no test coverage detected