Login / Register  0 items | $0.00 NewWhat is KVR? Submit News Advertise
clau_ste
KVRer
 
25 posts since 20 Jan, 2017

Postby clau_ste; Fri May 05, 2017 12:19 am Does exist a good and clear tutorial/book about optimization?

I know this guide online about sse simd
http://sci.tuomastonteri.fi/programming/sse
But it's from 2009 and i can't find anything else that describes in a good and clear way how to optimize an algorithm, do you have any other source
Miles1981
KVRian
 
1208 posts since 26 Apr, 2004, from UK

Postby Miles1981; Fri May 05, 2017 1:21 am Re: Does exist a good and clear tutorial/book about optimization?

The library I would use is Boost.SIMD, it wraps all the custom compiler/architecture dependent registers and functions in a nice wrapper.
Then all the stuff explained in the tutorial should be accessible and all the new SIMD instructions as well (FMA for instance).
Otherwise, you can go for Intel's handbook on KNL optimization, it has a chapter on SIMD as well IIRC.
clau_ste
KVRer
 
25 posts since 20 Jan, 2017

Postby clau_ste; Fri May 05, 2017 5:36 am Re: Does exist a good and clear tutorial/book about optimization?

Seems an interesting library, thanks
Miles1981
KVRian
 
1208 posts since 26 Apr, 2004, from UK

Postby Miles1981; Fri May 05, 2017 7:14 am Re: Does exist a good and clear tutorial/book about optimization?

The main thing about optimization is measurement. You should first profile your app to figure out the bottlenecks, and then solve them. No point in doing vectorization if you are already memory bound.
Chrisboy2000
KVRist
 
30 posts since 21 Apr, 2008, from Germany

Postby Chrisboy2000; Sun May 07, 2017 12:16 pm Re: Does exist a good and clear tutorial/book about optimization?

That's a good point. I recently stepped into the pitfall of vectorizing a simple algorithm with no performance gain because most of the time was spent fetching the (possibly) unaligned data from memory.

Have you any recommendations for profiling best practices? I know how to use Instruments and VerySleepy to find the most time consuming parts / functions of my code, but I still need to figure out how to check for eg. cache-misses or other stuff that is not as easy as finding the bottleneck with a common profiler.
Miles1981
KVRian
 
1208 posts since 26 Apr, 2004, from UK

Postby Miles1981; Sun May 07, 2017 10:28 pm Re: Does exist a good and clear tutorial/book about optimization?

VTune Amplifier, Advisor on all platforms, and then valgrind on Mac/Linux or PAPI on Linux (in HPC Toolkit, coupled with a script to turn it into a callgrind-like file).
User avatar
DJ Warmonger
KVRAF
 
2252 posts since 7 Jun, 2012, from Warsaw

Postby DJ Warmonger; Sun May 07, 2017 10:54 pm Re: Does exist a good and clear tutorial/book about optimization?

Miles1981 wrote:The main thing about optimization is measurement. You should first profile your app to figure out the bottlenecks, and then solve them. No point in doing vectorization if you are already memory bound.

That's a good point, but how to determine if you're memory bound?
http://djwarmonger.wordpress.com/
Tricky-Loops wrote: (...)someone like Armin van Buuren who claims to make a track in half an hour and all his songs sound somewhat boring(...)
Miles1981
KVRian
 
1208 posts since 26 Apr, 2004, from UK

Postby Miles1981; Sun May 07, 2017 11:04 pm Re: Does exist a good and clear tutorial/book about optimization?

Yeah, that's the real issue...
Actually Advisor has a roofline prototype that shows the bandwidth your loop is using. So if your are at the limit of DRAM and if your data doesn't fit your L3, you know that you are memory limited.
And if you are not and if the arithmetic intensity of your app combined with the bandwidth is not maximized, then you can perhaps enhance your code.
camsr
KVRAF
 
6582 posts since 16 Feb, 2005

Postby camsr; Mon May 08, 2017 2:59 pm Re: Does exist a good and clear tutorial/book about optimization?

DJ Warmonger wrote:
Miles1981 wrote:The main thing about optimization is measurement. You should first profile your app to figure out the bottlenecks, and then solve them. No point in doing vectorization if you are already memory bound.

That's a good point, but how to determine if you're memory bound?


Use constant-valued datasets instead of random, this should always be aligned and the data resides in the EXE.
Image
Siekmanski
KVRer
 
23 posts since 22 Sep, 2013

Postby Siekmanski; Fri May 12, 2017 2:53 am Re: Does exist a good and clear tutorial/book about optimization?

Marvinh
KVRist
 
51 posts since 5 Sep, 2015

Postby Marvinh; Wed May 31, 2017 10:02 am Re: Does exist a good and clear tutorial/book about optimization?

Urs wrote:Block processing. Instead of rendering oscillators, LFOs, envelopes, filters, and what not in one loop, create a method to call for each. Make those methods take not just one sample to process, but a stream of 64 or more. When they process, each module renders into its own temporary buffer when necessary.

Prefer stack memory over heap, and oversample individually as needed:

void render( float* in, float* out, int numSamples )
{
float tmp[ numSamples * 4 ];

upsample4( tmp, in, numSamples ); // upsample into tmp buffer

… process tmp …

downsample4( out, tmp, numSamples ); // downsample into out buffer
}

This takes into account that oversampling alone doesn't help anti aliasing much (need I explain?). Anti aliasing is only met properly if each individual module is oversampled. Alternatively, keep the large buffers and lowpass inbetween each module (that's the same thing but might require more memory on stack). The advantage for CPU optimisation is that each module can be oversampled just as much as it needs. A bandlimited oscillator doesn't need to be oversampled at all, a non-linear filter does.


This works for me I don't know the caveats yet.

Moderator: Moderators (Main)

Return to DSP and Plug-in Development