Reading from file into pinned memory

Hello,

I’m trying to accelerate my CUDA application using pinned host memory. Works perfectly in nearly all cases; the exception occurs when I try to read in data from a file into memory allocated by cudaMallocHost or cudaHostAlloc, which produces rubbish.

Any ideas?

I just tried to pin the memory allocated by malloc() instead of using cudaMallocHost() directly using cudaHostRegister(), which pins memory already allocated by the host. This worked. But why? :P