Ошибка с cudaMemcpy2D - PullRequest
       8

Ошибка с cudaMemcpy2D

0 голосов
/ 27 января 2011


Я пытаюсь скопировать данные RGB (при условии, что каждый является целым числом) изображения с хоста на устройство. Вот часть моего кода

 int *img_redd,*img_greend,*img_blued;//d denotes device
 int **img_redh,**img_greenh,**img_blueh;// h denotes host 


     //Initialize+ copy values into the arrays pointed by img_redh,img_greenh etc   
     // then Copy the values of RGB into host array <here>
     //Allocating memory on device below
     cudaMallocPitch((void**)&img_redd,&pitch1,img_width*sizeof(int),img_height);
     cudaMallocPitch((void**)&img_greend,&pitch2,img_width*sizeof(int),img_height);
     cudaMallocPitch((void**)&img_blued,&pitch3,img_width*sizeof(int),img_height);
     // copy it to CUDA device   
     cudaMemcpy2D(img_redd,pitch1,img_redh[0],img_width*sizeof(int),img_width*sizeof(int),img_height,cudaMemcpyHostToDevice);
     //I even tried with just img_redh above 
     //Similarly for green and blue

CudaMallocpitch работает нормальноно он вылетает в строке cudamemcpy2d и открывает файл host_runtime.h и указывает на

static void __cudaUnregisterBinaryUtil(void)
{
  __cudaUnregisterFatBinary(__cudaFatCubinHandle);
}

Я чувствую, что логика распределения памяти в порядке. Любые комментарии, что может вызвать сбой?

1 Ответ

1 голос
/ 28 января 2011

Похоже, вы используете вектор Iliffe для многомерного массива для img_redh. Попробуйте использовать обычный многомерный массив (int* img_redh = (int*)malloc(img_width*img_height*sizeof(int))

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...