LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Iteration Speed issue when Indexing 3D array wried to a while-loop

Brief Description of my Program:

I am working on the real-time signal generation by using LabView and DAQmx (PCI-6110 card). My vi reads the big data file (typically 8MB txt file containing about 400,000 samples (complex double precision). Then, the signal is pre-processed and I end up with a huge 3D array to feed while-loop (typically 3D array dimension is N x 7 x M where N & M >> 7). Inside the loop, that 3D array is indexed and processed before the results are written to the DAQmx outputs. I have a speed issue when indexing the large 3D array (i.e, 3D array having a large sub-array size). My while-loop could not run fast enough to top-up the DAQmx AO buffer (at the output rate of 96kHz). It could run faster only if I use smaller 3D array (i.e, smaller-sized sub-arrays). I do not quite understand why the size of 3D sub-array affects the rate of looping although I am indexing same sub-array size at each iteration. I really appreciate your comments, advices and helps.

I include my 3D array format as a picture below.

Question on LabView:

How does indexing an 3D array which wires to the while-loop affect the speed of the loop iteration? I found that large dimension of sub-arrays in the 3D array slows down the iteration speed by comparing to indexing the same size of sub-array from smaller-sized sub-arrays of the 3D array to perform signal processing inside the while-loop. Why? Is there any other way of designing LabView Program to improve speed of iteration?

--------------------------------------

attachment:

 
0 Kudos
Message 1 of 13
(3,710 Views)
Your attachment did not make it. Some file types are not permitted as attachments. .jpg or .png are good. Avoid .bmp as it produces very large files. You should also attach your VI. Several persons who participate in this forum regularly are quite knowledgeable regarding handling of large datasets. A paper on handling large amounts of data written by an NI employee is in the Archives or elsewhere on NI's web site. A search should find it for you.

The basic concepts are to avoid making copies of data and to avoid growing arrays (which requires reallocating memory) inside loops.

Lynn
Message 2 of 13
(3,704 Views)
Your image attachment points to your C: drive, which is unaccessible to most of us (hopefully 😉 You need to use the attchment button, but please no BMP as johnsold already mentioned)
 
How many elements are in the 3D array? Is ist still around 400000 or significantly more? Do you create unecessary data copies? Please attach a simplified version of your code.
 
Message 3 of 13
(3,695 Views)

Thank you all for your prompt replies and your interests. I am sorry about my attachment. But, I have now attached a jpg format image file as you suggested.

I had read the few papers on large data handling such as "LabVIEW Performance and Memory Management". Thus, I had already tried to avoid making unnecessary copies of data and growing arrays in my while-loop. I am not an expert on LabView, so I am not sure if the issues I have are just LabView fundamental limitations or there are any other ways to improve the iteration speed without reducing the input file size and DAQ output rate.

As you request, I also attach my top-level vi showing essential sections such as while-loop and its indexing. The attached file is as an image jpg format because the actual vi including Sub-VIs are as big as 3MB in total. I hope my attachment would be useful for anyone who would like to reply my question. If anyone would like to see my whole vi & llb files, I would be interesting to send it to you by an e-mail privately and thus please provide your e-mail address.

The dimension of my 3D array is N x 7 x M (Page x Row x Column), where N represents number of pages in 3D array, and M represents the size of 1D array.  The file I am currently using forms 3D array of N = 28, & M = 10,731.  Refering to the top-level vi picture I attached, my while-loop indexes each page per iteration and wrap-around.  The sub-VI called "channel" inside the while-loop will further index its input (2D array) into seven of 1D arrays for other signal processsing.  The output from that "channel" sub-VI is the superposition of those seven arrays.  I hope my explaination is clear. 

Attachement: 3Darray.jpg and MyVi.jpg
 
Kind Regards,
Shein
Download All
0 Kudos
Message 4 of 13
(3,686 Views)
Hi Altenbach,
 
Thank you for your indications.  I include your requests and answers to your questions in my previous reply.  Please refer to them. 
 
Regards,
Shein
0 Kudos
Message 5 of 13
(3,682 Views)
Have you done any profiling?
 
A quick demo (LabVIEW 7.1) shows that with the indexing of the 3D array, the loop takes about 1-2 ms with your given sizes.
 
Can you show a copy of the channel sub-VI? maybe you can flatten it to the main diagram to avoid the calling overhead? (it seems to shuffle at least 2 big 2D arrays). What is its priority setting?
 
(You can also e-mail it to me, my e-mail address is shown in VI properties...documentation of the attached VI.)
Message 6 of 13
(3,670 Views)
Thank you Altenbach...
 
>>Have you done any profiling?
Do you mean by  "Tools>Advanced>Profile VIs"?  It didn't show the duration of each while-loop iteration .  But I have an light indicator on the front panel which indicate the looping, so I can kind of measure duration by stopwatch by averaging over a few iterations. 
 
>>A quick demo (LabVIEW 7.1) shows that with the indexing of the 3D array, the loop takes about 1-2 ms with your given sizes.
This took about 5 ms to 14 ms for my PC.  I guess it depends on the speed of PC.
 
>>Can you show a copy of the channel sub-VI? maybe you can flatten it to the main diagram to avoid the calling overhead?
>>(it seems to shuffle at least 2 big 2D arrays). What is its priority setting?
I will send my "Channel" sub-VI and its internal sub-VIs to your email address.  Basically, I tried to minimize the overhead problem.  I set the Priority settings as below:
Top-Level VI > "Above Normal"
Channel(subVI)  >  "Above Normal"
SubVIs in Channel(subVI)  >  "Above Normal & Reentrant Execution" or "Subroutine"
The rest of the subVIs  >  "Normal"
 
I have also attached the picture of Channel(subVI) for those who are interested in.
 
Hope to get your precious comments and helps,
Shein
Download All
0 Kudos
Message 7 of 13
(3,664 Views)


@Shein wrote:
...
SubVIs in Channel(subVI)  >  "Above Normal & Reentrant Execution" or "Subroutine"

There is absolutely no reason to set this re-rentrant, it only costs you significantly more memory. I'll e-mail you a few more suggestions directly.
Message 8 of 13
(3,655 Views)
Hi,
 
Thank for your suggestion and willingness to help.  I received your email and I tried to run your version of the LV code.  Apparently, the code looks much nicer and compact but I didn't achieve any obvious speed improvement. 
 
The reason I didn't put the subVI in the for-loop, which you modify for me as an more compact VI arrangement, is I loose the continuities of random number generations.  For those who are confused by my above reason, I am generating independent seven channel noises.  Each  channel contains two independent Gaussian noise generations.  Therefore, equivalently, there are 14 independent Gaussian noise generations and I want them to be continuous.   Altenbach!... when I tried your modified VIs, I found that only the first while-loop noises are independent and the rest are corrupted.  I think Gaussian Noise VI doesn't know independency anymore.  But, I really appreciate your helps and efforts. 
 
However, some of my questions haven't been answered.  Why does indexing the same length of 1D array size from "large" 3D array, which  is wired to the while-loop, take longer iteration time than indexing the same amount of 1D array size from "smaller" 3D array?  Is that just a fundamental LabView limitation of the while-loop with large 3D array wried to it? Or is there any other reasons?
 
I really appreciate if any of you could answer those unknowns.  Thank you so much especially for those who have interests in my issues.
 
Best Regards,
Shein
0 Kudos
Message 9 of 13
(3,634 Views)
Is there a reason why you wire anything to the seed input of the random generator at all?
0 Kudos
Message 10 of 13
(3,621 Views)