02-03-2021 09:02 AM - edited 02-03-2021 09:06 AM
So I made this nifty little VI that I'm going to put into my toolkit package on VIPM. Feel free to steal it if you like it. It takes a table and a sort column, and determines whether the sort column contains all numbers, and if it does, performs the sort by numerical value instead of string value. Suuuper simple, but I figured why not turn on parallelism on the loops to make it execute faster for large tables.
Well, I did that, and it actually runs a bit slower. Why is that? I will say that I'm not too familiar with parallelizing loops, but I figured there wasn't much to it besides making sure the loop can do it and turning it on. And I know my benchmark VI is pretty crude but still, it shouldn't time slower with parallelism ON I feel like.
As always, any help is appreciated.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
Solved! Go to Solution.
02-03-2021 09:41 AM
Well, there is overhead in launching a bunch of thread, breaking up access to the input array, and bringing the output array back together. You are doing very little in your loops, so the overhead of the parallel loops is more than any saving you have by doing your processing in parallel.
02-03-2021 10:01 AM
I would guess you can gain some performance by having the 1st loop parallelized, but not the other.
02-03-2021 11:52 AM
@crossrulz wrote:
Well, there is overhead in launching a bunch of thread, breaking up access to the input array, and bringing the output array back together. You are doing very little in your loops, so the overhead of the parallel loops is more than any saving you have by doing your processing in parallel.
Ah I see. And this is explained in minute detail in the Performance Tips section of this KnowledgeBase article, but of course I posted before doing some research myself 😅
Thanks a bunch.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.