Reputation: 14977
I have a 100MB character array (h_array
) that is allocated using cudaHostAlloc()
with the flag cudaHostAllocWriteCombined
.
The program first copies data into h_array
on the host. When h_array
is full, it will copy h_array
to d_array
on the device and some processing is done. When the processing is completed, h_array
is reused in the sense that new data is copied to it again, starting from h_array[0]
. The new data is meant to overwrite what was previously stored in h_array
.
However, I'm getting segmentation fault when the new data is copied to h_array
after processing is complete. There are no seg fault errors when I'm using regular malloc
.
What is wrong? Can I not rewrite the memory when it's pinned?
Thank you!
Upvotes: 1
Views: 982
Reputation: 4422
Your CUDA context is probably getting yanked out from under you somehow.
For example, if you allocate the pinned host memory in a thread that then exits, the memory will go away.
Make sure the thread that performs the allocation sticks around!
Upvotes: 1