132
M2i.60xx / M2i.60xx-exp Manual
Continuous memory for increased data transfer rate
Continuous memory for increased data transfer rate
The continuous memory buffer has been added to the driver version 1.36. The continuous buffer is not avail-
able in older driver versions. Please update to the latest driver if you wish to use this function.
Background
All modern operating systems use a very complex memory management strategy that strictly separates between physical memory, kernel mem-
ory and user memory. The memory management is based on memory pages (normally 4 kByte = 4096 Bytes). All software only sees virtual
memory that is translated into physical memory addresses by a memory management unit based on the mentioned pages.
This will lead to the circumstance that although a user program allocated a larger memory block (as an example 1 MByte) and it sees the
whole 1 MByte as a virtually continuous memory area this memory is physically located as spread 4 kByte pages all over the physical memory.
No problem for the user program as the memory management unit will simply translate the virtual continuous addresses to the physically
spread pages totally transparent for the user program.
When using this virtual memory for a DMA transfer things become more complicated. The DMA engine of any hardware can only access
physical addresses. As a result the DMA engine has to access each 4 kByte page separately. This is done through the Scatter-Gather list. This
list is simply a linked list of the physical page addresses which represent the user buffer. All translation and set-up of the Scatter-Gather list is
done inside the driver without being seen by the user. Although the Scatter-Gather DMA transfer is an advanced and powerful technology it
has one disadvantage: For each transferred memory page of data it is necessary to also load one Scatter-Gather entry (which is 16 bytes on
32 bit systems and 32 bytes on 64 bit systems). The little overhead to transfer (16/32 bytes in relation to 4096 bytes, being less than one
percent) isn’t critical but the fact that the continuous data transfer on the bus is broken up every 4096 bytes and some different addresses
have to be accessed slow things down.
The solution is very simple: everything works faster if the user buffer is not only virtually continuous but also physically continuous. Unfortu-
nately it is not possible to get a physically continuous buffer for a user program. Therefore the kernel driver has to do the job and the user
program simply has to read out the address and the length of this continuous buffer. This is done with the function spcm_dwGetContBuf as
already mentioned in the general driver description. The desired length of the continuous buffer has to be programmed to the kernel driver
for load time and is done different on the different operating systems. Please see the following chapters for more details.
Next we’ll see some measuring results of the data transfer rate with/without continuous buffer. You will find more results on different mother-
boards and systems in the application note number 6 „Bus Transfer Speed Details“
Bus Transfer Speed Details (example system)
Setup on Windows systems
The continuous buffer settings is done with the Spectrum Control Center us-
ing a setup located on the „Support“ page. Please fill in the desired con-
tinuous buffer settings as MByte. After setting up the value the system needs
to be restarted as the allocation of the buffer is done during system boot
time.
If the system cannot allocate the amount of memory it will divide the de-
sired memory by two and try again. This will continue until the system can
allocate a continuous buffer. Please note that this try and error routine will
need several seconds for each failed allocation try during boot up proce-
dure. During these tries the system will look like being crashed. It is then
recommended to change the buffer settings to a smaller value to avoid the
long waiting time during boot up.
Continuous buffer settings should not exceed 1/4 of system memory. Dur-
ing tests the maximum amount that could be allocated was 384 MByte of
continuous buffer on a system with 4 GByte memory installed.
Setup on Linux systems
On Linux systems the continuous buffer setting is done via the command line argument contmem_mb when loading the kernel driver module:
PCI 33 MHz slot
PCI-X 66 MHz slot
PCI Express x1 slot
Mode
read
write
read
write
read
write
User buffer
109 MB/s
107 MB/s
195 MB/s
190 MB/s
130 MB/s
138 MB/s
Continuous kernel buffer
125 MB/s
122 MB/s
248 MB/s
238 MB/s
160 MB/s
170 MB/s
Speed advantage
15%
14%
27%
25%
24%
23%
insmod spcm.ko contmem_mb=4