04-26-2014 05:41 AM
Hi.
I'm learning multi - thread programing. For start I use "parallel for loops" and I was suprised that is not working. One -thread loop work few times faster (depends on settings) than multi - thread. I don't know why and this is my ask to correct my Vi to work properly.
Computer Lenovo, G580, Windows 7 home, 64 bits
Intel Core i7 3632QM
Ivy Bridge
Specification Intel(R) Core(TM) i7-3632QM CPU @ 2.20GHz
Package (platform ID) Socket 988B rPGA (0x4)
Number of cores 4
Number of threads 8
LabView 2011.
Solved! Go to Solution.
04-26-2014 07:45 AM
Hi,
Make the "dluga operacja.vi" Reentrant execution.
Since it is not reentrant - all the parallel process has to wait for the other to complete before it shares the "dluga operacja.vi" to the other parallel loop.
Hope this helps.
04-26-2014 03:01 PM
Ok. It works, but very strange.
Thank You very much.
04-26-2014 03:21 PM
@gibon wrote:
Ok. It works, but very strange.
Thank You very much.
It's not very strange if you think about it. If it's not re-entrant, a new call to the subVI must wait until the last call is complete.
04-26-2014 03:24 PM - edited 04-26-2014 03:41 PM
@gibon wrote:
Ok. It works, but very strange.
In what way does it work "strange"? Please explain.
In addition to that, make sure you make the benchmarks actually fair. There are quite a few code differences between the two FOR loop (autoindexing, explicit indexing, shift register, etc.).
Your first frame is also quite silly. Why do you run two indentical parallel FOR loop in parallel. Wouldn't one be enough. Simply branch the wire after the loop, right? Also your formula node makes no sense. What is the purpose of "a=inn+1", seems irrelevant since "a" gets redefined two lines later. Also don't put indocators inside the loop. They will skew the results.
04-26-2014 04:00 PM
Also note that plain LabVIEw code seems to be about 15% faster than your formula node. Here's a quick rewrite of your code to give you some ideas. (LabVIEW 2011).
04-27-2014 03:35 AM - edited 04-27-2014 03:37 AM
Thank You "billko" and "altenbach" for answer. Of course You both have right.
Altenbach - You have right about "linia dluga" - I wanted to make something hard for processor, It have no sense of corurse, this VI's are made to only understend some parallel programing in labview.
"Why do you run two indentical parallel FOR loop in parallel" - I made on begin two loops not parallel, later I made some modyfication when I was playnig.
What was "strange" in behavior ? In "linia dluga" when inside loop is set to "1" the "spreed up" between one and multi -thread is about 3 times, when I set it to "20" this grow to 6,2. That was strange form me, becourse I expected similar value.
Altenbach - I have one more question if You can help me - how did You get "High resolution relative seconds.Vi" ? - I mean how did You know that there is this "vi". And thanks a lot for Your modyfications.
04-27-2014 04:09 AM
gibon wrote:What was "strange" in behavior ? In "linia dluga" when inside loop is set to "1" the "spreed up" between one and multi -thread is about 3 times, when I set it to "20" this grow to 6,2. That was strange form me, becourse I expected similar value.
A parallel FOR loop has some overhead due to parallelization (splitting up the problem, then reassembling the results, etc.). If the code is very fast, the overhead is proportionally larger. If the subVI takes a long time to finish, the parallelization overhead is insignificant. It is often not worth to parallelize loops that have very simple and fast code.
gibon wrote:Altenbach - I have one more question if You can help me - how did You get "High resolution relative seconds.Vi" ? - I mean how did You know that there is this "vi". And thanks a lot for Your modyfications.
You can find it in vi.lib\utilities. It is well known.
04-27-2014 09:39 AM
@altenbach wrote:
gibon wrote:What was "strange" in behavior ? In "linia dluga" when inside loop is set to "1" the "spreed up" between one and multi -thread is about 3 times, when I set it to "20" this grow to 6,2. That was strange form me, becourse I expected similar value.
A parallel FOR loop has some overhead due to parallelization (splitting up the problem, then reassembling the results, etc.). If the code is very fast, the overhead is proportionally larger. If the subVI takes a long time to finish, the parallelization overhead is insignificant. It is often not worth to parallelize loops that have very simple and fast code.
gibon wrote:Altenbach - I have one more question if You can help me - how did You get "High resolution relative seconds.Vi" ? - I mean how did You know that there is this "vi". And thanks a lot for Your modyfications.
You can find it in vi.lib\utilities. It is well known.
Perhaps not well known enough! the "Hidden gems" package adds it to your palattes. It has also been discussed in a comunity nugget
01-26-2015 05:34 AM
Hi friends
I would like to ask you how to implement a vi that runs 3 loops with different execution time and have a unique stop button.
Attached a example that explain my project problem.
Thanks,
Alexandre.