LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
ouadji

Time to call a dll !!!

Status: Declined
Issue was resolved in comments below

Below, just an example that uses the "mean function".


This function uses a call to a dll.


Look at the difference between the execution times !

 

This is just a small example to show the extreme slowness of dll calls


The time required to call a dll is a disaster!

 

 


                  please, It would be necessary to improve time to call a dll, really !

 

 

 

SR1.png

 

sorry for my bad english, i do my best Smiley Happy

20 Comments
Intaris
Proven Zealot

If someone can post in LV 2012, I'll make tests also and put this topic to rest

 

PS place the DLL call from the Mean.VI directly in the loop instead of the full VI.

Mads
Active Participant

I have to admit my initial test had a flaw as wellSmiley Embarassed 

 

It seems that constant folding is a bit trickier to avoid than expected. If the input array is kept the same then the compiler seems to be so smart that it skips anything but the first run...

 

To force the same DLL free code to repeat itself each time I did a test where the input array is regenerated on each iteration. This requires subtraction of the time it takes to generate the arrays (varies, but not too much), but seems to remove the constant folding:

 

benchmark.png

 

 

On my computer the non-DLL version runs about 2 times faster than the dll-version(s):

 

testresult.PNG

 

Hopefully I've not overlooked another flaw this time  (?) Smiley Surprised

crossrulz
Knight of NI

Please send all other benchmarking to the thread in the LabVIEW board.  It turns out that the Mean code by NI uses an algorithm that is setup to avoid overflow to INF.  That is why it is slower.  It isn't the DLL call itself.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Intaris
Proven Zealot

And we've gone from a difference of 150x to "only" 2.5x

AristosQueue (NI)
NI Employee (retired)

It appears that the explanation to the slowdown has been found and it has nothing to do with DLL call speed. Is there any reason to keep this idea open longer?

ouadji
Trusted Enthusiast

"Is there any reason to keep this idea open longer?" ... no !

 

Thank you all.
I didn't know the "Constant Folding", today I learned something!
a difference of 150x to "only" 2.5x ... yes, I agree, my last tests give the same results.
A very interesting thread, really.

altenbach
Knight of NI

> a difference of 150x to "only" 2.5x.

 

Actually, the dll is 6x faster when comparing identical algorithms, so it is a difference of 150x to 0.17x. 😄

Intaris
Proven Zealot

Well seeing how we don't actually KNOW what the DLL is doing, that seems to be a rather unqualified statement.....

 

Besides, I was simply referring to the bad benchmarking mistakes which led to completely wrong initial comparison values.

 

altenbach
Knight of NI

Yes, we don't know the dll algorithm, but (as others have pointed out) it seems quite sophisticated when dealing with pathological data. Attempting to duplicate all these features in plain G will most likely slow it down even more, making the dll even more impressive. 😄

 

Just guessing of course. Maybe there is a mathematical shortcut that I don't know about.... 😮

JordanG
NI Employee (retired)
Status changed to: Declined
Issue was resolved in comments below