Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

S series DMA

Hi eesen-

I would expect the DMA query to take longer than the FIFO query.  The difference in timing is likely due to the fact that the dma->read() process requires multiple register accesses and other processing to determine whether bytes are available in the buffer.  The FIFOData polling method only requires a single register access, so it is expected to be much faster.

So why is DMA still better you might ask?  This is because each FIFO polling read requires CPU-controlled register accesses.  DMA, on the other hand, has slightly more overhead at the beginning (i.e. in your experience, <1uSec for polling a single point and >5uSec for the DMA method) but results in much better performance overall. 

Let's say you're reading 1000 points.  The polling method would require something like 1000 * 0.11uSec = 110uSec.  DMA on the other hand would require something like 2 * 7uSec = 14uSec (since two calls to dma->read() are necessary to complete the DMA transfer).  Given this, the overall read process using DMA is clearly better.

Hopefully this helps-

Tom W
National Instruments
0 Kudos
Message 11 of 16
(5,097 Views)
You said "Let's say you're reading 1000 points.  The polling method would require something like 1000 * 0.11uSec = 110uSec.  DMA on the other hand would require something like 2 * 7uSec = 14uSec (since two calls to dma->read() are necessary to complete the DMA transfer).  Given this, the overall read process using DMA is clearly better."
I also thought this. And i had measured time needen to transfer larger data using DMA. I'm sorry i shoul write them to my previous post.
Here are the results;
for 16 sample------7usec
for 32sample------8usec
for 100 sample-----12usec
for 200 sample------17usec
for 1000 sample------70usec
for 2000sample------142usec


0 Kudos
Message 12 of 16
(5,091 Views)

Hi eesen-

Is this the time that it takes the entire read() loop to execute?  What sampling rate are you using?

Tom W
National Instruments
0 Kudos
Message 13 of 16
(5,087 Views)

This measured time values are only for single dma->read() function.

Sample rate is 1khz

0 Kudos
Message 14 of 16
(5,062 Views)
I haven't found the problem with DMA yet. Any comments?
0 Kudos
Message 15 of 16
(5,026 Views)
Hello eesen-
 
My earlier predictions of the execution time may have been underestimated, but I still think you are seeing better performance using DMA.  It will undoubtedly take a longer overall time to perform the read if more data is being transferred, but your performance on a per sample basis should be much better.
 
Your call to FIFOData.readRegister() is only performing a single 32-bit read of the FIFO data with each call.  The DMA read on the other hand is transferring up to 2000 samples (judging by the test cases you provide).  So, your per sample read time for the FIFOData.readRegister() method is 0.11usec.  On the other hand, your time of 142usec for a 2000 point read operation leads to a per sample read time of 142/2000 = 0.071usec/Sample.
 
As you've noticed, the overhead of the DMA memory copy operations is not as advantageous when you read a small sample set (for example, 7usec/16 = ~0.5usec per sample), but as the read size increases you should see the DMA performance quickly outpace the FIFOData register read.  What type of performance do you see if you read 4k points?  10k? 
 
I guess the real question is this- do you need a method that will quickly return a small set of data or one that will quickly return a large set of data?  If you're reading a small set of data and the DMA performance is a problem then you might want to use programmed I/O via the direct register read method.
Tom W
National Instruments
0 Kudos
Message 16 of 16
(5,016 Views)