Philip Orr Posted May 15, 2008 Report Share Posted May 15, 2008 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 Quote Link to comment
TobyD Posted May 15, 2008 Report Share Posted May 15, 2008 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. Quote Link to comment
crelf Posted May 15, 2008 Report Share Posted May 15, 2008 QUOTE (TobyD @ May 14 2008, 02:26 PM) Is this a reentrant library file? The dll is not reentrant (it's orange - if it was reentrant, it'd be yellow). Quote Link to comment
TobyD Posted May 15, 2008 Report Share Posted May 15, 2008 QUOTE (crelf @ May 14 2008, 11:29 AM) The dll is not reentrant (it's orange - if it was reentrant, it'd be yellow). :thumbup: I hadn't ever noticed that! Thanks! :worship: Quote Link to comment
crelf Posted May 15, 2008 Report Share Posted May 15, 2008 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. Quote Link to comment
Rolf Kalbermatter Posted May 16, 2008 Report Share Posted May 16, 2008 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 Quote Link to comment
Philip Orr Posted May 16, 2008 Author Report Share Posted May 16, 2008 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! Quote Link to comment
Ton Plomp Posted May 16, 2008 Report Share Posted May 16, 2008 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.