Re: Where to look for dynamic code loading
Re: Where to look for dynamic code loading
- Subject: Re: Where to look for dynamic code loading
- From: Shaun Wexler <email@hidden>
- Date: Wed, 1 Mar 2006 21:35:25 -0800
On Mar 1, 2006, at 7:11 PM, Jeff DuMonthier wrote:
I'm building audio unit plugins, but have a non-audio question. My
DSP code is in C++ classes separate from the core audio classes and
I have Altivec and non-Altivec versions. It would be nice to just
ship one version and have it load the right code at run time, but
I've never gone through the trouble to figure out how. If I have a
C++ bundle, what is the preferred way build the plugin bundle and
have it load either the Altivec or non-Altivec version at run
time? The audio units include code to determine whether or not
Altivec is there, so I just need to figure out how to organize the
project and sub projects/libraries as well as load them. Since
this is not objective-C, NSBundle with a principle class isn't
going to work. I'm running under 10.3, so I'm not doing universal
binaries yet. One thing at a time.
You could use a class cluster. Place all unoptimized C methods (ie
non-unrolled, processor-agnostic) in your "abstract" base class, then
create subclasses for each optimized CPU type and cacheline size.
This allows a fallback path, as well as being helpful for profiling
your optimization by allowing you to switch it on/off.
MyPlugIn::initDSPEngine()
{
switch (getCPUType()) {
case CPU_G3:
dspEngine = new DSPEngineG3; // fp,32
break;
case CPU_G4:
dspEngine = new DSPEngineG4; // AltiVec,32
break;
case CPU_G5:
dspEngine = new DSPEngineG5; // AltiVec,128
break;
case CPU_Intel:
dspEngine = new DSPEngineIntel; // SSE3,64
break;
default:
dspEngine = new DSPEngine; // base class
}
dspEngine->initWithPlugIn(this);
}
--
Shaun Wexler
MacFOH
http://www.macfoh.com
To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the programmer, the glass is twice as big as it needs to be.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden