The upper limit on the DMA buffer size is currently set at 32 Megabytes. While this limit can be increased somewhat by making a custom driver, it is not the method preferred by the operating system. Windows and Linux prefer to keep physical buffer sizes small, so they can work on a “scatter-gather” basis and reuse as much of the memory as possible.
There are two ways in which you can capture a 40 GByte dataset.
If the goal is to consume the data (analyze or store to disk) in real time, the best approach is to use multiple buffers of smaller size, say 8 Megabytes. You can post a queue of these buffers and consume the data as it becomes available and re-post the used buffers back to the queue. This way, you can keep acquiring and consuming data for ever.
On the other hand, if the goal is to acquire a large dataset for post-processing, you can DMA the data into motherboard memory and analyze or store it after the fact. Of course, you must have enough free memory in your motherboard to store this data.
In the following paragraphs, we will discuss the second approach.
The first step is to make sure you have enough memory in your motherboard to store data. A good rule of thumb is that today’s operating systems need around 16 Gigabytes of memory for themselves. So, if you need to store 40 GBytes of data, you must have 56 GB of RAM, which effectively means 64 GB.
The next step is to decide whether you want to acquire this data using AlazarDSO (Windows) or AlazarFrontPanel (Linux), or do you want to do it under programmatic control.
In AlazarDSO or AlazarFrontPanel, you can use the Stream To Memory command to acquire data to motherboard memory. After the transfer is complete AlazarDSO or AlazarFrontPanel will save the acquired data to a file.
If you want to acquire this data programmatically you have to:
- Allocate a buffer of required size within your application. Remember, this is a logical buffer scattered all over the address space of the motherboard’s memory.
- Lock a small portion of the buffer (we call this a segment) so AlazarTech’s board can DMA into it
- Do the DMA
- Lock the next segment of the buffer and unlock the used segment
- Continue this until the entire buffer is complete
In this scheme, only a small portion of the buffer is locked to physical memory at any given time, which is what the operating system prefers. An added benefit is that your analysis software can deal with the entire buffer using one pointer.
Note that this scheme will work with continuous streaming, triggered streaming and NPT modes of AutoDMA.
There are a few constraints that must be kept in mind:
- All segments must be page-aligned
- All segment sizes must be a multiple of the page size. Page size is 4096 bytes.
AlazarTech publishes example code in C that demonstrates how to acquire using segments. This example program is called Stream to Memory and is available here.