crc32() optimization

Joakim Tjernlund Joakim.Tjernlund at lumentis.se
Sun Nov 10 17:35:21 EST 2002


I could not wait until tomorrow, so I did it now instead.
The result was worse. The best I got was 7% improvement.
I tried 16, 8, 6 and 4 as unrolling steps.

           Jocke

> Cool! I will give it a try(tomorrow afternoon) and see what happens.
> 
>          Jocke
> > > 
> > > What's "Duff's Device"?
> > 
> > It's a tricky way to implement general loop unrolling directly in  C.
> > Applied  to your problem, code that looks like this (instead of 8 any
> > other loop count may be used, but  you  need  to  adjust  the  "case"
> > statements then):
> > 
> > register int n = (len + (8-1)) / 8;
> > 
> > switch (len % 8) {
> > case 0: do { val = crc32_table ... ;
> > case 7: val = crc32_table ... ;
> > case 6: val = crc32_table ... ;
> > case 5: val = crc32_table ... ;
> > case 4: val = crc32_table ... ;
> > case 3: val = crc32_table ... ;
> > case 2: val = crc32_table ... ;
> > case 1: val = crc32_table ... ;
> > } while (--n > 0);
> > }
> > 
> > BTW: this is strictly legal ANSI C!
> > 
> > For an explanation see http://www.lysator.liu.se/c/duffs-device.html
> > 
> > Best regards,
> > 
> > Wolfgang Denk
> > 
> > -- 
> > Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
> > Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
> > See us @ electronica 2002 in Munich, Nov 12-15, Hall A3, Booth A3.325
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/




More information about the linux-mtd mailing list