Want to make sure I enable the cache in the right way

Hardware, coding, music, graphic and various applications

Moderators: Mug UK, lp, moondog/.tSCc., [ProToS], Moderator Team

Post Reply
Zamuel_a
Atari God
Atari God
Posts: 1285
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

Want to make sure I enable the cache in the right way

Post by Zamuel_a »

I am testing a 3d program I made and get very strange results when I compare it on a real Falcon and in Hatari (I wrote about it in the Hatari section). With everything turned on in Hatari for the most accurate emulation I get around 18fps on my program (both what I measure with the 200Hz timer and it "feels" like 18fps).
On my real machine I get 4 fps, so not really close.
I wonder what the problem might be. If it's something related to the cache on the real machine? Are the caches turned on by default? I guess so since when I turned it on in my program I didn't see any difference.

To set the different cache flags I used:

Code: Select all

;---------------------------------------------------------------------
; Set CacheControlRegister
setCACR:
	movec	cacr,d1
	or.w	d0,d1
	movec	d1,cacr
	rts
	
clearCACR:
	movec	cacr,d1
	eor.w	#$FFFF,d0
	and.w	d0,d1
	movec	d1,cacr
	rts
I call this from Pure C and use these defines

Code: Select all

#define WA	8192		/* 13 -Write Allocate */
#define DBE	4096		/* 12 - Data Cache Burst Enable - Not supported by the Falcon030! */
#define CD	2048		/* 11 - Clear Data Cache */
#define CED	1024		/* 10 - Clear Entry in Data Cache */
#define FD	512		/* 9 - Freeze Data Cache */
#define ED	256		/* 8 - Enable Data Cache */

#define IBE	16		/* 4 - Instruction Cache Burst Enable - Not supported by the Falcon030! */
#define CI	8		/* 3 - Clear Instruction Cache */
#define CEI	4		/* 2 - Clear Entry in Instruction Cache */
#define FI	2		/* 1 - Freeze Instruction Cache */
#define EI	1		/* 0 - Enable Instruction Cache */
And in the beginning of my program I turn Instruction cache on and data cache off

Code: Select all

	clearCACR(ED);
	setCACR(EI | CI);

This is done in the same way on Hatari as on a real machine, but why I get 4 times the speed in Hatari is very strange.
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe
mikro
Hardware Guru
Hardware Guru
Posts: 4566
Joined: Sat Sep 10, 2005 11:11 am
Location: Kosice, Slovakia
Contact:

Re: Want to make sure I enable the cache in the right way

Post by mikro »

What about those cache freeze bits? That looks like the culprit to me.
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3329
Joined: Sun Aug 03, 2014 5:54 pm

Re: Want to make sure I enable the cache in the right way

Post by ThorstenOtto »

And are you sure you have are emulating a 030 in Hatari? for 040/060, the CACR is different.
Zamuel_a
Atari God
Atari God
Posts: 1285
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

Re: Want to make sure I enable the cache in the right way

Post by Zamuel_a »

ThorstenOtto wrote: Mon Sep 27, 2021 2:20 pm And are you sure you have are emulating a 030 in Hatari? for 040/060, the CACR is different.
Yes Hatari says
16MHz/030(CE)-14Mb Falcon TOS 4.04 VGA 50Hz
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe
User avatar
Cyprian
10 GOTO 10
10 GOTO 10
Posts: 3258
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Want to make sure I enable the cache in the right way

Post by Cyprian »

Zamuel_a wrote: Mon Sep 27, 2021 3:59 pm VGA 50Hz
VGA modes slow down CPU significantly and I'm not sure whether Hatari properly emulates Videl's bus accesses
Lynx I / Mega ST 1 / 7800 / Portfolio / Lynx II / Jaguar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
DDD HDD / AT Speed C16 / TF536 / SDrive / PAK68/3 / Lynx Multi Card / LDW Super 2000 / XCA12 / SkunkBoard / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.atari.org
czietz
Hardware Guru
Hardware Guru
Posts: 2734
Joined: Tue May 24, 2016 6:47 pm

Re: Want to make sure I enable the cache in the right way

Post by czietz »

Cyprian wrote: Mon Sep 27, 2021 5:43 pm VGA modes slow down CPU significantly and I'm not sure whether Hatari properly emulates Videl's bus accesses
Good point! I ran CoreMark under Hatari 2.3.1 Falcon emulation in ST High and in Truecolor mode and it gave the same result: 9.73 it/s (Hatari settings: "16MHz/030(CE)"). On a real Falcon the benchmark results are significantly less and decrease further for Truecolor video mode, as shown here: https://github.com/czietz/coremark/wiki/Results
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3899
Joined: Sun Jul 31, 2011 1:11 pm

Re: Want to make sure I enable the cache in the right way

Post by Eero Tamminen »

czietz wrote: Mon Sep 27, 2021 6:03 pm
Cyprian wrote: Mon Sep 27, 2021 5:43 pm VGA modes slow down CPU significantly and I'm not sure whether Hatari properly emulates Videl's bus accesses
Good point! I ran CoreMark under Hatari 2.3.1 Falcon emulation in ST High and in Truecolor mode and it gave the same result: 9.73 it/s (Hatari settings: "16MHz/030(CE)"). On a real Falcon the benchmark results are significantly less and decrease further for Truecolor video mode, as shown here: https://github.com/czietz/coremark/wiki/Results
What kind of speed differences there are with different TrueColor resolutions, for example "40 cols, interlace off" and "80 cols, interlace on"?
czietz
Hardware Guru
Hardware Guru
Posts: 2734
Joined: Tue May 24, 2016 6:47 pm

Re: Want to make sure I enable the cache in the right way

Post by czietz »

Eero Tamminen wrote: Mon Sep 27, 2021 6:57 pm What kind of speed differences there are with different TrueColor resolutions, for example "40 cols, interlace off" and "80 cols, interlace on"?
I can't test this right now as my Falcon (mainboard) is in storage. Maybe someone else can provide these numbers by running CoreMark? Generally, the higher the memory bandwidth for video, the slower the Falcon becomes as Videl and CPU have to share access to RAM.
User avatar
Cyprian
10 GOTO 10
10 GOTO 10
Posts: 3258
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Want to make sure I enable the cache in the right way

Post by Cyprian »

Eero Tamminen wrote: Mon Sep 27, 2021 6:57 pm What kind of speed differences there are with different TrueColor resolutions, for example "40 cols, interlace off" and "80 cols, interlace on"?
there you can find some figures for different video modes:
Falcon and NemBench
I have also some additional Falcon's results for RGB.

Mikro wrote nice article about Videl's bus usage: https://mikro.naprvyraz.sk/docs/mikro/030_stram.html and that one https://mikro.naprvyraz.sk/docs/mikro/videl.html
Lynx I / Mega ST 1 / 7800 / Portfolio / Lynx II / Jaguar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
DDD HDD / AT Speed C16 / TF536 / SDrive / PAK68/3 / Lynx Multi Card / LDW Super 2000 / XCA12 / SkunkBoard / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.atari.org
Zamuel_a
Atari God
Atari God
Posts: 1285
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

Re: Want to make sure I enable the cache in the right way

Post by Zamuel_a »

I tried to run my program on a RGB monitor and gained 1 fps so it's still not close to Hatari (got 5 in RGB mode, 4 in VGA and 18 on Hatari)
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe
Rustynutt
Atari God
Atari God
Posts: 1846
Joined: Wed Mar 21, 2012 7:38 am
Location: Oregon

Re: Want to make sure I enable the cache in the right way

Post by Rustynutt »

Deleted.
An epiphany worked out :)
Post Reply

Return to “Professionals”