c++ - SIGSEGV in CUDA allocation -
i've host array of uint64_t
of size spectrum_size
, need allocate , copy on gpu. when i'm trying allocate in gpu memory, continue receive sigsegv... 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("\t\t...copying\n"); 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 in way, noy i've got sigsegv on other parts of code (in kernel, when using array. maybe due 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));
at least confused uint64_t**
, unit64_t*
.
at line 1, define gpu_hashed_spectrum
pointer, pointing data of type unit64_t
, @ line 3
handle_error(cudamalloc((void **)&gpu_hashed_spectrum, sizeof(uint64_t *) * spectrum_size));
you use gpu_hashed_spectrum
pointer, pointing data of type unit64_t*
.
maybe should change definition to
uint64_t** gpu_hashed_spectrum;
as other lines.
Comments
Post a Comment