Problem with cudaMallocHost

I’ve got some problem with cudaMallocHost. I have a 32-bit system with 2 GTX-285 cards (each 1GB Gmem), and a 64-bit system with 1 C1060 card (with 4GB Gmem). But when using pinned memory allocation, on GTX-285 I can only allocate about 450MB, and on C1060 I can only allocate 1700MB. Requesting more memory will get error from cudaMallocHost. But when using un-pinned malloc, I can allocate more than that and there’s no problem with it. Could anybody tell me why this is happening? Thanks!

cudaMallocHost has nothing to do with your GPUs. It allocates memory on the host. So it interacts with the operating system and makes a request for a portion of memory that the system must not page nor swap. It is due to your OS and your current usage of system memory to reserve the requested amount of mem or not. Try to reboot your system and don’t start any memory consuming applications then try again to reserve mem with cudaMallocHost.

Thanks for ur explanation. But the only meaning for pinning memory is that it’s not swappable? During my test using pinned memory will have some marginal performance advantage compared w/ un-pinned memory.

If you use cudaMemcpy to copy unpinned memory to GPU, the memory will be first copied to special locations, which is pinned memory, and then DMA will copy the pinned memory into GPU.

By using pinned memory in cudaMemcpy, you can get rid of the copying operation. The time saved, however, depends on the volume of the copied memory. And the speed of your CPU memory system. Most of the time, this copying process won’t take much time. So the benefit of using pinned memory is usually trivial.