LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why is CPU usage low on an intensive application?

I've written an application which is pretty CPU intensive.  It's a simulation, programmed using an object-oriented approach.

 

I'm trying to optimize the application to run as efficiently as possible.  To that end, I've parrallelized as much of the code as possible, and I've parrallelized whatever unavoidable for loops exist in my code.

 

But even after doing that, my CPU usage, on and 8-core machine, seems "stuck" at ~50%.  How do I find what is limiting the application from using more of the CPU?

 

Here's what I've already done:

-Minimized screen updates, so the CPU doesn't waste time drawing stuff.

-Created as much data-flow path independence as I can, 

-Parrallelized for loops.

-VIs in parrellized code are set to shared-close reentrant.

-Inlined as many VIs as I can.

 

At first I though that the problem was simply that the for loops don't have enough iterations to really take advantage of the parrallellized code, and I can observe that if I scale the number of objects in my simulation to less than about 250 objects (the number of for loop iterations is equal to the number of objects in the simulation).  With 250 objects, CPU usage is <25%.    If I increase the number of objects to about 1000 objects, CPU usage goes up to nearly 50%.  But even after increasing the number of objects even more (say, 10000 objects), CPU usage is still stuck at ~50%.

 

Any ideas why the application is leaving half the CPU cycles unused?  Nothing else is running on the system, and there is no I/O - so no blocking calls.  I'm not even streaming data to or from a file.  Any help is appreciated.

 

Thank you!

0 Kudos
Message 1 of 26
(3,666 Views)

Are there any waits?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 26
(3,656 Views)

Nope no waits...

0 Kudos
Message 3 of 26
(3,651 Views)

Which version of LabVIEW?  Have you spread your code across execution subsystems?

0 Kudos
Message 4 of 26
(3,638 Views)

Labview 2012.

 

How do I spread my code across execution subsystems?  That may be a technique that I'm not using.

0 Kudos
Message 5 of 26
(3,634 Views)

When you open VI Properties, under the Execution category there is an option to select an execution subsystem.  Each subsystem is assigned a group of threads.  For all subsystems (except User Interface), there's at least one thread per core, so in theory LabVIEW should be able to spread the load across all your cores even within a single subsystem if all threads are constantly busy.  However, separating long-running subVIs into separate execution subsystems can help balance load - if a thread in one system stalls, a thread in another subsystem can execute on that core.  Don't move subVIs that are only simple fast calculations into separate subsystems - leave them in "same as caller" - to minimize context switches.

Message 6 of 26
(3,628 Views)

What is the make and model of the CPU?

What is your LabVIEW version?

0 Kudos
Message 7 of 26
(3,623 Views)

ok, I'll give that a shot.  I'll let the forum know how it goes.

0 Kudos
Message 8 of 26
(3,617 Views)

I doubt that changing execution systems will help you. Most likely you have plenty of threads available. (Just don't run it in the UI thread :D)

 

Can you show us some code instead?

Message 9 of 26
(3,612 Views)

Labview 2012.

 

 

I'll let you know that exact CPU model when I get back to the computer later tonight, but it's an 8-core Intel.

0 Kudos
Message 10 of 26
(3,611 Views)