This one is on my Intel Q6600 around 20 cycles faster than the previous optimized delay (SSE1 version) which is ~18% less CPU time. Compared to the original code version, this code saves 54% CPU time !!!
Beat this !!! 😈
aliasant ·
Is it samplerate independent?
Tzarls ·
Well, I think the input is in samples, so as long as you adjust the number of samples for the active samplerate, everything should work ok.
MyCo ·
it is not directly samplerate dependent, but it has a buffer that is max. 1 second long for 44,1kHz, 2 seconds for 22,05kHz... So if you need long delays for high samplerates you have to adjust this, but it's the same for all delay code modules.
MyCo ·
Here is the same optimization for the non-interpolated delay version:
streamin in;
streamout out;
streamin delay;
int arrayindex=0;
float index=0;
float F1=1.0;
float mem[44100];
// move index by one sample and clip it
movaps xmm0,index;
addps xmm0,F1;
It saves ~26 Cycles which is around ~39% of the CPU time.
This improvements are just made by reordering the code, what's a little bit curious...
aliasant ·
Great stuff Myco.
Did you do the rearranging in the original code and then optimized it in asm or did you do the alterations directly in the asm code?
MyCo ·
I did it directly...
I've found out, that the advantage doesn't work everytime, I don't know why... eg. in the Chorus it doesn't work but in the Reverb it does.
Tom7777 ·
These are nice thanks, i did some quick tests with the default example changing a delay in the delay module and with SMs cpu reader i got -
Standard coded delay = 4.8-5%
Standard coded delay replacement = 4.6%
MichaelBenjamin wrote: thanks myco.
i changed a bit at start so F1 F0 and maxdelay have their own xmm register, saves 13 cycles, or 7.7% here.
With a single instance myco's seems to run faster but once you start stacking them up your modified version starts to win out. Shouldn't the benefit of moving those commonly used variables into an xmm reg be seen even in a single instance? Is it just the cpu tools acting up? I know, so many questions haha.
MichaelBenjamin ·
its consistent 13 cycles faster here with a single instance. i dont know, maybe its the processor (amd x2)?
can some other people test this?
MyCo ·
I've tested realy everything on my CPU, the preloading (like MichaelBenjamin did), reordering the code, merging the SSE and x86 part, reordering the x86 (eg. 4 fld in series)... here is nothing faster than my versions above.
I also tried a trick that could be a little bit unstable but it should save 4... but it doesnt.... the trick should work like this: delete every "shl eax,4;" and just put a multiplication with 16 before the read block... It works on small buffer (44kHZ) but there is no better performance.
@MichaelBenjamin: in my test's your version uses 7 Cycles more. It's realy CPU dependent.
MichaelBenjamin ·
edit: so you got an intel processor?
i attached the osm with the cpu analyser and my results
Dozius ·
Intel processor here. I'm getting the same results as Myco. The cpu analyzer you have there is newer than what I have. Where can I get the latest analysis toolkit? I thought I had the latest from the wiki.
PS: The Analyser is newer than the one I used, the results are the same. BTW: One try to optimize the analyser could be to test sequential and not parallel.
aliasant ·
MichaelBenjamin wrote: edit: so you got an intel processor?
i attached the osm with the cpu analyser and my results
I too have an Intel and B ( No preload) is faster by 6-7 cycles
stw ·
aliasant wrote:
MichaelBenjamin wrote: edit: so you got an intel processor?
i attached the osm with the cpu analyser and my results
I too have an Intel and B ( No preload) is faster by 6-7 cycles
dito
Tom7777 ·
That analyser is inacurate, i have tested and it can flip the results depending on when you plugin inputs in etc and there isn't really another decent one i have found either. I hope malc adds some decent testing tools sometime because currently they all give un-reliable readings.
infuzion ·
MichaelBenjamin wrote: I changed a bit at start so F1 F0 and maxdelay have their own xmm register, saves 13 cycles, or 7.7% here.
On my AMD64 single core laptop, I tried doing that with MyCo's version (I can't let him best me in ASM! 😉 )& I found only swapping F1for an XMM did I save 5 cycles; F0 & maxdelay XMMing slowed it down. You tend to get "free" memory loads as long is they're well interleaved. Also, if you load a register & do not use it for a while, that can waste cycles it seems sometimes.
MichaelBenjamin ·
i dont think the analyser is that inaccurate, instead its seems to be the different cpus showing varying results.
so these optimisations finally seem to be quite useless since they are slower/faster depending on what cpu the code runs.
Tom7777 ·
All of them are inaccurate or at least on this computer, with that one when testing with your previous optimization osm it was telling me that the un-optimized version was better at times then after closing SM and opening it again it would tell me the optimized version was better, then flip the results again later. All the current tools are all far too jumpy and un-reliable on this computer, the only way i find to get good readings is to export out of SM and test in a host and thats really annoying to do. Im guessing it's down to the fact that the tools are built from modules rather than dedicated modules. Hopefully malc will make some decent tools for SM but i don't know when that will happen.
Wrote something here? To have a post removed or your name hidden, write to [email protected].