LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel processing questions

The following two code segments work faster on my 1.75ghz single core processor (1gb ram) than it does on another computer with 4 1.87ghz processors (8gb ram), and I cannot figure out why for the life of me. 

 

In the first bit of code I made the smooth vi reentrant, and they do not depend on each other in anyway, so I would expect them to be running in parallel.

In the second bit of code I have 3 mathscripts which are not dependant on each other, so I would also expect them to run in parallel.

 

Does anyone have any ideas/suggestions on why it doesn't work?

 

Thanks,

Tim

Message Edited by elset191 on 02-05-2009 02:51 PM
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 1 of 26
(4,118 Views)

How do you measure execution time? What is the actual speed difference? How large are the arrays (how long does each subVI take)? What's inside the subVIs? What is the CPU usage? What is the exact model of each processor? (Intel vs. AMD, cache size, etc.). What else is different between the two PCs (I assume the one with 8GB if RAM uses a 64 bit OS, for example). What is your LabVIEW version?

 

Can you attach some code?

Message Edited by altenbach on 02-05-2009 01:38 PM
0 Kudos
Message 2 of 26
(4,100 Views)

The contents of the subvi are actually just the mathscripts that you see under them.  I have the code configured in two ways.  One way uses the 4 subvi calls on 4 separate arrays.  The other way calls the subvi once on one array which is a combination of the other four. 

 

The attached vi is what is pictured as smooth.  It contains three mathscript structures which operate on the beginning, middle and end of the input array.  This is the second configuration I described above.

 

Another way I do it, to see if it works better or runs faster, is to take the components that go into the 1d array above, and run the algorithm on each of them.  The interesting portion of the code is pictured above.

 

Details:

The arrays are 283x129.

I measure execution time by running them and seeing which one finishes first.  They take a very long time to run.  A couple minutes generally.

The processor on the single processor computer is a  1.73 GHz Intel Pentium M, it's in my laptop.

The multicore processor is a I.87 GHz Intel Xeon dual core

Both computers are running 32 bit OS.  The laptop is XP, the big one is Vista.

Assume the big one has at least as much cache as my laptop, I'm sure it has much more.

Both computers are running LV8.6


 

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 3 of 26
(4,085 Views)

Well, I also get only a very small speed increase with reentrant settings on a dual core  (~5%) so it seems that the bulk of the mathscript code is not reentrant and setting the subVI to reentrant does not do much. What are typical values for the scalar inputs? (I get errors unless they are zero, but I have not really looked into this)

 

For further clarification, you might want to discuss this in the Mathschript forum).

 

When speed matters, mathscript should not be the first choice anyway. Can you tell us a little more about the algorithm? Smoothing a signal should not require that much code!!! I am sure this could be done orders of magnitude faster with a built-in functions or some simple graphical code. How big are your input arrays?

0 Kudos
Message 4 of 26
(4,057 Views)

The algorithm is what I was describing in this other thread you were replying in http://forums.ni.com/ni/board/message?board.id=170&message.id=384152&query.id=203192#M384152

 

I know this can possibly be done much faster but I don't know anything about the smoothing functions within labview, or convolutions that you mentioned in the other thread.

 

If you have any suggestions I'd be very grateful.

 

The scalars you asked about r and c stand for row and columns.  Therefore they should be (for my purposes) 283 and 129, which is the size of my arrays.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 5 of 26
(4,053 Views)

Hi else91,

 

Can you please answer the following questions?

1. How do you measure execution time?

2. How are you measuring the actual speed difference?

3. What processors are you using?

4. Do you have any other applications running at the same time?

Warm regards,
Karunya R
National Instruments
Applications Engineer
0 Kudos
Message 6 of 26
(4,026 Views)

I measure execution time by running them and seeing which one finishes first.  They take a very long time to run, so it is easy to see which one finishes first.  They usually take about 2 minutes to execute

 

 

The processor on the single processor computer is a  1.73 GHz Intel Pentium M, it's in my laptop.

The multicore processor is a I.87 GHz Intel Xeon, and there are two of them.

 

The other applications cpu usage is negligible.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 7 of 26
(4,022 Views)

Hi Else,

 

  • Can you post your code for me to test?
  • Can you also post the difference in time so that I can see the difference between our execution times?
  • What versions of the software are you using?

 

Thanks,

Karunya

Warm regards,
Karunya R
National Instruments
Applications Engineer
0 Kudos
Message 8 of 26
(3,991 Views)
Hello Tim,

Altenbach is correct: MathScript code is not reentrant.  Although MathScript is built on top of LabVIEW, there are many VI layers between LabVIEW and MathScript in order to support the way types work in MathScript.  We are looking to change the reentrancy in a future version so operations can be run in parallel.

As for why you observed slower behavior on a multi-processor machine than on a single-core machine, this is likely a result of resource contention.  When a VI is not reentrant but is needed in multiple threads, a mutex is set up to block access to that VI by other threads.  For an application that is not very parallel (and MathScript is not currently), this contention can actually cause worse behavior.

One thing that might speed up your code somewhat is to use the semicolon everywhere.  MathScript is smart enough to know that you are in a MathScript node, so it won't actually go through the work of formatting the output.  However, it still has to check if it should.  If you have the MathScript probe showing, for example, this will cause the output to be displayed.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
Message 9 of 26
(3,979 Views)
Thanks Grant.
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 10 of 26
(3,970 Views)