Assembly - divps and CPU load?

If you require help or assistance with anything then please post here

Moderators: electrogear, exonerate

Re: Assembly - divps and CPU load?

Postby trogluddite on Mon Jan 11, 2010 6:41 am

trogluddite wrote:Replacing all the modlulus, division and rounding with SSE2 stuff and rcpps, I nearly halved the CPU load.
MegaHurtz wrote:Rccps is as heavy i dunno who told you the opposite it`s 1/x.

Stoopid me! I always have to learn stuff the hard way. I'd read this one on the forums somewhere - the low CPU looked great at first - till I had all my audio paths running at once - then the denorms started breeding like bunnies! Oh well, back to divps then! All running nicely now - and still saved about 30% of the CPU :) .
TomC wrote:If you know the internal representation of the floating values (e.g. if they are IEEE 754) you can mask them directly with an integer

Masking the mantissa but not the exponent - that kind of thing? Time for some experiments.
infuzion wrote:Use a text editor that has code highlighting.

Thanks for the tip, I'll go see what those nice folks at Source Forge have in their box of goodies...

The Luddite
Feel free to use any schematics and algorithms I post on the forum in your own designs - a credit is appreciated (but not a requirement).
Don't stagnate, mutate to create. Without randomness and serendipity the earth would be just another barren rock.
User avatar
trogluddite
smychopath
 
Posts: 3024
Joined: Mon Oct 20, 2008 3:52 pm
Location: Yorkshire, UK

Re: Assembly - divps and CPU load?

Postby infuzion on Mon Jan 11, 2010 2:04 pm

trogluddite wrote:
MegaHurtz wrote:Rccps is as heavy i dunno who told you the opposite it`s 1/x.

Stoopid me! I always have to learn stuff the hard way. I'd read this one on the forums somewhere - the low CPU looked great at first - till I had all my audio paths running at once - then the denorms started breeding like bunnies! Oh well, back to divps then! All running nicely now - and still saved about 30% of the CPU :).
Division by whole numbers take about half as much cycles no modern CPUs, so as long as your dependency interpolation is set up well, you should notice little impact. Post/send the OSM if you'd like to see if there could be more savings.
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6163
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Re: Assembly - divps and CPU load?

Postby trogluddite on Mon Jan 11, 2010 6:46 pm

trogluddite wrote:Post/send the OSM if you'd like to see if there could be more savings.

You guys are just too nice! :D
When I've next got time on my big computer, I'll try and break it down into bite sized chunks - already getting loads of ideas from my forum searches, but this ASM stuff is really taxing my grey matter! :S
Feel free to use any schematics and algorithms I post on the forum in your own designs - a credit is appreciated (but not a requirement).
Don't stagnate, mutate to create. Without randomness and serendipity the earth would be just another barren rock.
User avatar
trogluddite
smychopath
 
Posts: 3024
Joined: Mon Oct 20, 2008 3:52 pm
Location: Yorkshire, UK

Re: Assembly - divps and CPU load?

Postby trogluddite on Thu Jan 14, 2010 12:00 am

infuzion wrote:Use a text editor that has code highlighting

Thanks again; that's Top Tip of the month for sure! :)
Just installed Notepad++ from sourceforge; wow, what a difference that makes. Just rooted out about a dozen unused variable declarations from 750+ lines of assembly in a few minutes, and searching for where you've used a register is a breeze!
If any Notepad++ users are interested here's a little user language file for the S|M ASM primitive with just the recognised opcodes, and the stream bits included...
SM Assembly for NotepadPP.zip
(901 Bytes) Downloaded 99 times

...had to zip it, SM won't attach .xml files. Put in in your Doc's and Settings/username/Notepad++ folder, or cut and paste the relevant bits into the user language file if you have one already.
Feel free to use any schematics and algorithms I post on the forum in your own designs - a credit is appreciated (but not a requirement).
Don't stagnate, mutate to create. Without randomness and serendipity the earth would be just another barren rock.
User avatar
trogluddite
smychopath
 
Posts: 3024
Joined: Mon Oct 20, 2008 3:52 pm
Location: Yorkshire, UK

Re: Assembly - divps and CPU load?

Postby Andrew J on Thu Jan 14, 2010 2:00 am

trogluddite wrote:If any Notepad++ users are interested here's a little user language file for the S|M ASM primitive with just the recognised opcodes, and the stream bits included...
SM Assembly for NotepadPP.zip

...had to zip it, SM won't attach .xml files. Put in in your Doc's and Settings/username/Notepad++ folder, or cut and paste the relevant bits into the user language file if you have one already.


Nice - thanks for that!
Andrew J
smanatic
 
Posts: 616
Joined: Tue May 29, 2007 4:53 am
Location: Australia

Re: Assembly - divps and CPU load?

Postby TomC on Thu Jan 14, 2010 9:06 am

trogluddite wrote:from 750+ lines of assembly in a few minutes


If the 750 lines are one single code I would rethink your approach.

trogluddite wrote:If any Notepad++
SM Assembly for NotepadPP.zip


Thanks a lot for that.

Tom
.signature failure
User avatar
TomC
smanatic
 
Posts: 706
Joined: Tue Oct 02, 2007 9:34 pm
Location: 3rd rock from the sun

Re: Assembly - divps and CPU load?

Postby aliasant on Thu Jan 14, 2010 9:28 am

Thanx Luddite !

This style looks much better then the default Assembly style but I had some difficulties placing the langauge file in the right place :)
For others using Win7 drop the file in this folder and restart the app:
username/appdata/roaming/notepad++
It's never to late to be late.....
http://martinrodensjo.smugmug.com/
User avatar
aliasant
smunatic
 
Posts: 2386
Joined: Sat Dec 30, 2006 5:49 pm
Location: Sweden

Re: Assembly - divps and CPU load?

Postby trogluddite on Thu Jan 14, 2010 1:45 pm

aliasant wrote:For others using Win7

Ah yes, sorry, should have pointed out that I'm still on XP!
TomC wrote:If the 750 lines are one single code I would rethink your approach

Not so easy with this one as it's not really a standard synth/FX architecture, more like a self comtained app - all of the core features rely on a common audio buffer - once that's inside a code primitive (as opposed to using mem array components), there's no way to share the buffer between modules. Now that I have a quck way to edit the code, I'm quite happy working this way - I'm used to it from the Z80 ASM I used to write on my ZX Spectrum years (decades!) ago (used to have to convert the code to hex by hand in those days too!). Managed to lose nearly 150 lines during optimisation already though.
Feel free to use any schematics and algorithms I post on the forum in your own designs - a credit is appreciated (but not a requirement).
Don't stagnate, mutate to create. Without randomness and serendipity the earth would be just another barren rock.
User avatar
trogluddite
smychopath
 
Posts: 3024
Joined: Mon Oct 20, 2008 3:52 pm
Location: Yorkshire, UK

Re: Assembly - divps and CPU load?

Postby MegaHurtz on Thu Jan 14, 2010 6:23 pm

If you get it to run you save some movaps.

funny that:

movaps xmm1,diva;
movaps xmm2,divb;
divps xmm1,xmm2;
movaps out,xmm1;

Uses less cpu than the divider primitive :D
Visit my website at: http://www.schlukhash.nl
User avatar
MegaHurtz
smaniac
 
Posts: 1511
Joined: Mon Aug 11, 2008 5:29 pm
Location: Eindhoven/Netherlands

Re: Assembly - divps and CPU load?

Postby rl on Thu Jan 14, 2010 10:17 pm

I don't believe your claim :)

If you connect both div methods to an analyser, that's the code for the div primitive:
Code: Select all
***** Init *****
push ebp;
mov ebp,edi;
pop ebp
ret;
***** Sample Rate *****
push ebp;
mov ebp,edi;
movaps xmm0,dword ptr[ebp+4208]
divps xmm0,dword ptr[ebp+4224]
movaps dword ptr[ebp+4192],xmm0
pop ebp
ret;

your asm code:
Code: Select all
***** Init *****
push ebp;
mov ebp,edi;
pop ebp
ret;
***** Sample Rate *****
push ebp;
mov ebp,edi;
movaps xmm1,dword ptr[ebp+4208]
movaps xmm2,dword ptr[ebp+4224]
divps xmm1,xmm2
movaps dword ptr[ebp+4192],xmm1
pop ebp
ret;

Pretty much the same
User avatar
rl
dsp wiz
 
Posts: 1494
Joined: Mon Feb 07, 2005 10:24 pm
Location: de.earth.universe.known

Re: Assembly - divps and CPU load?

Postby infuzion on Thu Jan 14, 2010 10:22 pm

rl wrote:
MegaHurtz wrote:If you get it to run you save some movaps.
movaps xmm1,diva;
movaps xmm2,divb;
divps xmm1,xmm2;
movaps out,xmm1;
Uses less cpu than the divider primitive :D

I don't believe your claim
If you have only a divide by itself, either one is the same. If you have a bunch of other opcodes before/after that divps in the same Assembly primitive, epically if they're outside of the divide's dependence chain, then that divps will indeed be faster.
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6163
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Re: Assembly - divps and CPU load?

Postby stw on Thu Jan 14, 2010 11:05 pm

rl wrote:If you connect both div methods to an analyser, that's the code for the div primitive:
Code: Select all
***** Init *****
push ebp;
mov ebp,edi;
pop ebp
ret;
***** Sample Rate *****
push ebp;
mov ebp,edi;
movaps xmm0,dword ptr[ebp+4208]
divps xmm0,dword ptr[ebp+4224]
movaps dword ptr[ebp+4192],xmm0
pop ebp
ret;


where do you get that code from?
stw
smanatic
 
Posts: 639
Joined: Mon Jun 30, 2008 2:55 pm

Re: Assembly - divps and CPU load?

Postby rl on Fri Jan 15, 2010 8:03 am

through the signal analyzer. SM's mighty general purpose debugging tool:

analyzer.png
analyzer.png (30.68 KiB) Viewed 1157 times
User avatar
rl
dsp wiz
 
Posts: 1494
Joined: Mon Feb 07, 2005 10:24 pm
Location: de.earth.universe.known

Re: Assembly - divps and CPU load?

Postby stw on Fri Jan 15, 2010 9:21 am

wohoo... :love:
Didn't know that. This is really cool!
Thanks for the info!
stw
smanatic
 
Posts: 639
Joined: Mon Jun 30, 2008 2:55 pm

Re: Assembly - divps and CPU load?

Postby MegaHurtz on Fri Jan 15, 2010 12:18 pm

Thats a nice feat indeed, havnt seen that before.
Also tells you the SM version uses the smaller register :D
Sometimes higher cycles with lower cpu spike equals lower percentage.
Visit my website at: http://www.schlukhash.nl
User avatar
MegaHurtz
smaniac
 
Posts: 1511
Joined: Mon Aug 11, 2008 5:29 pm
Location: Eindhoven/Netherlands

Previous

Return to Help

Who is online

Users browsing this forum: No registered users and 2 guests