Add read_arrays definition for CUDA
This commit is contained in:
parent
8e534daf8b
commit
c22b74ba47
@ -39,7 +39,16 @@ void CUDAStream<T>::write_arrays(const std::vector<T>& a, const std::vector<T>&
|
||||
template <class T>
|
||||
void CUDAStream<T>::read_arrays(std::vector<T>& a, std::vector<T>& b, std::vector<T>& c)
|
||||
{
|
||||
// Copy device memory to host
|
||||
cudaMemcpy(a.data(), d_a, a.size()*sizeof(T), cudaMemcpyDeviceToHost);
|
||||
check_error();
|
||||
cudaMemcpy(b.data(), d_b, b.size()*sizeof(T), cudaMemcpyDeviceToHost);
|
||||
check_error();
|
||||
cudaMemcpy(c.data(), d_c, c.size()*sizeof(T), cudaMemcpyDeviceToHost);
|
||||
check_error();
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
__global__ void copy_kernel(const T * a, T * c)
|
||||
{
|
||||
|
||||
@ -33,6 +33,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
stream->copy();
|
||||
|
||||
stream->read_arrays(a, b, c);
|
||||
std::cout << c[105] << std::endl;
|
||||
|
||||
delete[] stream;
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user