LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Code Challenge: optimize c function using labview icons. VI and c-code given!

First, I accidentally posted this on the RT section, I have edited that post to point to this, although the RT people can join in on the challenge too, as there are no floating operations, even FPGA's can be used..

Hi!

To pat myself on the back while keeping an eye out to see if anyone out there can do it better, I'd like to post a quick challenge! -Mostly though, the tribute goes to these two:
Original Code: Ashley Roll
C-code Optimisations: Scott Dattalo
(LabVIEW Port: Kjell-Edmund Ims)

In the VI, I have posted the original C-code (open source, includes url's and references to original authors), as well as my adaptation of the c code. It is a CRC 16 implementation that is FAST on embedded electronics, such as PIC's.. it executes in just 17 instructions on the PIC, not to shabby!

I basically just "copied" the c-code straight off over to LabVIEW code, using built in LV functions for shifts and such, the reason this is so optimized already is just because the original author of the c-code did a very good job of optimizing it.

So, if you are bored, jump right in and see if you can do it better!!

I have attached both LV 7.1, LV 8 and a jpg file so everyone can participate. The jpg is relatively small, its not a complicated code to copy by hand..

Kjell-Edmund Ims
---------------------------------------------------

Project Engineer
LabVIEW 2009
Run LabVIEW on WinXP and Vista system.
Used LabVIEW since May 2005

Certifications: CLD and CPI certified
Currently employed.
Download All
Message 1 of 6
(4,360 Views)
Hi,
 
This vi runs faster, but the cost is that it's less readable. I think the results are the same, but I only tested it with the default inputvalues.
 
In my benchmark (4000000X) I got 2.000 sec. The old code took 2.387 sec.
 
After that I put the priority of the sub on "subroutine". Now it only takes 0.941 sec. I don't know how much use this setting is on FPGA though.
 
Regards,
 
Wiebe.
Message 2 of 6
(4,292 Views)
Thats pretty sweet! 🙂

The major part of it though, as you say, probably has to do with how LV displays the VI to windows. By setting it to sub (and no debug), you are basically allowing LabVIEW to drop everything else and run this VI and windows to assign it the outmost importance.

As for your code optimizing, it looks like you did manage to find a more efficient implementation of the c-code, even if it was "only" by an average of 96.75 nano seconds (before changing the priority and such.)

I'm impressed!

I'll test it in my appication to see if I start getting CRC errors. I'll post back here in a day or two, but if it works for a few codes, it is pretty likely that it works for all, since the whole point of CRC is to change (significantly) if any one bit in the input changes.

Thanks!

PS>> you forgot to add your name to the optimization. If you would like credit for this, you can PM me with your name.. can you pm on these boards?
---------------------------------------------------

Project Engineer
LabVIEW 2009
Run LabVIEW on WinXP and Vista system.
Used LabVIEW since May 2005

Certifications: CLD and CPI certified
Currently employed.
0 Kudos
Message 3 of 6
(4,272 Views)
Glad you like it.


My name is not that secret (my email is on the site, if you want it):


Wiebe Walstra
Carya Automatisering
www.carya.nl


"Kjell-Edmund" <x@no.email> wrote in message news:1140615639478-328560@exchange.ni.com...
Thats pretty sweet! 🙂 The major part of it though, as you say, probably has to do with how LV displays the VI to windows. By setting it to sub (and no debug), you are basically allowing LabVIEW to drop everything else and run this VI and windows to assign it the outmost importance.As for your code optimizing, it looks like you did manage to find a more efficient implementation of the c-code, even if it was "only" by an average of 96.75 nano seconds (before changing the priority and such.)I'm impressed!I'll test it in my appication to see if I start getting CRC errors. I'll post back here in a day or two, but if it works for a few codes, it is pretty likely that it works for all, since the whole point of CRC is to change (significantly) if any one bit in the input changes.Thanks!PS>> you forgot to add your name to the optimization. If you would like credit for this, you can PM me with your name.. can you pm on these boards?
0 Kudos
Message 4 of 6
(4,258 Views)
could you post the vi as it looked when you ran the test?
is it just a simple
Get tick counter
do for loop of vi under test
Get tick after

delta tick in ms?

Thanks! 🙂
---------------------------------------------------

Project Engineer
LabVIEW 2009
Run LabVIEW on WinXP and Vista system.
Used LabVIEW since May 2005

Certifications: CLD and CPI certified
Currently employed.
0 Kudos
Message 5 of 6
(4,244 Views)
That's basically it. Just a flat sequence with a get tick count in the first and last case, and a for loop with the SUT (subvi under test) in the middle case.
 
Regards,
 
Wiebe.
0 Kudos
Message 6 of 6
(4,213 Views)