Go to Post Dean Kamen, you deserve a cookie. - Jessica Boucher [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-12-2010, 14:28
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
Dynamically parallel

Hi Folks,

I'm doing some tests of how quickly CAN functions execute in parallel as opposed to series.
I'd like to be able to execute a variable-sized array of commands in parallel just as easily as I would in series. This is what I'm having trouble with.

Here's how I'm trying to execute them in parallel:

I have a reference to a VI (in this example, the VI just pops up a dialog box and waits for a rendezvous). I'm using the rendezvous to make sure that all the instances have finished executing before I measure the time elapsed.

The trouble I'm having is that LabVIEW won't execute more than one instance of the VI simultaneously. It is a reentrant VI.
Attached Files
File Type: zip parallel test.zip (24.7 KB, 7 views)
__________________
-- Marshal Horn
Reply With Quote
  #2   Spotlight this post!  
Unread 21-12-2010, 14:38
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: Dynamically parallel

Marshall -

Someone once told me that you shouldn't use a 20 pound speedometer to measure how fast a chicken can run. Are you sure you want to do it this way? Hardcoding it isn't as pretty, but it will be a more accurate measurement of time.


In order to dispatch in parallel, you need to prepare the VI for re-entrant execution when you load it. This is done by passing "8" to the options input on Open VI Reference. I think you will need to open a reference for every copy you want running in parallel, but I'm not positive.
Reply With Quote
  #3   Spotlight this post!  
Unread 21-12-2010, 15:50
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
Re: Dynamically parallel

Sure, I get what you're saying. I was thinking this would make the code more flexible and easier to maintain, but it may not be worth it.

Any idea what the overhead would be?
__________________
-- Marshal Horn
Reply With Quote
  #4   Spotlight this post!  
Unread 21-12-2010, 16:47
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: Dynamically parallel

I don't have any hard numbers, but it shouldn't be that bad. In fact, I use almost exactly this method in a program that I'm working on now. To me, it just isn't an accurate representation of a typical use case for FRC.

Also, if this method is used incorrectly, it can force LabVIEW to set up and tear down the VI each time the command is called. These are advanced functions, and shouldn't be thrown around without reason.



As for maintainability, I think it would be much more legible to explicitly have all the VIs plopped down in parallel.
Reply With Quote
  #5   Spotlight this post!  
Unread 21-12-2010, 16:53
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,015
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Dynamically parallel

Quote:
Originally Posted by kamocat View Post
I'm doing some tests of how quickly CAN functions execute in parallel as opposed to series.
Is the purpose of this to get an idea of the concurrent processing overhead? ... or something else?

Reply With Quote
  #6   Spotlight this post!  
Unread 22-12-2010, 01:32
SuperS_5's Avatar
SuperS_5 SuperS_5 is offline
[Certified LabVIEW Developer]
FRC #1219
 
Join Date: Dec 2010
Rookie Year: 2010
Location: Canada
Posts: 140
SuperS_5 will become famous soon enoughSuperS_5 will become famous soon enough
Re: Dynamically parallel

Quote:
Originally Posted by kamocat View Post
Hi Folks,

Here's how I'm trying to execute them in parallel:
Hi, You only have one VI ref here. You will need a new ref for each VI instance that you want to run. Secondly, you specify to open as a re-entrant VI as the option when opening the reference.
<Hint>Open VI Reference primitive</hint>

Edit: While this is "legal" LabVIEW code, I would recommend against it if you can avoid it. There is some overhead when opening VI's in this manner. (Dynamic calling) If calling parallel code statically, (IE. Specifying at edit time on the block diagram) the overhead is very minimal.

Last edited by SuperS_5 : 22-12-2010 at 01:35.
Reply With Quote
  #7   Spotlight this post!  
Unread 22-12-2010, 09:20
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Dynamically parallel

As others have mentioned, you need to get a new vi ref for each run. What I'd recommend is to in advance, loop through doing the opens and putting the refs into an array, same size as the CAN IDs. Then your timing will not include data space cloning and mgmt overhead. Personally, I've only used this a few times, and for profiling, tend to drop the reentrant code N times. If much code is involved, I wrap it into another reentrant subVI. If I need hundreds, I drop ten, make a subVI, and drop ten of those, etc.

Greg McKaskle
Reply With Quote
  #8   Spotlight this post!  
Unread 22-12-2010, 17:02
SuperS_5's Avatar
SuperS_5 SuperS_5 is offline
[Certified LabVIEW Developer]
FRC #1219
 
Join Date: Dec 2010
Rookie Year: 2010
Location: Canada
Posts: 140
SuperS_5 will become famous soon enoughSuperS_5 will become famous soon enough
Re: Dynamically parallel

Hi again. I just want to add an extra note. The performance of parallel code will greatly depend upon the target. Single core targets will likely not benefit from parallel code. (Massively multi-core targets obviously benefit greatly) The exception would be if a piece of code must wait for a response from another device, then parallel coding MAY benefit. Usually LabVIEW's compiler can generate more efficient code that is serial then code that is parallel, and therefore, parallel code may potentially be worse in terms of performance. There are a number of articles on the NI site that describe this. Parallel "engines" like what I think you are trying to build can introduce race conditions.
__________________
Mike B

Last edited by SuperS_5 : 22-12-2010 at 17:27.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parallel Batteries DiehardCybercard Electrical 14 06-11-2009 07:15
Batteries in Parallel ubermeister Electrical 20 10-04-2008 08:58
Parallel Tanks AdamC Pneumatics 12 13-11-2007 20:14
Parallel Processor rohandalvi Kit & Additional Hardware 25 27-10-2004 20:21
Working in Parallel dubya404 3D Animation and Competition 7 28-01-2003 11:48


All times are GMT -5. The time now is 08:26.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi