Jump to content

Multi-processor utilization


Recommended Posts

Hello!

I use a Macbook with 2.4Ghz Intel Core2 Duo. Having recently discovered that LabVIEW will, when possible, assign work to multiple cores, I decided to slightly alter my number-crunching simulation. The majority of processing is done by a for loop that produces an array. I split the for loop in two so that half the processing is performed by each loop, in the hope that LabVIEW would fully utilize both cores.

This doesn't seem to be the case, from what I can see, although there is a good chance I am wrongly interpreting the CPU Monitor usage graphs.

I have attached a cut-out of the VI showing most of the two main for loops which I hope to execute simultaneously. I've also attached an image of the CPU utilization when the VI is running.

As you can see, it shows that only 50% of each core is being used. Also, the time the VI takes to execute is not drastically improved. In fact, it is very difficult to tell the difference in time, and the previous CPU utilization graph (not attached) is very similar although not as 'flat'.

Can anyone explain why this is, and whether I am going about things the correct way?

Many thanks for any advice!

Philip

Link to comment

QUOTE (Philip Orr @ May 14 2008, 11:02 AM)

I split the for loop in two so that half the processing is performed by each loop, in the hope that LabVIEW would fully utilize both cores.

It looks like you are making a call to the same dll in both loops. Is this a reentrant library file? If not, then I wouldn't expect to see any speed increase because both loops are sharing the same resource and each loop has to wait until the resource is available before the next iteration can run.

Link to comment

QUOTE (TobyD @ May 14 2008, 02:32 PM)

:thumbup: I hadn't ever noticed that! Thanks! :worship:

No worries :) If I remember correctly (and I usually don't), there are three colors: yellow = thread safe, orange = thread unsafe, white = LabVIEW can't determine, so it runs it thread-unsafe.

Link to comment

QUOTE (crelf @ May 14 2008, 01:41 PM)

No worries :) If I remember correctly (and I usually don't), there are three colors: yellow = thread safe, orange = thread unsafe, white = LabVIEW can't determine, so it runs it thread-unsafe.

Never saw the white so far and for the Call Library Node it wouldn't make sense anyhow. LabVIEW can not determine if an external shared library or particular functions in it are reentrant safe. The programmer defines that in the Call Library configuration dialog (and if he says it is reentrant the according function better is or you are in for strange to rather nasty effects).

RolfKalbermatter

Link to comment

Thanks for the replies. So, are people in agreement that the reason for no speed increase is because they both call the same function from the same library?

How can I implement the speed increase and make my VI use both cores fully - do I need to make two libraries with identical functions, or is there another way?

Thanks again.

Philip

Edit: Success! I configured the Call Lib Function nodes to 'Run in any thread' and now both cores are fully utilized. Many thanks for the advice! I'm very grateful!

Link to comment

QUOTE (Philip Orr @ May 15 2008, 11:24 AM)

Thanks for the replies. So, are people in agreement that the reason for no speed increase is because they both call the same function from the same library?

No, only because the call to the DLL is non-reentrant.

QUOTE

How can I implement the speed increase and make my VI use both cores fully - do I need to make two libraries with identical functions, or is there another way?

You should try to make the call reentrant (or threadsafe), if you know the vendor of the function ask him. (or just try).

Another tip, try to do the number crunching outside the for-loop, all of the calculations you do can be done on arrays as well.

Ton

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.