LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

matrix performance

I got an 2049x2049 matrix which represents an detector image. I analyse my measured data in a while loop and every time I find a detector event I increase the corresponding matrix cell about one. But this process is awful slow. Approx. 5min for 2500 counts. I used the profiler to determine which part of the code inside the loop causes the delay, but every bit is running fast, but not the whole loop. I use shift register to pass the matrix in the next loop step, so I presume this is the part where I lose time.
Is there a better way passing a matrix through a loop ?
I know of text based programming languages that you adress such a matrix as global variabel because of efficiency aspects. Is there something similar possible in LabVIEW 7 ?
The
attached VI contains the descript code as example. It is not able to run because it is a smaller part of larger VI.

Thanks in advance for your help
0 Kudos
Message 1 of 9
(3,655 Views)
When you run it, is it the inner loop that is slow (I see you have an indicator on the index), or is it the outer? Without a data source it's not easy to do any tests.

Shift registers are the fastest option and your code looks OK as far as I can see.

You could perhaps use a presized stack in a functional global instead of the que. The que status VI should be linked to the deque function so that you don't get a race condition (currently there is no guaranteed execution order). Are you sure it's not the ques the code it waiting for? Unless the que contains new data everytime the loop has done an iteration (which should be fast) the loop will stop and wait for new data to arrive...You could perhaps get rid of the local of the time has passed and some other
minor stuff, but that would not explain the problem here.
Message 2 of 9
(3,655 Views)
Hi Mads,

thank you for your answer. I will try out your suggestions.
But I don't think the queue is the main problem, because I wired some test code which is running quite fast. I attached it below. The main differences are that I don't use a matrix for data display and that I only sample two channels instead of three. But the number of channels shouldn't be a problme.

Stephan
0 Kudos
Message 3 of 9
(3,655 Views)
Rewrote it slightly since I don't have an AI card. Added a third "channel". Skipped the time part to see just how fast it would run. It runs very fast. With the timer part included though the outer loop will wait a lot.
0 Kudos
Message 4 of 9
(3,655 Views)
I tinkerd a little bit with the size of the matrix. The smaller I select the dimension of the matrix the faster the code is running. So I think the bad guy is really the matrix.
Has anybody an idea how to speed up things if the has a greater dimension (see above) ?

Thanks

Stephan
0 Kudos
Message 5 of 9
(3,655 Views)
In my edited test the matrix is 3*1000 and 100 blocks are processed...How much larger is the matrix in your case?
0 Kudos
Message 6 of 9
(3,655 Views)
Hi Mads,

sorry, I fear my description of my problem was not as accurate as it should have been.
In my first posting there are two matrices. One coming from the queue which contain the measured data and one which is connected with the diagram output node "Detektorbild" (which is german for "detector image"). This one contains the analysed data and represents (as the name is saying) the image of a detector surface. It has a dimension of 2049x2049 (!) elements which come from the resolution of my measurement and it is the one which is slowing down the whole process. I reduced the resolution to 51x204 elements and everything is as fast as it should be, but I can't distinguish anymore any structures on the detector.
So, my problem is to s
peed up the access on this "detector image" matrix without loosing resolution.

Thank you very much for your help!

Stephan
0 Kudos
Message 7 of 9
(3,655 Views)
Ok. With the different test codes I have now and with a matrix of 2049*2049 elements I can't simulate the 5 minute processing time you describe. What I do see is that it's the adding og the matrix at the end of the outer loop that takes time in the code I have, to run that outer loop 100 times takes 5 seconds, and it's all due to that addition. Perhaps if you could only use one copy of the matrix and do the addition inside the inner loop together with the other things that are done there...you could save time.

But that's the 5 seconds...Do you have a code that will simulate/show the 5 minute delay?
0 Kudos
Message 8 of 9
(3,655 Views)
Hi Mads,

the adding of the two matrices was the problem of the code! Now it works :-)!
Thank you very much for your help!

Stephan
0 Kudos
Message 9 of 9
(3,655 Views)