LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

producer multi-consumer loop, seems consumers not Parallel Computing

Solved!
Go to solution

Hi,

 

I have a program acquire image from a camera and then process the image. Since the image acquisition speed is fast enough, while the image processing is very slow (140 ms per second). So I decided to use a producer two-consumer loop to process image parallel, so that I can eventually get a dynamic image at high frame frequency. (That is another two-producer one consumer loop, two process block put processed images in a queue, then the display block display the queued image)

 

However, it seems the first two consumer loops are not parallel computing; When there is only one consumer loop, the time for each loop is 140 ms, while when there are two, the time for each loop is 280 ms. So eventually I still get a slow image at frame time of 140 ms.

 

Can anyone help me find the reason?

 

My computer use a CPU of AMD X6, which seems to be six cores.

 

I attached my code here. Please see it.

0 Kudos
Message 1 of 3
(3,388 Views)
Solution
Accepted by topic author ustcmiaor

A consumer loop can only execute as fast as the producer loop can put data into the queue.  How fast is your producer loop doing that?  If your consumer loop takes longer, than the producer loop, the queue will fill up.  If the consumer speeds up again, then it can work faster until it empties the queue.

 

You have two consumer loops both dequeueing data from the same queue.  They will compete with each other and whichever one grabs the next element off the queue first will execute first.  Then the other consumer loop will wait until the next element gets placed in the queue by the producer.

 

Also, what is taking most of the time?  Is it the Image Processing VI?  You do not have it marked as re-entrant which means any call (such as in consumer loop B) as to wait until any other call to it (such as in consumer loop A) is done with it.  If you mark it re-entrant, then the two instances of that subVI can execute at the same time.

0 Kudos
Message 2 of 3
(3,379 Views)

Hi Ravens,

 

Thank you very much for your helpful information, I do solve the problem!!

 

My producer loop do execute enough, so I make it to send data to two different queue, then make the two consumer loop deal with each queue. Besides I follow your suggestion to make the sub Vi re-entrant.

 

Now I can get a very high frame rate!!

 

Thank you very much~

0 Kudos
Message 3 of 3
(3,361 Views)