Is ASM faster or better than DSP?

DSP related issues, mathematics, processing and techniques
Post Reply
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Is ASM faster or better than DSP?

Post by Spogg »

Hi all

Simple question (I hope!). I see that quite a few people create DSP code blocks then convert the compiled code to ASM.
Why? Is it faster, more accurate or what?
When I've done this myself I can't detect any improvement.

Cheers

Spogg
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Is ASM faster or better than DSP?

Post by adamszabo »

ASM is the closest code to give instructions to the CPU. The DSP code will anyway be converted into ASM no matter what, but sometimes its not as "smart", and compiles the code with unnecessary instructions. If you learn to write your code from scratch in assembly you can really optimize it well and it will be faster than the DSP code.
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Is ASM faster or better than DSP?

Post by Tronic »

Hi Spogg,
the improvement is how you optimize the assembler code.

this is the result of original compiled abs function:

Code: Select all

streamin in;
streamout out;

float smIntVarTemp=0.0;
float smIntVarZero=0;

movaps xmm0,in;
movaps smIntVarTemp,xmm0;
cmpps xmm0,smIntVarZero,6;
andps xmm0,smIntVarTemp;
addps xmm0,xmm0;
subps xmm0,smIntVarTemp;
movaps out,xmm0;


thi is the optimized version:

Code: Select all

streamin in;
streamout out;

int absMask=2147483647;

movaps xmm0,in;
andps xmm0,absMask;
movaps out,xmm0;
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: Is ASM faster or better than DSP?

Post by Spogg »

Ahhh! Thanks for that guys, now I get it. :)
Thanks for the answers.
Spogg
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: Is ASM faster or better than DSP?

Post by Nubeat7 »

just in case if someone asks himself where tronic got the original abs code from, just use the "S" output on the DSP module, this is the ASM code version from your DSP code as text, which you can now copy - paste into the ASM moduleand optimize it there..

if you are interested in optimizing your DSP codes and ASM codes you should have a look to KG's great articles on flowstone guru:

http://flowstone.guru/blog/optimizing-d ... component/
http://flowstone.guru/blog/optimizing-c ... assembler/
http://flowstone.guru/blog/advanced-dsp ... tion-tips/
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: Is ASM faster or better than DSP?

Post by Spogg »

Many thanks for that Nubeat7. Some great info there.
Cheers
Spogg
Post Reply