/
usr
/
include
/
boost
/
compute
/
algorithm
/
detail
/
/usr/include/boost/compute/algorithm/detail
mkdir
upload
Name
Size
Mode
Actions
balanced_path.hpp
6267
0644
edit
dl
rm
binary_find.hpp
4626
0644
edit
dl
rm
compact.hpp
2188
0644
edit
dl
rm
copy_on_device.hpp
7382
0644
edit
dl
rm
copy_to_device.hpp
6731
0644
edit
dl
rm
copy_to_host.hpp
6658
0644
edit
dl
rm
count_if_with_ballot.hpp
2605
0644
edit
dl
rm
count_if_with_reduce.hpp
2648
0644
edit
dl
rm
count_if_with_threads.hpp
4241
0644
edit
dl
rm
find_extrema.hpp
2441
0644
edit
dl
rm
find_extrema_on_cpu.hpp
5333
0644
edit
dl
rm
find_extrema_with_atomics.hpp
4251
0644
edit
dl
rm
find_extrema_with_reduce.hpp
18672
0644
edit
dl
rm
find_if_with_atomics.hpp
8509
0644
edit
dl
rm
inplace_reduce.hpp
4839
0644
edit
dl
rm
insertion_sort.hpp
6030
0644
edit
dl
rm
merge_path.hpp
3874
0644
edit
dl
rm
merge_sort_on_cpu.hpp
14654
0644
edit
dl
rm
merge_sort_on_gpu.hpp
22093
0644
edit
dl
rm
merge_with_merge_path.hpp
7339
0644
edit
dl
rm
radix_sort.hpp
15502
0644
edit
dl
rm
random_fill.hpp
1880
0644
edit
dl
rm
reduce_by_key.hpp
5243
0644
edit
dl
rm
reduce_by_key_with_scan.hpp
23735
0644
edit
dl
rm
reduce_on_cpu.hpp
3949
0644
edit
dl
rm
reduce_on_gpu.hpp
10391
0644
edit
dl
rm
scan.hpp
1545
0644
edit
dl
rm
scan_on_cpu.hpp
7056
0644
edit
dl
rm
scan_on_gpu.hpp
11320
0644
edit
dl
rm
search_all.hpp
2579
0644
edit
dl
rm
serial_accumulate.hpp
1990
0644
edit
dl
rm
serial_count_if.hpp
2243
0644
edit
dl
rm
serial_find_extrema.hpp
3151
0644
edit
dl
rm
serial_merge.hpp
3504
0644
edit
dl
rm
serial_reduce.hpp
2145
0644
edit
dl
rm
serial_reduce_by_key.hpp
4240
0644
edit
dl
rm
serial_scan.hpp
3184
0644
edit
dl
rm
Edit:
/usr/include/boost/compute/algorithm/detail/copy_to_device.hpp
(6731B)
//---------------------------------------------------------------------------// // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com> // // 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_DEVICE_HPP #define BOOST_COMPUTE_ALGORITHM_DETAIL_COPY_TO_DEVICE_HPP #include <iterator> #include <boost/utility/addressof.hpp> #include <boost/compute/command_queue.hpp> #include <boost/compute/async/future.hpp> #include <boost/compute/iterator/buffer_iterator.hpp> #include <boost/compute/memory/svm_ptr.hpp> namespace boost { namespace compute { namespace detail { template<class HostIterator, class DeviceIterator> inline DeviceIterator copy_to_device(HostIterator first, HostIterator last, DeviceIterator result, command_queue &queue, const wait_list &events) { typedef typename std::iterator_traits<DeviceIterator>::value_type value_type; typedef typename std::iterator_traits<DeviceIterator>::difference_type difference_type; size_t count = iterator_range_size(first, last); if(count == 0){ return result; } size_t offset = result.get_index(); queue.enqueue_write_buffer(result.get_buffer(), offset * sizeof(value_type), count * sizeof(value_type), ::boost::addressof(*first), events); return result + static_cast<difference_type>(count); } template<class HostIterator, class DeviceIterator> inline DeviceIterator copy_to_device_map(HostIterator first, HostIterator last, DeviceIterator result, command_queue &queue, const wait_list &events) { typedef typename std::iterator_traits<DeviceIterator>::value_type value_type; typedef typename std::iterator_traits<DeviceIterator>::difference_type difference_type; size_t count = iterator_range_size(first, last); if(count == 0){ return result; } size_t offset = result.get_index(); // 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), events ) ); // copy [first; last) to result buffer std::copy(first, last, pointer); // unmap result buffer boost::compute::event unmap_event = queue.enqueue_unmap_buffer( result.get_buffer(), static_cast<void*>(pointer) ); unmap_event.wait(); return result + static_cast<difference_type>(count); } template<class HostIterator, class DeviceIterator> inline future<DeviceIterator> copy_to_device_async(HostIterator first, HostIterator last, DeviceIterator result, command_queue &queue, const wait_list &events) { typedef typename std::iterator_traits<DeviceIterator>::value_type value_type; typedef typename std::iterator_traits<DeviceIterator>::difference_type difference_type; size_t count = iterator_range_size(first, last); if(count == 0){ return future<DeviceIterator>(); } size_t offset = result.get_index(); event event_ = queue.enqueue_write_buffer_async(result.get_buffer(), offset * sizeof(value_type), count * sizeof(value_type), ::boost::addressof(*first), events); return make_future(result + static_cast<difference_type>(count), event_); } #ifdef BOOST_COMPUTE_CL_VERSION_2_0 // copy_to_device() specialization for svm_ptr template<class HostIterator, class T> inline svm_ptr<T> copy_to_device(HostIterator first, HostIterator last, svm_ptr<T> 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( result.get(), ::boost::addressof(*first), count * sizeof(T), events ); return result + count; } template<class HostIterator, class T> inline future<svm_ptr<T> > copy_to_device_async(HostIterator first, HostIterator last, svm_ptr<T> result, command_queue &queue, const wait_list &events) { size_t count = iterator_range_size(first, last); if(count == 0){ return future<svm_ptr<T> >(); } event event_ = queue.enqueue_svm_memcpy_async( result.get(), ::boost::addressof(*first), count * sizeof(T), events ); return make_future(result + count, event_); } template<class HostIterator, class T> inline svm_ptr<T> copy_to_device_map(HostIterator first, HostIterator last, svm_ptr<T> 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( result.get(), count * sizeof(T), CL_MAP_WRITE, events ); // copy [first; last) to result buffer std::copy(first, last, static_cast<T*>(result.get())); // unmap result queue.enqueue_svm_unmap(result.get()).wait(); return 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_DEVICE_HPP
Save
cmd:
run