[Lunar-commits] r25168 - moonbase/trunk/graphics/libpng

Zbigniew Luszpinski zbiggy at o2.pl
Wed Jul 18 11:57:59 CEST 2007


Wednesday 18 of July 2007 07:14:52 Kok, Auke wrote:
> Zbigniew Luszpinski wrote:
> > Author: zbiggy
> > Date: 2007-07-18 03:32:46 +0200 (Wed, 18 Jul 2007)
> > New Revision: 25168
> >
> > Added:
> >    moonbase/trunk/graphics/libpng/BUILD
> > Log:
> > Bugfix: now libpng is compiled with low level MMX assembly optimization
> > when MMX ready CPU is detected during compilation.
> > This built-in asm optimization is faster than general CFLAGS.
> > libpng MMX check is a little bit crazy and _turns off_ building MMX code
> > when: - march is higher than i686 (because it autoenables supported by
> > CPU simd optimizations) - mmx,sse,3dnow are enabled manually using -m
> > parameter or -mfpmath= If MMX optimization is turned off you'll see
> > PNG_NO_MMX_CODE flag in compilation log several times. This bugfix fixes
> > this problem by temporary turning off bad flags and by providing
> > alternative optimization. libpng built with this bugfix returns:
> > checking if assembler code in pnggccrd.c can be compiled without
> > PNG_NO_MMX_CODE... yes in configure stage.
> > In compilation log you will not see PNG_NO_MMX_CODE anymore.
> >
> >
> > Added: moonbase/trunk/graphics/libpng/BUILD
> > ===================================================================
> > --- moonbase/trunk/graphics/libpng/BUILD	                        (rev 0)
> > +++ moonbase/trunk/graphics/libpng/BUILD	2007-07-18 01:32:46 UTC (rev
> > 25168) @@ -0,0 +1,12 @@
> > +(
> > +
> > +CFLAGS="${CFLAGS//march/mtune}"
> > +CFLAGS="${CFLAGS//=sse/=387}"
> > +CFLAGS="${CFLAGS//=387,387/=387}"
> > +CFLAGS="${CFLAGS//-mmmx/-mno-mmx}"
> > +CFLAGS="${CFLAGS//-m3dnow/-mno-3dnow}"
> > +CFLAGS="${CFLAGS//-msse/-mno-sse}"
> > +CFLAGS="-march=`uname -m` $CFLAGS"
> > +default_build
>
> really, this kind of optimization is silly.

I'm sure you can write more tighter and faster code. I'm not bash hack3r. 
However next time write sample code to prove silliness of mine - I will be 
happy learning better coding. I did not find any other way of better simd 
turn off to make MMX turn on than what you see. This code configures gcc with 
the highest possible CPU optimizations which not triggers MMX switch off.
If you can do it better show us. If libpng would not done such weird MMX check
this patch would not be needed. Rollback it if you do not like it. I keep it 
in zlocal so no problem.

> did you measure the performance 
> difference? How much is the average user going to benefit from this?

I viewed several png files in seamonkey. On my A64 3000+ rendering looks a 
little bit more faster. Increase is not high but I can't expect huge speed up 
in full optimized Lunar viewing one png file. The speed increase may vary per 
CPU. The slower CPU the more speed up. Feel free to measure performance and 
make a report.

Zbigniew


More information about the Lunar-dev mailing list