direct to the question
i need to copy 4 2d arrays to gpu, i use cudaMallocPitch and cudaMemcpy2D to accelerate its speed, but it turns out there are problems i can not figure out
the code segment is as follows:
int valid_dim[][NUM_USED_DIM];
int test_data_dim[][NUM_USED_DIM];
int *g_valid_dim;
int *g_test_dim;
//what i should say is the variable with a prefix g_ shows that it is on the gpu, the ones without the prefix indicate it is on the host
size_t g_valid_dim_pitch = 0;
size_t g_test_dim_pitch = 0;
pitch = sizeof(int) * NUM_USED_DIM;
cudaMallocPitch((void **)&g_valid_dim, &g_valid_dim_pitch, pitch, FILE_DATA_NUM);
cudaMemcpy2D(g_valid_dim, g_valid_dim_pitch, valid_dim, pitch, pitch, FILE_DATA_NUM, cudaMemcpyHostToDevice);
cudaMallocPitch((void **)&g_test_dim, &g_test_dim_pitch, pitch, FILE_DATA_NUM);
cudaMemcpy2D(g_test_dim, g_test_dim_pitch, test_data_dim, pitch, pitch, FILE_DATA_NUM, cudaMemcpyHostToDevice);
the first cudaMemcpy2D is ok, but the second can not run through, which makes ma frustrated yesterday.
Do you have some advice for me to fix it ?
thank you very much!