Re: AltiVec optimization in Cocoa?
Re: AltiVec optimization in Cocoa?
- Subject: Re: AltiVec optimization in Cocoa?
- From: Timothy Larkin <email@hidden>
- Date: Sun, 19 May 2002 22:12:21 -0400
On 2002.05.19 21:17, "Mike Vannorsdel" <email@hidden> wrote:
>
If AltiVec code is executed on a G3, I believe the Mac OS will try and
>
emulate the vector processor.
It will simply crash the G3. Although Apple had an Altivec emulation tool
that ran on the G3 in OS 8, it has not been updated recently.
>
To
>
prevent this, beware of code like this:
>
>
void computeData(void * someData)
>
{
>
if (hasAltiVec)
>
doAltiVecCode(someData);
>
else
>
doScalarCode(someData);
>
}
Actually, this is the standard method of handling the situation where code
could be run on either the G3 or the G4, assuming that no in-lining is being
done. As you say, what absolutely must be avoided is the situation where any
function that will execute on the G3 has any AltiVec instructions, since the
compiler usually emits VSAVE instructions at the start of that function
which will cause the G3 to crash.
>
Writing code for AltiVec is a lot harder than it looks. You have to watch
>
data alignment and need to use data pre-fetching to get worthwhile
>
performance in most places. You also need to schedule your code around to
>
work with the pipelines if the compiler is doing a poor job at doing it
>
itself. Getting to know SimG4 will help you with this.
While optimization at the cache level can be done in Altivec, it is very
tricky because the details depend on the version of the G4 executing the
code, as well as other factors that are difficult to predict. Most
cache-line optimizations are done by trial and error.
However, my experience has been that code can be made to execute 2 or 3
times faster even without worrying about cache lines, or any of the other
nasty hardware details. It is well worth exploring the Altivec instruction
set if your application has compute-bound bottle necks that are suitable for
parallel processing.
--
Timothy Larkin
Abstract Tools
Caroline, NY
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.