Multi-Core support with Hatari?

A forum about the Hatari ST/STE/Falcon emulator - the current version is v2.1.0

Moderators: simonsunnyboy, thothy, Moderator Team

finisterre
Atarian
Atarian
Posts: 1
Joined: Tue Apr 10, 2018 1:50 pm

Multi-Core support with Hatari?

Postby finisterre » Tue Apr 10, 2018 2:03 pm

Hi there,

Well done to the author(s) of Hatari! I have been thoroughly enjoying the Falcon emulation abilities, and been trying some demos to showcase it's abilities. This is where I have found an issue.
When trying to run the "Black Lotus Rift Demo (TBL RIFT)" - a high-end Falcon demo needing 060 CPU, and loads of TT-RAM (I used 64MB) - I have got it to work, however, it is slow and choppy. Looking at my i7-2600's utilisation, I notice it is hitting 18-20%, but this is because it is maxing out just one core of the 8 available.

I appreciate it may be difficult to implement due to affecting timing of audio etc. to do multi-threaded code, but are there any plans to take advantage of this?

Finally, are there plans to have a config manager for Hatari, so it can be possible to set up different configs for STFM, STe, Falcon030 etc. without manually configuring TOS IMG, CPU, RAM, HDD Images etc. each time?

Sorry for questions as soon as joining, but have been battling with this for a few months, and finally getting somewhere with disk images, XbootIII etc. :-)

:cheers:

Darren

ThorstenOtto
Captain Atari
Captain Atari
Posts: 284
Joined: Sun Aug 03, 2014 5:54 pm

Re: Multi-Core support with Hatari?

Postby ThorstenOtto » Tue Apr 10, 2018 2:43 pm

This has been discussed already. It does not make much sense, not only because it is complicated to get the synchronization right, but mainly because hatari tries hard to do cycle exact emulation of both the cpu, video system, dsp etc., and the subprocesses (or threads) would most of the time just wait on another.

are there plans to have a config manager for Hatari


You can have something like that already by just saving the configuration under a different name.

ijor
Hardware Guru
Hardware Guru
Posts: 3305
Joined: Sat May 29, 2004 7:52 pm
Contact:

Re: Multi-Core support with Hatari?

Postby ijor » Tue Apr 10, 2018 4:43 pm

ThorstenOtto wrote:This has been discussed already. It does not make much sense, not only because it is complicated to get the synchronization right, but mainly because hatari tries hard to do cycle exact emulation of both the cpu, video system, dsp etc., and the subprocesses (or threads) would most of the time just wait on another.


I'm not sure I agree with that 100%. Cycle accuracy doesn't always requires synchronization on every cycle. Yes, if you would try to emulate, say, the CPU, GLUE and MMU, each one in its own thread, that woulnd't be very efficient. But I see no reason why you couldn't, for example, put the sound subsystem on a separate thread.

I don't know about the Falcon, but the ST sound subsystem doesn't provide any feedback. Communication is one way only (for the sound processing). This means that the main system doesn't ever need to wait for the sound processor. You can build a circular buffer, store all "writes" in the buffer saving also the timing of each write, and the sound thread could collect and process the data separately without any synchronization. The bulk of the video subsystem is also a good candidate.

I believe the concept is already used in other emulators (not specifically ST emulators). It is a good question if it is worth the complication, especially how this would affect the portability. But it certainly does make sense.

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Multi-Core support with Hatari?

Postby Foxie » Tue Apr 10, 2018 5:19 pm

ThorstenOtto wrote:You can have something like that already by just saving the configuration under a different name.


I do wish for a config selector too, something like how FS-UAE does it. It could just be a simple third party launching program. I find the SDL interface very unresponsive to clicks under OS X, to the point where the file selector is usually unusable. It's also a bit clunky going through several menu levels to select a config.

For years I've been using a simple shell script to start Hatari in various preset configurations. It works on OS X and Linux, you need to adjust the paths:

Code: Select all

#!/bin/bash

# For lower sensitivity when mouse is grabbed / fullscreen
export SDL_MOUSE_RELATIVE=0

if (( $# < 1 ))
then

echo "Usage: ./launch_hatari.sh mode [[custom_tos*]] [floppy_disk_image_or_extra_hatari_options]"
echo "Available modes:"
echo "custom          1040ST colour,         Custom *"
echo "custom_mono     1040ST mono,           Custom *"
echo "st              1040ST colour,         TOS 1.04"
echo "st_mono         1040ST mono,           TOS 1.04"
echo "st_mint         4096ST mono,           TOS 1.04 + MINT"
echo "st_old          520ST colour,          TOS 1.00"
echo "ste             4MB STE colour,        TOS 1.62"
echo "ste_mono        4MB STE mono,          TOS 1.62"
echo "ste_mono        4MB STE mono,          TOS 1.62 + MINT"
echo "ste_ntsc        4MB STE colour NTSC    TOS 2.06"
echo "mste            4MB MegaSTE colour     TOS 2.06"
echo "mste_mono       4MB MegaSTE mono,      TOS 2.06"
echo "mste_mono       4MB MegaSTE mono,      TOS 2.06 + MINT"
echo "mste_vdi        4MB MegaSTE+VDI card,  TOS 2.06"
echo "mste_vdi_mono   4MB MegaSTE+mono card, TOS 2.06"
echo "tt **           4+16MB TT VGA,         TOS 3/2.06"
echo "tt_mono **      4+16MB TT mono,        TOS 3/2.06"
echo "falcon_vga      14MB falcon VGA,       TOS 4.04"
echo "falcon_rgb      14MB falcon RGB,       TOS 4.04"
echo "falcon_492_vga  14MB falcon VGA,       TOS 4.92"
echo "falcon_492_rgb  14MB falcon RGB,       TOS 4.92"
echo "*   Specify custom TOS image as the argument following"
echo "    custom, optional floppy image comes afterwards."
echo "**  Because TOS 3.x won't boot due to unknown"
echo "    reasons, this is fudged by setting the ROM"
echo "    to TOS 3.x and booting from a TOS 2.06 disk."
echo "    It seems to provide full TT facilities."

exit 1
fi


# Paths can't contain spaces

if (( $# == 2 ))
then
tempdiskimage="$2"
else
tempdiskimage="/Users/user/Data/Retro_computing/ST/new_disk.st"
fi

if (( $# == 3 ))
then
tempdiskimagealt="$3"
else
tempdiskimagealt="/Users/user/Data/Retro_computing/ST/new_disk.st"
fi

temphdddir="/Users/user/Data/Retro_computing/ST/st"
tempacsi="/Users/user/Data/Retro_computing/ST/st_mint-0.7.img"

# No trailing slash in path:
temptosbase="/Users/user/Data/Retro_computing/ST/TOS_images"


if [ "$1" == "ste" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos162uk.img" --machine ste --memsize 4 --blitter 1  --compatible 1 --cpu-exact 1 --timer-d 0 --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "ste_mono" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos162uk.img" --machine ste --memsize 4 --blitter 1  --compatible 1 --cpu-exact 1 --timer-d 0 --monitor mono --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "ste_ntsc" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos206us.img" --machine ste --memsize 4 --blitter 1  --compatible 1 --cpu-exact 1 --timer-d 0 --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "ste_mint" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos162uk.img" --machine ste --memsize 4 --blitter 1  --compatible 1 --cpu-exact 1 --timer-d 0 --monitor mono --harddrive "$temphdddir" --gemdos-drive D --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "mste" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos206uk.img" --machine megaste --cpuclock 16 --memsize 4 --blitter 1  --compatible 1 --cpu-exact 1 --timer-d 0 --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "mste_mono" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos206uk.img" --machine megaste --cpuclock 16 --memsize 4 --blitter 1  --compatible 1 --cpu-exact 1 --timer-d 0 --monitor mono --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "mste_mint" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos206uk.img" --machine megaste --cpuclock 16 --memsize 4 --blitter 1  --compatible 1 --cpu-exact 1 --timer-d 0 --monitor mono --harddrive "$temphdddir" --gemdos-drive D --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "mste_vdi" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos206uk.img" --machine megaste --cpuclock 16 --memsize 4 --blitter 1  --compatible 1 --cpu-exact 1 --timer-d 0 --vdi 1 --vdi-planes 4 --vdi-width 1024 --vdi-height 752 --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "mste_vdi_mono" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos206uk.img" --machine megaste --cpuclock 16 --memsize 4 --blitter 1  --compatible 1 --cpu-exact 1 --timer-d 0 --monitor mono --vdi 1 --vdi-planes 1 --vdi-width 1024 --vdi-height 752 --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "st" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos104uk.img" --machine st --memsize 1 --compatible 1 --cpu-exact 1 --timer-d 0 --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "st_mono" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos104uk.img" --machine st --memsize 1 --compatible 1 --cpu-exact 1 --timer-d 0 --monitor mono --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "st_mint" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos104uk.img" --machine st --memsize 4 --compatible 1 --cpu-exact 1 --timer-d 0 --monitor mono --harddrive "$temphdddir" --gemdos-drive D --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "st_old" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos100uk.img" --machine st --memsize 0 --compatible 1 --cpu-exact 1 --timer-d 0 --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimage"

elif [ "$1" == "falcon_vga" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos404.img" --machine falcon --memsize 14 --compatible 0 --cpu-exact 0 --mmu 1 --dsp emu --blitter 1 --timer-d 0 --monitor vga --max-width 768 --max-height 512 --harddrive "$temphdddir" "$tempdiskimage"

elif [ "$1" == "falcon_rgb" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos404.img" --machine falcon --memsize 14 --compatible 0 --cpu-exact 0 --mmu 1 --dsp emu --blitter 1 --timer-d 0 --monitor rgb --max-width 768 --max-height 512 --harddrive "$temphdddir" "$tempdiskimage"

elif [ "$1" == "falcon_492_vga" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos492.img" --machine falcon --memsize 14 --compatible 0 --cpu-exact 0 --mmu 1 --dsp emu --blitter 1 --timer-d 0 --monitor vga --max-width 768 --max-height 512 --harddrive "$temphdddir" "$tempdiskimage"

elif [ "$1" == "falcon_492_rgb" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos492.img" --machine falcon --memsize 14 --compatible 0 --cpu-exact 0 --mmu 1 --dsp emu --blitter 1 --timer-d 0 --monitor rgb --max-width 768 --max-height 512 --harddrive "$temphdddir" "$tempdiskimage"

elif [ "$1" == "tt" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos36uk.img" --machine tt --cpuclock 32 --cpulevel 3 --memsize 4 --ttram 16 --addr24 0 --blitter 0  --compatible 0 --mmu 1 --cpu-exact 0 --fpu 68882 --timer-d 0 --monitor vga --max-width 648 --max-height 480 --harddrive "$temphdddir" --protect-floppy on --fastfdc 1 /Users/user/Data/Retro_computing/ST/TOS_images/Disk\ images/tos3st.st

elif [ "$1" == "tt_mono" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$temptosbase/tos36uk.img" --machine tt --cpuclock 32 --cpulevel 3 --memsize 4 --ttram 16 --addr24 0 --blitter 0  --compatible 0 --mmu 1 --cpu-exact 0 --fpu 68882 --timer-d 0 --monitor mono --harddrive "$temphdddir" --protect-floppy on --fastfdc 1 /Users/user/Data/Retro_computing/ST/TOS_images/Disk\ images/tos3st.st




elif [ "$1" == "custom" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$2" --machine st --memsize 1 --compatible 1 --cpu-exact 1 --timer-d 0 --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimagealt"

elif [ "$1" == "custom_mono" ]; then

/Applications/Hatari.app/Contents/MacOS/hatari --tos "$2" --machine st --memsize 1 --compatible 1 --cpu-exact 1 --timer-d 0 --monitor mono --harddrive "$temphdddir" --acsi 0="$tempacsi" "$tempdiskimagealt"


else

echo "Usage: ./launch_hatari.sh mode [[custom_tos*]] [floppy_disk_image_or_extra_hatari_options]"
echo "Available modes:"
echo "custom          1040ST colour,         Custom *"
echo "custom_mono     1040ST mono,           Custom *"
echo "st              1040ST colour,         TOS 1.04"
echo "st_mono         1040ST mono,           TOS 1.04"
echo "st_mint         4096ST mono,           TOS 1.04 + MINT"
echo "st_old          520ST colour,          TOS 1.00"
echo "ste             4MB STE colour,        TOS 1.62"
echo "ste_mono        4MB STE mono,          TOS 1.62"
echo "ste_mono        4MB STE mono,          TOS 1.62 + MINT"
echo "ste_ntsc        4MB STE colour NTSC    TOS 2.06"
echo "mste            4MB MegaSTE colour     TOS 2.06"
echo "mste_mono       4MB MegaSTE mono,      TOS 2.06"
echo "mste_mono       4MB MegaSTE mono,      TOS 2.06 + MINT"
echo "mste_vdi        4MB MegaSTE+VDI card,  TOS 2.06"
echo "mste_vdi_mono   4MB MegaSTE+mono card, TOS 2.06"
echo "tt **           4+16MB TT VGA,         TOS 3/2.06"
echo "tt_mono **      4+16MB TT mono,        TOS 3/2.06"
echo "falcon_vga      14MB falcon VGA,       TOS 4.04"
echo "falcon_rgb      14MB falcon RGB,       TOS 4.04"
echo "falcon_492_vga  14MB falcon VGA,       TOS 4.92"
echo "falcon_492_rgb  14MB falcon RGB,       TOS 4.92"
echo "*   Specify custom TOS image as the argument following"
echo "    custom, optional floppy image comes afterwards."
echo "**  Because TOS 3.x won't boot due to unknown"
echo "    reasons, this is fudged by setting the ROM"
echo "    to TOS 3.x and booting from a TOS 2.06 disk."
echo "    It seems to provide full TT facilities."

fi

User avatar
npomarede
Atari God
Atari God
Posts: 1237
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Multi-Core support with Hatari?

Postby npomarede » Tue Apr 10, 2018 8:37 pm

ijor wrote:
ThorstenOtto wrote:This has been discussed already. It does not make much sense, not only because it is complicated to get the synchronization right, but mainly because hatari tries hard to do cycle exact emulation of both the cpu, video system, dsp etc., and the subprocesses (or threads) would most of the time just wait on another.


I'm not sure I agree with that 100%. Cycle accuracy doesn't always requires synchronization on every cycle. Yes, if you would try to emulate, say, the CPU, GLUE and MMU, each one in its own thread, that woulnd't be very efficient. But I see no reason why you couldn't, for example, put the sound subsystem on a separate thread.
...
I believe the concept is already used in other emulators (not specifically ST emulators). It is a good question if it is worth the complication, especially how this would affect the portability. But it certainly does make sense.

Hi
yes, that's what I explained in the hatari mailing list (this question comes regularly). It would be a real waste of cpu ressource to have 2 threads, 1 for cpu and 1 for dsp for example, and to have both threads send/receive data as cpu/dsp would do on a Falcon. Accurate emulation (such as it would be required to run the demo '030' for example) would really need a context switch between each threads after each emulated cpu or dsp instruction. Even the most recent intel/amd cpu would not be fast enough, and even so, I don't think there's any mainstream OS scheduler under Windows/MacOS/Linux that would allow millions of contexts switch per second.

So, CPU/DSP/MMU and all others "2 ways" components should be emulated in the same thread/cpu core.
But as you say, additional core could be used for YM sound (which would not save that much cpu, as it really takes a very small percentage of the emulation), or to do avi recording without slowing down main emulation, or to apply more advanced video filters, and so on.

To emulate "complex" system such as Falcon or TT (and it's the same with Amiga emulation), a cpu with the most power per core is really needed.

Nicolas

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1684
Joined: Sun Jul 31, 2011 1:11 pm

Re: Multi-Core support with Hatari?

Postby Eero Tamminen » Tue Apr 10, 2018 9:10 pm

Ijor, sound processing is already done in another thread/process, by SDL + pulseaudio (on Linux). It can actually take a noticeable amount of CPU.

Foxie, on Linux, something like zenity is quite nice for making GUI launchers for emulators: https://en.wikipedia.org/wiki/Zenity

I've attached couple of old examples of using Zenity & Dialog.

EDIT: fix typo
You do not have the required permissions to view the files attached to this post.
Last edited by Eero Tamminen on Tue Apr 10, 2018 11:25 pm, edited 1 time in total.

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 678
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Multi-Core support with Hatari?

Postby dhedberg » Tue Apr 10, 2018 9:27 pm

Eero Tamminen wrote:Foxie, on Linux, something like zenity is quite nice for making GUI launchers for emulators: https://en.wikipedia.org/wiki/Zenity

Looks like it's available for Windows and possibly macOS (yes, seems like Apple renamed it again?) as well:
Wikipedia: As of 2012, Zenity is available for Linux, BSD and Windows.[4] A Zenity port to Mac OS X is available in MacPorts and Homebrew.
Daniel, New Beat - http://newbeat.atari.org

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Multi-Core support with Hatari?

Postby Foxie » Tue Apr 10, 2018 10:43 pm

Eero Tamminen wrote:Foxie, on Linux, something like zenity is quite nice for making GUI launchers for emulators: https://en.wikipedia.org/wiki/Zenity

I've attached couple of old examples of using Zenity & Dialog.


Thanks! This should make it much easier to use.

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Multi-Core support with Hatari?

Postby Foxie » Sun Apr 15, 2018 6:05 pm

Foxie wrote:
Eero Tamminen wrote:Foxie, on Linux, something like zenity is quite nice for making GUI launchers for emulators: https://en.wikipedia.org/wiki/Zenity

I've attached couple of old examples of using Zenity & Dialog.


Thanks! This should make it much easier to use.


Here's the script I'm using now if anyone wants something similar:

Code: Select all

#!/bin/bash

stdir="/Users/user/Data/Retro_computing/ST"
hatariexe="/Applications/Hatari.app/Contents/MacOS/hatari"
zenityexe="/usr/local/Cellar/zenity/3.28.1/bin/zenity"

cd "$stdir"

config1name="MegaSTE Colour TOS 2.06"
config2name="MegaSTE Mono TOS 2.06"
config3name="MegaSTE VDI TOS 2.06"
config4name="MegaSTE Mono TOS 2.06 + MINT"

config5name="4160STE Colour TOS 1.62"
config6name="4160STE Mono TOS 1.62"
config7name="4160STE Colour + EmuTOS"
config8name="4160STE Mono + EmuTOS"
config9name="4160STE Colour TOS 2.06 NTSC"

config10name="1040ST Colour TOS 1.04"
config11name="1040ST Mono TOS 1.04"
config12name="1040ST Colour TOS 1.00"
config13name="1040ST Mono TOS 1.00"

config14name="TT VGA"
config15name="TT Mono"
config16name="TT040 Mono"
config17name="TT040 Mono + EmuTOS"

config18name="Falcon RGB"
config19name="Falcon VGA"
config20name="Falcon040 VGA"
config21name="Falcon040 VGA TOS 4.92"
config22name="Falcon040 VGA + EmuTOS"


result=$("$zenityexe" --height=500 --width=640 --title="Launch Hatari" --text="Machine" --list --column "Configuration" "$config1name" "$config2name" "$config3name" "$config4name" "$config5name" "$config6name" "$config7name" "$config8name" "$config9name" "$config10name" "$config11name" "$config12name" "$config13name" "$config14name" "$config15name" "$config16name" "$config17name" "$config18name" "$config19name" "$config20name" "$config21name" "$config22name")

"$hatariexe" --configfile "Hatari_configs/$result" &


Rather than using command line options, I saved each configuration as a Hatari config file in the Hatari_configs folder. The files need to have the same names as the menu titles.

On OS X, Zenity can be installed by installing homebrew and typing brew install zenity. The script can be turned into an OS X application by using Automator. Select new application and select run shell script.

Unfortunately Zenity has an annoying bug. The window doesn't pop up in the foreground. I tried the --modal option but it didn't work. Those are the same problems that plagued me on Linux for years. I'm disappointed it was brought across to OS X on the port.

There's a better looking alternative to Zenity for OS X called CocoaDialog. Unfortunately they've removed the download for version 2 until they release version 3 later this year.

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1684
Joined: Sun Jul 31, 2011 1:11 pm

Re: Multi-Core support with Hatari?

Postby Eero Tamminen » Sun Apr 15, 2018 9:59 pm

Another possibility would be to write it in Python. Hconsole & Python-UI (included with Hatari sources) have code for running and interacting with Hatari.

(Python-UI is unfortunately stuck with Gtk v2, as pygtk never made change to newer Gtk versions. With them one would need to use gobject bindings directly, instead of pygtk which would be a large rewrite for python-UI...)


Social Media

     

Return to “Hatari”

Who is online

Users browsing this forum: No registered users and 1 guest