MCPcopy Create free account
hub / github.com/boostorg/compute / dispatch_fill

Function dispatch_fill

include/boost/compute/algorithm/fill.hpp:102–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100// specialization which uses clEnqueueFillBuffer for buffer iterators
101template<class BufferIterator, class T>
102inline void
103dispatch_fill(BufferIterator first,
104 size_t count,
105 const T &value,
106 command_queue &queue,
107 typename boost::enable_if<
108 is_valid_fill_buffer_iterator<BufferIterator>
109 >::type* = 0)
110{
111 typedef typename std::iterator_traits<BufferIterator>::value_type value_type;
112
113 if(count == 0){
114 // nothing to do
115 return;
116 }
117
118 // check if the device supports OpenCL 1.2 (required for enqueue_fill_buffer)
119 if(!queue.check_device_version(1, 2)){
120 return fill_with_copy(first, count, value, queue);
121 }
122
123 value_type pattern = static_cast<value_type>(value);
124 size_t offset = static_cast<size_t>(first.get_index());
125
126 if(count == 1){
127 // use clEnqueueWriteBuffer() directly when writing a single value
128 // to the device buffer. this is potentially more efficient and also
129 // works around a bug in the intel opencl driver.
130 queue.enqueue_write_buffer(
131 first.get_buffer(),
132 offset * sizeof(value_type),
133 sizeof(value_type),
134 &pattern
135 );
136 }
137 else {
138 queue.enqueue_fill_buffer(
139 first.get_buffer(),
140 &pattern,
141 sizeof(value_type),
142 offset * sizeof(value_type),
143 count * sizeof(value_type)
144 );
145 }
146}
147
148template<class BufferIterator, class T>
149inline future<void>

Callers 1

fillFunction · 0.85

Calls 7

fill_with_copyFunction · 0.85
check_device_versionMethod · 0.80
enqueue_write_bufferMethod · 0.80
enqueue_fill_bufferMethod · 0.80
enqueue_svm_fillMethod · 0.80
get_indexMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected