-
-
Save zoq/11101e2022d11527854a263061a3939b to your computer and use it in GitHub Desktop.
copy-test.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Okay I got what's happening here, it is basically column-wise but look at one whole matrix at a time, so
0 2 4
1 3 5
becomes
0 5
1
2
3
4
and rest is getting filled in the same fashion.
0 3 6
1 4 7
2 5 8
gets filled as
0 5 4
1 0 5
2 1 6
3 2 7
4 3 8
that is right
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And below is my code