pinned memory


I read that cudaMalloHost allocates “pinned” memory. What is that ?
And why is copying to the device so fast if one uses pinned memory ?

Greetings, Uwe

Disclaimer - I’m not certain, but this is my understanding:

Pinned memory is marked unpageable at a low OS level. Pinned pages always stay in RAM. It allows faster transfers because it’s easier to do DMA on it.

It can also be fragile - Please be sure you use an OS version that is explicitly supported by CUDA, if you’re using pinned mem.

Ok, thanks.

Are there any drawbacks using unpageable memory ?

Greetings, Uwe

Using a lot of pinned memory can cause performance problems for the operating system. (“a lot” is hard to quantify unfortunately, which is another drawback)

When it goes completely wrong, it’s like incrementally removing RAM from the machine. The kernel always has less and less memory it is allowed to work with. As the unpageable block grows, other stuff has to be swapped out. Stuff like X11 and your consoles and things you need to operate :)

Note that I’ve only had the above problems manifest when I was doing stupid things with memory. But still, as a person that tends to do stupid things once in a while, I’m cautious around pinned mem :)

For os x users falling on this thread and wondering what’s going on behind the scenes on their machines……boutMemory.html

also see:

man mlock

on os x (and linux too, I imagine), “pinned” memory is referred to as “wired” memory.