Re[4]: [XviD-devel] Quality optimization

James Hauxwell xvid-devel@xvid.org
Fri, 24 Jan 2003 11:42:41 -0000


Hi,

I don't know about CodeAnalyst, but I do use rational quantify for the
same job.  I know when I profile a release build I have to include some
of the symbols that would normally be removed, so it's a mixture between
debug and release.  CodeAnalyst probably is very similar.  There's not
much point in benchmarking debug code :-)

For the test

if (x)
{
}

this can be true/false or 50% probability of being true.  You are
normally best constructing conditional flow with the most probable being
the fall through case (no branch).  The intel compiler has a two pass
compilation mode which basically records the flow and constructs the
conditionals in a way to avoid branch, but you can do this by building a
version with two statics counters

if (x)
{
	here++;
}
else
{
	there++;
}

At the end of the run if you output these numbers then you will know for
any given data set the probabilities of taking the branch or not and
then invert your test if required.

Jim

-----Original Message-----
From: xvid-devel-admin@xvid.org [mailto:xvid-devel-admin@xvid.org] On
Behalf Of radoslaw@syskin.cjb.net
Sent: 24 January 2003 11:18
To: xvid-devel@xvid.org
Subject: Re[4]: [XviD-devel] Quality optimization

Hello,

Christoph wrote

> Yes. MMX has an instruction for that, other CPU ASMs might as well.
> If not, prefetch using C is possible, too. There are also other basic
> operations which always should be tried before immediately going to
ASM:

> http://cdrom.amd.com/devconn/events/gdc_2002_amd.pdf

Thanks for that. It looks very useful, even though I wasn't able to
get any improvement yet.

Instead, I looked a bit deeper into code optimization techniques and
tools. I downloaded AMD's CodeAnalyst and run some motion estimation
tests.
I have some questions about it.
First thing I noticed: if CodeAnalyst is correct, branch prediction is
horrible. In particular in d_mv_bits() there is:

if (x) { // 50% incorrect prediction
  x = ABS(x) // ~40% incorrect prediction
...
... and the same for y.

I have 2 questions now.
CodeAnalyst requires the library to be built in debug mode, with no
optimization. If these results are true, that means that unoptimized
library is wrong - I don't care. Does it actually mean (with
reasonable probablity) that optimized library has the same problem?

And 2. How can I improve branch prediction? In this particular example
I have a hint for the compiler: it is _not_ zero. Usually. This hint
has better chances to be true than 50%...

Do you know better tools to do this stuff? CodeAnalyst ignores asm-ed
code, doesn't allow me to run some functions several times (don't ask
for details, 300MB needed for a single call of SearchP is a hint here)
and so on...

Best Regards,
Radek

_______________________________________________
XviD-devel mailing list
XviD-devel@xvid.org
http://list.xvid.org/mailman/listinfo/xvid-devel