void copy(vector_slice<vector<SCALARTYPE> > const & gpu_vector_slice, VectorType & cpu_vector) { assert(gpu_vector_slice.end() - gpu_vector_slice.begin() >= 0 && bool("Range must have nonnegative length!")); if (gpu_vector_slice.end() - gpu_vector_slice.begin() > 0) { std::vector<SCALARTYPE> temp_buffer(gpu_vector_slice.stride() * gpu_vector_slice.size()); viennacl::backend::memory_read(gpu_vector_slice.handle(), sizeof(SCALARTYPE)*gpu_vector_slice.start(), sizeof(SCALARTYPE)*temp_buffer.size(), &(temp_buffer[0])); for (vcl_size_t i=0; i<cpu_vector.size(); ++i) cpu_vector[i] = temp_buffer[i * gpu_vector_slice.stride()]; } }
void copy(const VectorType & cpu_vector, vector_slice<vector<SCALARTYPE> > & gpu_vector_slice ) { if (cpu_vector.size() > 0) { std::vector<SCALARTYPE> temp_buffer(gpu_vector_slice.stride() * gpu_vector_slice.size()); viennacl::backend::memory_read(gpu_vector_slice.handle(), sizeof(SCALARTYPE)*gpu_vector_slice.start(), sizeof(SCALARTYPE)*temp_buffer.size(), &(temp_buffer[0])); for (vcl_size_t i=0; i<cpu_vector.size(); ++i) temp_buffer[i * gpu_vector_slice.stride()] = cpu_vector[i]; viennacl::backend::memory_write(gpu_vector_slice.handle(), sizeof(SCALARTYPE)*gpu_vector_slice.start(), sizeof(SCALARTYPE)*temp_buffer.size(), &(temp_buffer[0])); } }
vector_slice(vector_slice<VectorType> const & v, slice const & entry_slice) : base_type(const_cast<handle_type &>(v.handle()), entry_slice.size(), v.start() + v.stride() * entry_slice.start(), entry_slice.stride() * v.stride()) {}