I'm trying to write to CUDA host memory (which I created in my main thread) with a worker thread. The code for this is very simple. I create the memory with
unsigned char* _new;
cudaHostAlloc(&_new, _size, cudaHostAllocPortable);
and pass the pointer _new to the other thread. This thread, however, creates a memory violation when trying to write to it with
memcpy(_new, _source, _size);
or
cudaMemcpy(_new, _source, _size, cudaMemcpyHostToHost);
When I use _new = new unsigned char[_size];
or copy the data in the same thread, it works.
Does anybody know why this happens and how I can fix this?