English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 19 April 2010, 15:05   #1
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 45
Posts: 276
Using FPU registers?

I'm running out of registers in my application! However I was thinking of beginning to use FPU registers, just for temporary storage. Imagine this scenario:
fmove d0,fp0
-- do calculations --
fmove fp0,d0

Is the above faster than using a simple variable in RAM? Like
move.l d0,temp
--- do calculations --
move.l temp,d0
oRBIT is offline  
Old 19 April 2010, 15:17   #2
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,542
move.l d0,-(a7)
move.l (a7)+,d0

'nuff said.
StingRay is offline  
Old 19 April 2010, 15:27   #3
pmc
gone
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
LOL.

Never one to mince words is Stinger.
pmc is offline  
Old 19 April 2010, 15:29   #4
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 45
Posts: 276
@Stingray: Yeah but is it really faster? Your way involves a memory read/write, which the fmove doesn't (?)
oRBIT is offline  
Old 19 April 2010, 15:32   #5
coze
hastala vista winny vista
coze's Avatar
 
Join Date: Feb 2006
Location: mt fuji
Age: 42
Posts: 1,335
Send a message via ICQ to coze Send a message via Yahoo to coze
well, why don't you just test and see with a simple code ?
coze is offline  
Old 19 April 2010, 15:36   #6
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 45
Posts: 276
My environment is currently consisting of WinUAE only (sadly) so..
oRBIT is offline  
Old 19 April 2010, 15:37   #7
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,542
Quote:
Originally Posted by oRBIT View Post
@Stingray: Yeah but is it really faster? Your way involves a memory read/write, which the fmove doesn't (?)
First of all, using the FPU for temporary storage is really really stupid, your program will require an FPU only because you used it to store registers. Also, writing to the FPU requires a fair amount of time (convert to 80bit, convert to 32 bit integer again etc).
StingRay is offline  
Old 19 April 2010, 15:43   #8
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 45
Posts: 276
Yes of course it will require an FPU. I was just curious if there was any obvious "performance-improvement" compared to storing data in RAM...
oRBIT is offline  
Old 19 April 2010, 18:24   #9
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
The integer <-> fp conversion is too slow. Even if the data were single precision fp in the integer register it wouldn't be worth using the fp register. If you don't need fp operations then don't use the floating point registers. Operate directly on variables in memory or use the stack.
matthey is offline  
Old 19 April 2010, 18:30   #10
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,542
Quote:
Originally Posted by oRBIT View Post
I was just curious if there was any obvious "performance-improvement" compared to storing data in RAM...
There isn't. And it should actually be obvious why. Anyway, I made some quick tests on my A4060, results:

15000 x fmove d0,fp0 fmove fp0,d0: : 147 raster lines (143 raster lines for fmove.s)
15000 x move.l d0,-(a7) move.l (a7)+,d0: 126 raster lines

It'll be even worse on 030/FPU systems.

Quote:
Originally Posted by matthey View Post
The integer <-> fp conversion is too slow. Even if the data were single precision fp in the integer register it wouldn't be worth using the fp register. If you don't need fp operations then don't use the floating point registers. Operate directly on variables in memory or use the stack.
That's basically exactly what I said.
StingRay is offline  
Old 19 April 2010, 18:36   #11
seuden
uber cool demi god

seuden's Avatar
 
Join Date: Jun 2006
Location: Kent/England
Posts: 2,044
If you don't listen to Sting you'll only get stung!
seuden is offline  
Old 19 April 2010, 20:17   #12
Photon
Moderator

Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 4,821
Well, he could have been using the FPU already in another part of the program. No need to call coders stupid, especially those coding advanced things are usually highly intelligent. And it makes sense to not rely on WinUAE timings. So.

But when you get bitten by the coding bug (again) I think you should get a real Amiga, then you can test things like this easily.

btw, orbit=orbiter?
Photon is offline  
Old 19 April 2010, 20:52   #13
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,542
Quote:
Originally Posted by Photon View Post
Well, he could have been using the FPU already in another part of the program. No need to call coders stupid, especially those coding advanced things are usually highly intelligent. And it makes sense to not rely on WinUAE timings. So.
Dear Photon, please learn to read, thank you! I said using FPU registers for temporary storage is stupid and not that oRBIT is stupid!
StingRay is offline  
Old 19 April 2010, 21:08   #14
Photon
Moderator

Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 4,821
Yes, you're correct. But I also think there's no need to accuse someone of doing stupid things before you know the reason why. He had two good reasons why he even asked about it, and since the stack and FPU method were so close, speed-wise it was not obvious that one was faster than the other. What if, for example, the FPU register method had been the fastest by 1 scanline for the AGA-060 platform? Then he would have found a faster method which all AGA 060 coders could use, and as we all know, "if it's faster it's faster" , and this 'standard demo platform' has a built in FPU.

Whether it feels correct to do this, well, I agree. But if it had been slightly faster, then all coders would have used this new method (where applicable). So.
Photon is offline  
Old 19 April 2010, 21:24   #15
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,542
Quote:
Originally Posted by Photon View Post
But I also think there's no need to accuse someone of doing stupid things before you know the reason why. He had two good reasons why he even asked about it, and since the stack and FPU method were so close, speed-wise it was not obvious that one was faster than the other.
He asked, I answered. As simple as that. EOD.
StingRay is offline  
Old 19 April 2010, 22:35   #16
cosmicfrog
The 1 who ribbits
cosmicfrog's Avatar
 
Join Date: Apr 2006
Location: leek, Staffs, UK
Age: 53
Posts: 3,556
Send a message via MSN to cosmicfrog
heheheh

fight fight

don`t think anyone got called stupid, idea may have been shot down in flames though with proof to back it up
cosmicfrog is offline  
Old 26 April 2010, 14:34   #17
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 52
Posts: 1,250
Quote:
Originally Posted by oRBIT View Post
I'm running out of registers in my application! However I was thinking of beginning to use FPU registers, just for temporary storage. Imagine this scenario:
fmove d0,fp0
-- do calculations --
fmove fp0,d0

Is the above faster than using a simple variable in RAM? Like
move.l d0,temp
--- do calculations --
move.l temp,d0
How many registers you need?
You can use up to 17 Motorola registers, and if no longword values you can split 8 data registers via SWAP command, this is enough for almost all routines.
Don_Adan is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying blitter registers while it's running mc6809e Coders. Asm / Hardware 8 30 June 2013 16:57
Need DA8000-DAFFFF registers documentation BlueAchenar Coders. General 2 13 December 2008 16:39
Amiga Inc. registers new brands in Germany viddi Amiga scene 7 27 February 2007 01:35
Gayle Hardware Registers bluea support.Hardware 5 09 July 2006 18:07
blizzard 1230iv scsi no longer registers :( Boot_WB support.Hardware 5 24 November 2004 03:26

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:31.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.10756 seconds with 13 queries