Skip to content

Instantly share code, notes, and snippets.

@zoq
Created March 28, 2022 16:32
Show Gist options
  • Save zoq/11101e2022d11527854a263061a3939b to your computer and use it in GitHub Desktop.
Save zoq/11101e2022d11527854a263061a3939b to your computer and use it in GitHub Desktop.
copy-test.hpp
mat src(4, 1);
src.randn();
mat dst(4, 1);
dst.randu();
src.print();
dst.print();
// Copy the first three elements from src to dst.
cudaMemcpy((double*)dst.get_dev_mem().cuda_mem_ptr, src.get_dev_mem().cuda_mem_ptr, sizeof(double) * 3, cudaMemcpyDeviceToDevice);
// Copy first element from src to last element in dst.
cudaMemcpy((double*)dst.get_dev_mem().cuda_mem_ptr + 3, src.get_dev_mem().cuda_mem_ptr, sizeof(double) * 1, cudaMemcpyDeviceToDevice);
src.print();
dst.print();
@zoq
Copy link
Author

zoq commented Mar 28, 2022

that is right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment