I use cudaMalloc and cudaMemcpy to select a matrix and copy arrays of vectors into it, for example:
float **pa;
cudaMalloc((void***)&pa, N*sizeof(float*));
for(i=0; i<N; i++) {
cudaMalloc((void**) &(pa[i]), N*sizeof(float));
cudaMemcpy (pa[i], A[i], N*sizeof(float), cudaMemcpyHostToDevice);
}
What is wrong with my instructions? thanks in advance
PS A [i] - vector
Now I'm trying to copy the matrix from the device to the matrix from the host:
Suppose I have ** pc in the device and ** pgpu is in the host:
cudaMemcpy (pgpu, pc, N*sizeof(float*), cudaMemcpyDeviceToHost);
for (i=0; i<N; i++)
cudaMemcpy(pgpu[i], pc[i], N*sizeof(float), cudaMemcpyDeviceToHost);
= wrong ....
source
share