From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Slower execution speed of FFTEx

Hello all

 

I want to shift my processing algorithms from VSC++ to Labwindow/CVI however, one strange problem i am facing is the significant execution speed difference b/w VS and CVI. One such example is of FFT. In Microsoft Visual Studio 2010 VC++, i am using FFTW libraries for FFT execution of say 65536 points array in a loop of 100 iterations. It takes roughly 30-47ms for execution for this process on core i5 processor. Now for NI LabWindows CVI 2012 on same processor, i have used FFTEx  (with reusable FFT table calculated using 'CreateFFTTable' one time before loop iterations) for same no of points and iterations and it takes roughly 210-217ms for execution for this process.

 

Is this normal or i am missing something?

 

Thanks

 

 

 

 

 

0 Kudos
Message 1 of 9
(3,586 Views)

While I seem to rememeber to have read that CVI isn't an optimizing compiler, a couple options can be tried to speed up program execution.

First of all, you should never try benchmarking a debuggable executable, as it adds several overheads to process execution for debuggning porposes.

Once you switch to standalone executables, the Optimization level parameter becomes active in build options dialog, where you have several different scenarios to choose among: see this Knowledgebase article and make reference to LLVM site to decide which level to try with.

Finally, the CVI Environment sleep policy has a high impact of application performances: you may want to try using a SetSleepPolicy (VAL_SLEEP_NONE) around the code that performs the FFT.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 9
(3,544 Views)

Thanks for help. I have tried SetSleepPolicy as you advised but it has no effect on execution speed.

0 Kudos
Message 3 of 9
(3,506 Views)

The sleep policy is relevant when you are handling user events. As you can read in the help:

When the User Interface Library checks for an event from the operating system, it can put your program in the background, to sleep, for a specified period of time. This action gives other applications more processor time, but your program might run more slowly.

If your evaluation process gives no time to the user interface (e.g. you have a tight loop without ProcessSystemEvents calls inside) then manipulating the sleep policy has no effect on the process behaviour.

You should better try some of the otpimization options, since the default compiler behaviour is not to perform any optimization neither for size nor for speed.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 9
(3,493 Views)

As pointed out by Roberto, CVI did not use an optimizing compiler - at least in past editions such as your 2012.
Starting with 2013 edition CVI has been switched to CLang & LLVM, and this brought in optimizations and other features.
In pre-2013 editions who needed the speed of a true optimizing compiler (including myself) could use the "Use external compiler" feature to use a more powerful compiler, such as Microsoft one.
If you can't upgrade CVI, then you could use the Microsoft optimizing compiler to do final compilation of your release, while retaining all the facilities of CVI environment. 
In my past experiences, the speed improvement was always noticeable, and sometime pure "wow". 
In current development, I leave default CVI configuration active, because performances are good enough for my applications, and I can have a development environment more consistent on different PCs.
Of course all this regards your own source code.
The NI library code comes already compiled from NI, so switching compiler does not impact on it. I did not any specific test in this area, but I think (and I hope I'm right) that libraries that come with recent releases of CVI have been recompiled with updated and better compilers, and their performance should be somewhat improved on past editions. 

Carlo A.
Megaris




0 Kudos
Message 5 of 9
(3,486 Views)

Gosh! I didn't focused on him being on CVI2012: shame on me!



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 9
(3,481 Views)

Dear Carlo

 

Thanks for help. Can you kindly indicate some literature how to complile my CVI project using external ' Microsoft optimizing compiler'?

 

Secondly, If i understand correctly, i cannot speed up 'FFTEx function' execution in current CVI version even by using external compiler?

 

Thanks

0 Kudos
Message 7 of 9
(3,418 Views)

While I cannot assist you in usnig an external compiler, I can suggest an alternative way to solve your problem, which is to build up a DLL in Visuali C with your FFT algorithm and use it in your CVI project.

Some references on using DLLs in CVI can be found in the following documents:

FAQ: Using Dynamic Link Libraries with NI LabWindows™/CVI™

Linking to Functions Defined in a DLL From LabWindows™/CVI



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 8 of 9
(3,411 Views)

Hi..

Firstly, the LabWindows/CVI 2012 Help page related to external compilers is accessible online here

http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/programmerref/buildingprjinextcompiler/ (of course you should have it on your PC, too).

On the latter question, I was talking about library functions provided with LabWindows.
If I am correct, you are compiling the FFTEx function source within your project so you should have a direct advantage compiling it with a better compiler.

 

The approach suggested by Roberto (i.e. compiling FFTEx as a DLL with Visual Studio or whatever, and then dynamically linking to your CVI program) is another way to solve your problem. 

Carlo A.
Megaris




Message 9 of 9
(3,405 Views)