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

Function dispatch_fill

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

Source from the content-addressed store, hash-verified

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