demos/bwtest/
gpu_bwtest_demo.pro
Demonstrates the use of page-locked memory for fast CPU-GPU transfer.
This example tests the data transfer bandwidth between host and GPU memory and demonstrates the use of page locked (pinned) memory.
The example first demonstrates conventional data transfer using gpuPutArr
and gpuGetArr
.
It then creates a page-locked variable in IDL, using gpuMallocHost. Note
that in addition to the number of elements, gpuMallocHost
needs to know
the IDL type of the variable to be created. This can be accomplished with
the size(/type)
function.
This variable can be treated like any other IDL variable. However, one has to be careful to avoid deleting/recreating the variable by accident, as page locked variables are deleted by IDL's garbage collector.
E.g the assignment:
g = f
would release the page locked variable g and create a new IDL variable that
lives in standard memory (and therefore will lead to poor data transfer
rate). This can be avoided by subscripting the variable g, as done in the
code:
g[0:*] = f
One should observe that data transfer rate is about twice as high for page
locked memory compared to conventional memory.
While it would be possible to use page locked memory for all host variables that need to be transferred to the GPU, one has to keep in mind that page-locked variables are a limited resource. It is therefore preferable to allocate a few transfer buffers and reuse those.
File attributes
Modification date: | Fri Nov 12 11:07:55 2010 |
Lines: | 128 |
Docformat: | rst rst |