Stream to Disk Using Win32 File IO
Overview
The LabVIEW VIs below provide access to non-buffered file I/O in Windows. This is useful for sequential reads and writes of large amounts of data at high data rates. Non-buffered file I/O disables the Windows file cache, so data is written directly to or read directly from the file I/O driver for the hard disk drive or RAID controller.
Downloads
Filename: win32fileiovis.zip
The Read VIs in this directory take an incoming array as input; the data read from disk is placed in the input array provided. This leads to much higher performance, since the array can be preallocated ahead of time. The Read Binary File VI in LabVIEW performs at much lower rates
The write VIs in this directory are there only for completeness; you should be able to use the Win32 Open File VI to open the file in non-buffered mode and use the LabVIEW Write Binary File VI thereafter.
These VIs are compiled in LabVIEW 8.0, although they should work in earlier versions of LabVIEW if saved for that version.
Note that the Win32 Open File VI outputs a LabVIEW file refnum as well as a Windows file handle. This allows you to call LabVIEW file I/O VIs such as Get File Size or Set File Position along with the Win32 Read File VIs.
Benchmark VIs that help you test the maximum read and write speeds for your hard drive or RAID configuration are located in the FileIOBenchmarkVIs directory at the same level as this Win32FileIOVIs directory.
It is important to note that data must be written or read in quantities that are a multiple of the sector size (512 bytes). Data must be aligned in memory on boundaries required by the IDE, SATA, or RAID controller. The memory alignment requirement is typically 2 bytes, although nVIDIA onboard RAID controllers require 4 bytes and Adaptec RAID controllers require 8 byte alignment. Most data arrays allocated by modern compilers are 8-byte aligned, so this is usually not a problem.
Please copy and extract the file below to the C:\Program Files\National Instruments\LabVIEW 8.2\user.lib folder to see Win32 File IO Pallette within "User Libraries" of the functions pallette.
Reader Comments | Submit a comment »
Great!
Worked great for me....I went from 7-8
MB/s to 47 Mb/s. Perhaps it is system /
hardware dependent? Or perhaps in
control panel / devices / drives you had
write caching disabled already?
- Howard Bernier, E. Fjeld Company, Inc. hbernier@efjeld.com - Nov 21, 2007
Well written but didn't seem to improve I/O much.
35 Mb/s with the LV method and 39Mb/s with
the win32 method, both on my Dell Latitude
D820 notebook/laptop
- Ted Anderson, CPP Wind Engineering. tanderson@cppwind.com - Nov 5, 2007
Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
