dimanche 12 juin 2016

SIGSEGV in CUDA allocation


I've an host array of uint64_t of size spectrum_size and I need to allocate and copy it on my GPU. But when I'm trying to allocate this in the GPU memory, but I continue to receive SIGSEGV... Any ideas?

   uint64_t * gpu_hashed_spectrum;
   uint64_t * gpu_hashed_spectrum_h = new uint64_t [spectrum_size];
   HANDLE_ERROR(cudaMalloc((void **)&gpu_hashed_spectrum, sizeof(uint64_t *) * spectrum_size));
   for(i=0; i<spectrum_size; i++) {
      HANDLE_ERROR(cudaMalloc((void **)&gpu_hashed_spectrum_h[i], sizeof(uint64_t)));
   }
   printf("tt...Copyingn");
   for(i=0; i<spectrum_size; i++) {
      HANDLE_ERROR(cudaMemcpy((void *)gpu_hashed_spectrum_h[i], (const void *)hashed_spectrum[i], sizeof(uint64_t), cudaMemcpyHostToDevice));
   }
   HANDLE_ERROR(cudaMemcpy(gpu_hashed_spectrum, gpu_hashed_spectrum_h, spectrum_size * sizeof(uint64_t *), cudaMemcpyHostToDevice));

Full code available here

UPDATE:

I tried to do in this way, noy I've got SIGSEGV on other parts of the code (in the kernel, when using this array. Maybe is due to other errors.

   uint64_t * gpu_hashed_spectrum;
   HANDLE_ERROR(cudaMalloc((void **)&gpu_hashed_spectrum, sizeof(uint64_t) * spectrum_size));
   HANDLE_ERROR(cudaMemcpy(gpu_hashed_spectrum, hashed_spectrum, spectrum_size * sizeof(uint64_t), cudaMemcpyHostToDevice));

Aucun commentaire:

Enregistrer un commentaire