English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 20 March 2024, 16:13   #1
VladR
Registered User
 
Join Date: Dec 2019
Location: North Dakota
Posts: 741
Placement of code and data in FastRam

While working on my RTG benchmark, I want to dedicate one of the tests to differences between ChipRam and FastRam.

I'm using vasm and hunkexe format, so it should be a relocatable format (no .ORG or absolute memory addresses anywhere).

When I printed the addresses of the first/last line of code and data at run-time, I noticed that they are all in FastRAM (unless I change the attribute in the SECTION to use chipram) - well based on the range that SysInfo gives me under WinUAE.

Is that guaranteed, though ? I am not using AllocMem and all my data is compile-time allocated (for now). It would be of great benefit if I didn't have to refactor the code to use AllocMem and both code/data would be guaranteed to be placed in FastRAM.

I do not intend to run it below 040 initially, and some time in the future, I might try to make it run on slowest RTG config (A1200, I suspect) - but for now, let's say 040.
VladR is offline  
Old 20 March 2024, 16:38   #2
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Segment loader is allocating public memory (unless a hunk is tagged to use something else), so as long as fastmem has higher priority over chipmem you'll get fastmem if a hunk fits.
a/b is offline  
Old 20 March 2024, 17:05   #3
VladR
Registered User
 
Join Date: Dec 2019
Location: North Dakota
Posts: 741
Quote:
Originally Posted by a/b View Post
Segment loader is allocating public memory (unless a hunk is tagged to use something else), so as long as fastmem has higher priority over chipmem you'll get fastmem if a hunk fits.
Does that mean, if I suddenly started using a single giant array which would then cause the segment to not fit into a single available block, then the OS would downgrade to non-fastmem (assuming lower-class RAM would fit it)?

And what exactly is that kind of RAM anyway ? If it's not chipset, what other is there ? The trapdoor local expansion one perhaps ?

Is there a difference between FastRAM on the expansion card (say, with 128 MB RAM) and FastRAM in the motherboard ?
VladR is offline  
Old 20 March 2024, 17:41   #4
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Yeah, if you run out of fastmem while asking for public mem, you will get chipmem.
Each part of the memory pool has a priority, and allocation works down the list. So, fast with several priority levels (Z3, Z2, ..., that should answer your last question) > slow/ranger > chip.
a/b is offline  
Old 20 March 2024, 18:09   #5
VladR
Registered User
 
Join Date: Dec 2019
Location: North Dakota
Posts: 741
Thanks, that's great to hear. I presume this order of allocation should be documented somewhere in the OS/library docs...

So, technically, looks like I can get away with not refactoring the code to use AllocMem, as static allocation will work just fine and get me a FastRAM for both code+data and FrameBuffer (which is what I need).

I guess I can always just print out the address range used for code+data/framebuffer and this way the user will know exactly (for his particular system), what kind of RAM has been given to the executable by the OS. This should take care of all the "why did it run slower this time?" questions - the answers will be given to the user on the first screen of the program.
VladR is offline  
Old 20 March 2024, 20:00   #6
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,231
Quote:
Originally Posted by VladR View Post
Thanks, that's great to hear. I presume this order of allocation should be documented somewhere in the OS/library docs...
How AllocMem works is documented in the RKRM libraries, how the dos.library scatter loader aka LoadSeg() works is documented in the RKRM DOS.


Quote:
Originally Posted by VladR View Post
I guess I can always just print out the address range used for code+data/framebuffer and this way the user will know exactly (for his particular system), what kind of RAM has been given to the executable by the OS.
The type of memory you get with TypeOfMem(), which is a function of exec. That provides you the memory attributes (or 0) a specific memory location has. Thus, if you requested MEMF_PUBLIC, but the system run out of fast memory, TypeOfMem() will give you MEMF_PUBLIC|MEMF_CHIP as result.
Thomas Richter is offline  
Old 20 March 2024, 20:05   #7
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,104
Yes, it is documented (http://amigadev.elowar.com/read/ADCD.../node02A6.html). Static allocation will work just fine, and in practice you don't have to worry about fast buffers being demoted to chip ram. That will really only happen on very low spec systems, and the user will be used to it.
You can also force your segments to be in fast ram, but there are only downsides to this. Just use TypeOfMem and print a warning if you really need to.

Most accelerator cards will just have a comparatively large amount of fast ram where you program will always fit. The priority case only comes up in niche situations (like this awesome thing: https://eab.abime.net/showthread.php?t=115241&nojs=1)
paraj is offline  
Old 21 March 2024, 13:00   #8
VladR
Registered User
 
Join Date: Dec 2019
Location: North Dakota
Posts: 741
Quote:
Originally Posted by Thomas Richter View Post
How AllocMem works is documented in the RKRM libraries, how the dos.library scatter loader aka LoadSeg() works is documented in the RKRM DOS.



The type of memory you get with TypeOfMem(), which is a function of exec. That provides you the memory attributes (or 0) a specific memory location has. Thus, if you requested MEMF_PUBLIC, but the system run out of fast memory, TypeOfMem() will give you MEMF_PUBLIC|MEMF_CHIP as result.
Thanks, I just checked out TypeOfMem, and it's exactly what I was looking for!

I also need to redownload the Amiga docs, as I couldn't find them in my Amiga Dev directory (it probably didn't make it to the new computer - I hate this part - you always forget some directories from old HDD).
VladR is offline  
Old 21 March 2024, 13:06   #9
VladR
Registered User
 
Join Date: Dec 2019
Location: North Dakota
Posts: 741
Quote:
Originally Posted by paraj View Post
Yes, it is documented (http://amigadev.elowar.com/read/ADCD.../node02A6.html). Static allocation will work just fine, and in practice you don't have to worry about fast buffers being demoted to chip ram. That will really only happen on very low spec systems, and the user will be used to it.
Right, since I require RTG, I kinda bypassed all the low-spec systems anyway. For once there is some advantage to not dealing with OCS/ECS


Quote:
Originally Posted by paraj View Post
You can also force your segments to be in fast ram, but there are only downsides to this. Just use TypeOfMem and print a warning if you really need to.
What exactly do you mean by forcing ? At compile-time via SECTION directive ? Because that's what I use for data now.

Quote:
Originally Posted by paraj View Post
Most accelerator cards will just have a comparatively large amount of fast ram where you program will always fit. The priority case only comes up in niche situations (like this awesome thing: https://eab.abime.net/showthread.php?t=115241&nojs=1)
My current code size is 60 KB. Data is around 250 KB. Framebuffers, though, take a lot.

But still, comfortably, under 4 MB total - which shouldn't be a big deal for any low-spec RTG system, right ?.

Last edited by VladR; 21 March 2024 at 13:06. Reason: typos
VladR is offline  
Old 21 March 2024, 14:32   #10
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,231
Quote:
Originally Posted by VladR View Post
But still, comfortably, under 4 MB total - which shouldn't be a big deal for any low-spec RTG system, right ?.
No, that shouldn't be a big deal.
Thomas Richter is offline  
Old 21 March 2024, 20:10   #11
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,104
Quote:
Originally Posted by VladR View Post
Right, since I require RTG, I kinda bypassed all the low-spec systems anyway. For once there is some advantage to not dealing with OCS/ECS
If you run out of fast mem your normal buffers will still be demoted to chipmem, but no big deal.

Quote:
Originally Posted by VladR View Post
What exactly do you mean by forcing ? At compile-time via SECTION directive ? Because that's what I use for data now.
Yes, exactly, like having "data_f" sections. I.e. sections where you require fast ram. IMO there is not reason to do that. You will just be preventing potentially useful benchmarking/marginal systems from running for no good reason.

Quote:
Originally Posted by VladR View Post
My current code size is 60 KB. Data is around 250 KB. Framebuffers, though, take a lot.

But still, comfortably, under 4 MB total - which shouldn't be a big deal for any low-spec RTG system, right ?.
Totally fine, and on RTG systems I guess framebuffers will mostly(?) always not take up any fast ram (i.e. be buffers allocated on the graphics device).
paraj 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
VBCC: How to use small code/data models with nostdlib Hedeon Coders. C/C++ 23 04 October 2023 01:10
Mutable data in code section hop Coders. Asm / Hardware 19 08 June 2022 20:09
Code / data / tools of Scoopex "TWO" (rotozoom cracktro for Starquake) Yragael Coders. Tutorials 4 24 November 2018 10:44
A600 4mb Fastram + A1200 Mb Fastram mikele MarketPlace 7 07 May 2012 19:28
A600 floppy placement. prart support.Hardware 4 08 September 2008 08:47

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 08:41.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.23405 seconds with 15 queries