/usr/include/boost/compute/algorithm/detail
NameSizeModeActions
balanced_path.hpp62670644editdlrm
binary_find.hpp46260644editdlrm
compact.hpp21880644editdlrm
copy_on_device.hpp73820644editdlrm
copy_to_device.hpp67310644editdlrm
copy_to_host.hpp66580644editdlrm
count_if_with_ballot.hpp26050644editdlrm
count_if_with_reduce.hpp26480644editdlrm
count_if_with_threads.hpp42410644editdlrm
find_extrema.hpp24410644editdlrm
find_extrema_on_cpu.hpp53330644editdlrm
find_extrema_with_atomics.hpp42510644editdlrm
find_extrema_with_reduce.hpp186720644editdlrm
find_if_with_atomics.hpp85090644editdlrm
inplace_reduce.hpp48390644editdlrm
insertion_sort.hpp60300644editdlrm
merge_path.hpp38740644editdlrm
merge_sort_on_cpu.hpp146540644editdlrm
merge_sort_on_gpu.hpp220930644editdlrm
merge_with_merge_path.hpp73390644editdlrm
radix_sort.hpp155020644editdlrm
random_fill.hpp18800644editdlrm
reduce_by_key.hpp52430644editdlrm
reduce_by_key_with_scan.hpp237350644editdlrm
reduce_on_cpu.hpp39490644editdlrm
reduce_on_gpu.hpp103910644editdlrm
scan.hpp15450644editdlrm
scan_on_cpu.hpp70560644editdlrm
scan_on_gpu.hpp113200644editdlrm
search_all.hpp25790644editdlrm
serial_accumulate.hpp19900644editdlrm
serial_count_if.hpp22430644editdlrm
serial_find_extrema.hpp31510644editdlrm
serial_merge.hpp35040644editdlrm
serial_reduce.hpp21450644editdlrm
serial_reduce_by_key.hpp42400644editdlrm
serial_scan.hpp31840644editdlrm
Edit: /usr/include/boost/compute/algorithm/detail/copy_to_host.hpp (6658B)
//---------------------------------------------------------------------------// // Copyright (c) 2013 Kyle Lutz // // Distributed under the Boost Software License, Version 1.0 // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // // See http://boostorg.github.com/compute for more information. //---------------------------------------------------------------------------// #ifndef BOOST_COMPUTE_ALGORITHM_DETAIL_COPY_TO_HOST_HPP #define BOOST_COMPUTE_ALGORITHM_DETAIL_COPY_TO_HOST_HPP #include #include #include #include #include #include #include namespace boost { namespace compute { namespace detail { template inline HostIterator copy_to_host(DeviceIterator first, DeviceIterator last, HostIterator result, command_queue &queue, const wait_list &events) { typedef typename std::iterator_traits::value_type value_type; size_t count = iterator_range_size(first, last); if(count == 0){ return result; } const buffer &buffer = first.get_buffer(); size_t offset = first.get_index(); queue.enqueue_read_buffer(buffer, offset * sizeof(value_type), count * sizeof(value_type), ::boost::addressof(*result), events); return iterator_plus_distance(result, count); } template inline HostIterator copy_to_host_map(DeviceIterator first, DeviceIterator last, HostIterator result, command_queue &queue, const wait_list &events) { typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::difference_type difference_type; size_t count = iterator_range_size(first, last); if(count == 0){ return result; } size_t offset = first.get_index(); // map [first; last) buffer to host value_type *pointer = static_cast( queue.enqueue_map_buffer( first.get_buffer(), CL_MAP_READ, offset * sizeof(value_type), count * sizeof(value_type), events ) ); // copy [first; last) to result buffer std::copy( pointer, pointer + static_cast(count), result ); // unmap [first; last) boost::compute::event unmap_event = queue.enqueue_unmap_buffer( first.get_buffer(), static_cast(pointer) ); unmap_event.wait(); return iterator_plus_distance(result, count); } template inline future copy_to_host_async(DeviceIterator first, DeviceIterator last, HostIterator result, command_queue &queue, const wait_list &events) { typedef typename std::iterator_traits::value_type value_type; size_t count = iterator_range_size(first, last); if(count == 0){ return future(); } const buffer &buffer = first.get_buffer(); size_t offset = first.get_index(); event event_ = queue.enqueue_read_buffer_async(buffer, offset * sizeof(value_type), count * sizeof(value_type), ::boost::addressof(*result), events); return make_future(iterator_plus_distance(result, count), event_); } #ifdef BOOST_COMPUTE_CL_VERSION_2_0 // copy_to_host() specialization for svm_ptr template inline HostIterator copy_to_host(svm_ptr first, svm_ptr last, HostIterator result, command_queue &queue, const wait_list &events) { size_t count = iterator_range_size(first, last); if(count == 0){ return result; } queue.enqueue_svm_memcpy( ::boost::addressof(*result), first.get(), count * sizeof(T), events ); return result + count; } template inline future copy_to_host_async(svm_ptr first, svm_ptr last, HostIterator result, command_queue &queue, const wait_list &events) { size_t count = iterator_range_size(first, last); if(count == 0){ return future(); } event event_ = queue.enqueue_svm_memcpy_async( ::boost::addressof(*result), first.get(), count * sizeof(T), events ); return make_future(iterator_plus_distance(result, count), event_); } template inline HostIterator copy_to_host_map(svm_ptr first, svm_ptr last, HostIterator result, command_queue &queue, const wait_list &events) { size_t count = iterator_range_size(first, last); if(count == 0){ return result; } // map queue.enqueue_svm_map(first.get(), count * sizeof(T), CL_MAP_READ, events); // copy [first; last) to result std::copy( static_cast(first.get()), static_cast(last.get()), result ); // unmap [first; last) queue.enqueue_svm_unmap(first.get()).wait(); return iterator_plus_distance(result, count); } #endif // BOOST_COMPUTE_CL_VERSION_2_0 } // end detail namespace } // end compute namespace } // end boost namespace #endif // BOOST_COMPUTE_ALGORITHM_DETAIL_COPY_TO_HOST_HPP