Created
May 17, 2016 08:40
-
-
Save jszuppe/5605c1057f6f0282437c777dd33ea24f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class HostIterator, class DeviceIterator> | |
inline DeviceIterator copy(HostIterator first, | |
HostIterator last, | |
DeviceIterator result, | |
boost::compute::command_queue &queue) | |
{ | |
... | |
// map result buffer to host | |
value_type *pointer = static_cast<value_type*>( | |
queue.enqueue_map_buffer( | |
result.get_buffer(), | |
CL_MAP_WRITE, | |
offset * sizeof(value_type), | |
count * sizeof(value_type) | |
) | |
); | |
// copy [first; last) to result buffer | |
std::copy(first, last, pointer); | |
// unmap result buffer | |
boost::compute::event unmapEvent = queue.enqueue_unmap_buffer( | |
result.get_buffer(), | |
static_cast<void*>(pointer) | |
); | |
unmapEvent.wait(); | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment