| 97 | // specialization which uses clEnqueueFillBuffer for buffer iterators |
| 98 | template<class BufferIterator, class T> |
| 99 | inline void |
| 100 | dispatch_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 | |
| 145 | template<class BufferIterator, class T> |
| 146 | inline future<void> |
no test coverage detected