Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: ejstans on July 10, 2011, 06:17:27 PM

Title: 64KiB alignment?
Post by: ejstans on July 10, 2011, 06:17:27 PM
Hola!

I was reading through some old Amiga magazine where it talked about aligning bitplanes on 64KiB boundaries for maximum speed. Huh? What's this about?
Title: Re: 64KiB alignment?
Post by: Piru on July 10, 2011, 06:53:02 PM
Quote from: ejstans;648945
I was reading through some old Amiga magazine where it talked about aligning bitplanes on 64KiB boundaries for maximum speed. Huh? What's this about?

64bit. Either the article is incorrect or you read it wrong.
Title: Re: 64KiB alignment?
Post by: ejstans on July 10, 2011, 07:06:17 PM
There's a good chance the article is incorrect (they've printed nonsense before), but I did find another reference to the 64KiB alignment. In the "How to code (http://www.mways.co.uk/amiga/howtocode/text/generalguidelines.php)" series, in the section on relocatable code, we find the following sentence: "If you require bitplanes to be on a 64Kb boundary then try the following [...]" followed by code clearly trying to allocate on 64 kilobyte boundary.

It doesn't say anything about the reason for such a want though.

So, what are they talking about, if not nonsense? Worth pointing out that this is pre-AGA also. Is the 64-bit alignment applicable on OCS/ECS?
Title: Re: 64KiB alignment?
Post by: Zac67 on July 10, 2011, 07:25:33 PM
OCS/ECS don't care too much about alignment, needs to be 16-bit obviously. AGA introduced 32-bit access, so bitplanes need to be aligned likewise.
I suppose 64-bit is for emulation optimization. 64 KiB sounds very strange...
Title: Re: 64KiB alignment?
Post by: ChaosLord on July 10, 2011, 07:48:14 PM
All my bitplanes are 64-bit aligned.  If anyone can find any evidence that 128-bit or larger alignment provides an advantage then please tell me.  Thanks.
Title: Re: 64KiB alignment?
Post by: ChaosLord on July 10, 2011, 07:50:24 PM
Would it help speed up WinUAE if I increased my alignment to 128-bit or larger?
Title: Re: 64KiB alignment?
Post by: Zac67 on July 10, 2011, 09:22:36 PM
Modern x86 CPUs use 64-byte cache lines, so 512-bit alignment may be of advantage for emulation - provided emulation memory gets aligned, too...
Title: Re: 64KiB alignment?
Post by: Karlos on July 10, 2011, 09:25:03 PM
Quote from: Zac67;648968
Modern x86 CPUs use 64-byte cache lines, so 512-bit alignment may be of advantage for emulation - provided emulation memory gets aligned, too...


I'd hope that the emulated amiga's memory blocks were page aligned on the host.
Title: Re: 64KiB alignment?
Post by: Crumb on July 10, 2011, 09:29:58 PM
Quote from: ChaosLord;648951
All my bitplanes are 64-bit aligned.  If anyone can find any evidence that 128-bit or larger alignment provides an advantage then please tell me.  Thanks.


There are certain 040/060 instructions that allow performing very fast memcpy when data is 128bit aligned but I don't think it makes much difference with chipram in practice.
Title: Re: 64KiB alignment?
Post by: Leffmann on July 10, 2011, 10:07:32 PM
The reason people did 64K alignment of bitplanes, and more often areas touched by the Blitter, was in order to squeeze out a little extra performance by not having to repeatedly set the high word of the pointers since it wouldn't change.

In a tight loop doing many smaller blits you could always up the number of bobs or whatever on the screen like this, especially on the unexpanded classic machines.

Aligning the data in your emulated Amiga on 64 byte boundaries to suit the outside machine isn't going to make a difference, there's just too much stuff happening for that to be noticable, but f.ex aligning your 32-bit accesses on 68020 and up will of course still matter inside your emulated Amiga.
Title: Re: 64KiB alignment?
Post by: psxphill on July 10, 2011, 10:09:35 PM
Quote from: ChaosLord;648951
All my bitplanes are 64-bit aligned. If anyone can find any evidence that 128-bit or larger alignment provides an advantage then please tell me. Thanks.

Aligning on 64k boundaries allows you to do some funky things just by updating the high part of the blitter/bitplane address registers.
Title: Re: 64KiB alignment?
Post by: minator on July 11, 2011, 01:15:51 AM
Quote from: ChaosLord;648951
All my bitplanes are 64-bit aligned.  If anyone can find any evidence that 128-bit or larger alignment provides an advantage then please tell me.  Thanks.


IIRC the G5 cache lines were 128 bytes long so it makes sense to align them on that scale if you plan on running on a G5 or X1000.

OTOH 64KB doesn't make much sense.
Title: Re: 64KiB alignment?
Post by: ejstans on July 11, 2011, 08:49:37 AM
Quote from: Leffmann;648981
The reason people did 64K alignment of bitplanes, and more often areas touched by the Blitter, was in order to squeeze out a little extra performance by not having to repeatedly set the high word of the pointers since it wouldn't change.

In a tight loop doing many smaller blits you could always up the number of bobs or whatever on the screen like this, especially on the unexpanded classic machines.

Aligning the data in your emulated Amiga on 64 byte boundaries to suit the outside machine isn't going to make a difference, there's just too much stuff happening for that to be noticable, but f.ex aligning your 32-bit accesses on 68020 and up will of course still matter inside your emulated Amiga.

Quote from: psxphill;648982
Aligning on 64k boundaries allows you to do some funky things just by updating the high part of the blitter/bitplane address registers.

Ah, thank you both! This would explain it then! :)