Dynamic recompiler

Discussion of development and patch submission.
therock247uk
Posts: 29
Joined: Fri 25 Apr, 2014 2:55 pm

Re: Dynamic recompiler

Post by therock247uk »

Not sure if i did this right but i got pcem to crash when i used gdb pcem.exe then typing run in its console...

Code: Select all

therock247uk@dell-PC /c/users/therock247uk/desktop/PCem-fe2267275270/PCem-fe2267
275270/src
$ gdb pcem.exe
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from c:\users\therock247uk\desktop\PCem-fe2267275270\PCem-fe2267
275270\src\PCem.exe...done.
(gdb) run
Starting program: c:\users\therock247uk\desktop\PCem-fe2267275270\PCem-fe2267275
270\src/PCem.exe
[New Thread 5556.0x1454]
[New Thread 5556.0x1660]
[New Thread 5556.0x60c]
[New Thread 5556.0x11f8]
[New Thread 5556.0xcac]
[New Thread 5556.0x1270]
[New Thread 5556.0x132c]
[New Thread 5556.0x112c]
[New Thread 5556.0x14f0]
[New Thread 5556.0x1550]
[New Thread 5556.0x1248]
[New Thread 5556.0x113c]
[New Thread 5556.0xe80]
[New Thread 5556.0x1704]
[New Thread 5556.0xb74]
[New Thread 5556.0x13c8]
[New Thread 5556.0x17ec]
[New Thread 5556.0x1794]
[New Thread 5556.0xea8]
[New Thread 5556.0x10d4]
[New Thread 5556.0x1654]
[New Thread 5556.0x1408]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 5556.0x1408]
0x06a880e8 in ?? ()
(gdb)
therock247uk@dell-PC /c/users/therock247uk/desktop/PCem-fe2267275270/PCem-fe2267
275270/src
$
Alegend45
Posts: 85
Joined: Sat 26 Apr, 2014 4:33 am

Re: Dynamic recompiler

Post by Alegend45 »

Add -g to CFLAGS and take away -O3. Compile. Then in gdb, hit run, and when it gives SIGSEGV, hit bt.
therock247uk
Posts: 29
Joined: Fri 25 Apr, 2014 2:55 pm

Re: Dynamic recompiler

Post by therock247uk »

therock247uk@dell-PC /c/users/therock247uk/desktop/1PCem-fe2267275270/PCem-fe226
7275270/src
$ gdb pcem.exe
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from c:\users\therock247uk\desktop\1PCem-fe2267275270\PCem-fe226
7275270\src\PCem.exe...done.
(gdb) run
Starting program: c:\users\therock247uk\desktop\1PCem-fe2267275270\PCem-fe226727
5270\src/PCem.exe
[New Thread 4916.0x1794]
[New Thread 4916.0x1650]
[New Thread 4916.0x1430]
[New Thread 4916.0x10a4]
[New Thread 4916.0x1754]
[New Thread 4916.0x17d8]
[New Thread 4916.0xc28]
[New Thread 4916.0x1694]
[New Thread 4916.0x14dc]
[New Thread 4916.0x1444]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 4916.0x1444]
0x0612c138 in ?? ()
(gdb) bt
#0 0x0612c138 in ?? ()
#1 0x7564f645 in msvcrt!_beginthread () from C:\Windows\syswow64\msvcrt.dll
#2 0x7564f624 in msvcrt!_beginthread () from C:\Windows\syswow64\msvcrt.dll
#3 0x756e338a in KERNEL32!BaseThreadInitThunk ()
from C:\Windows\syswow64\kernel32.dll
#4 0x77bb9f72 in ntdll!RtlInitializeExceptionChain ()
from C:\Windows\system32\ntdll.dll
#5 0x77bb9f45 in ntdll!RtlInitializeExceptionChain ()
from C:\Windows\system32\ntdll.dll
#6 0x00000000 in ?? ()
(gdb)
User avatar
ppgrainbow
Posts: 479
Joined: Thu 04 Sep, 2014 7:03 am
Contact:

Re: Dynamic recompiler

Post by ppgrainbow »

I have one question though. Why doesn't the dynamic re-compiler work at all on pre-80486 and compatible CPUs? SA1988 tested the IBM AT BIOS with the dynamic re-compiler recently and it wouldn't even work.

As far as I recall, I tested the dynamic re-compiled version of PCem v9 r176 the other day using a AMI 486 BIOS running at 33 MHz and the dynamic recompiled emulator wouldn't even boot correctly. When the clock speed is set to 25 MHz, a long beep sound is heard when starting up the boot process.

Is this issue due to the design of the dynamic re-compiler itself or are there bugs that need to be ironed out?
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Dynamic recompiler

Post by SarahWalker »

There are quite possibly issues with 286/386 and the recompiler. PCem uses internal cache enable to determine whether to recompile; as 286 and 386 have no internal cache this is a bit pointless. Given this, and that speed with these CPUs is less of an issue than with 486 and later, I don't see the point in investing the time in getting them working.

As for your example, you say 'a AMI 486 BIOS'. Is this implying that this is a random BIOS you found somewhere, rather than one that is actually supported?
User avatar
ppgrainbow
Posts: 479
Joined: Thu 04 Sep, 2014 7:03 am
Contact:

Re: Dynamic recompiler

Post by ppgrainbow »

Thank you very much for telling me. The AMI 486 BIOS is implying to the ROM that is officially supported by PCem.

SA1988 is wondering if there was a switch option will be implemented in the PCem settings to switch from dynamic to interpreter mode for (pre-80486 CPUs), vice-versa or not.
truth

Re: Dynamic recompiler

Post by truth »

ppgrainbow wrote:SA1988 is wondering if there was a switch option will be implemented in the PCem settings to switch from dynamic to interpreter mode for (pre-80486 CPUs), vice-versa or not.
Tom already answered that question. If the dynamic core isn't necessary and made compatible with pre-486, then a switch isn't needed for that case.
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: Dynamic recompiler

Post by leilei »

I did try AM486 again with the dynarec and got Windows 95 to install and boot fine. However after installing a few things (dunno what causes this yet, haven't carefully reproduced) I eventually hit a "invalid configuration, you need to run Windows Setup" BSOD which causes PCem to quit if I continue from there

On the other hand, it's very nice to see 100% AM486 120Mhz speed :)


EDIT: Installing After Dark 3.2 and letting it insert ADWRAP.DRV in SYSTEM.INI causes this. It does not occur in the interpreter.

EDIT2: This also occurs with Pentium emulation on Windows98SE after installing After Dark 3.2
User avatar
ppgrainbow
Posts: 479
Joined: Thu 04 Sep, 2014 7:03 am
Contact:

Re: Dynamic recompiler

Post by ppgrainbow »

truth wrote:
ppgrainbow wrote:SA1988 is wondering if there was a switch option will be implemented in the PCem settings to switch from dynamic to interpreter mode for (pre-80486 CPUs), vice-versa or not.
Tom already answered that question. If the dynamic core isn't necessary and made compatible with pre-486, then a switch isn't needed for that case.
Thanks again.
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: Dynamic recompiler

Post by leilei »

BTW how cycle accurate is the Pentium emulation? P100 w/ S3 Trio64v+ seems kind of fast, getting 30fps in Quake timerefresh start when I think I should be getting 21fps there
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Dynamic recompiler

Post by SarahWalker »

It's a bit quick, I estimated about 10-20%. A reasonable chunk of this is probably due to memory being unrealistically fast, and things like AGI stalls and FPU latency are not emulated.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Dynamic recompiler

Post by SarahWalker »

Performance update, as of rev 187 :

Code: Select all

Normal build : 

DOS prompt        -  27% faster (52% / 66%)
Doom              - 114% faster (35% / 75%)
Duke 3D           -  72% faster (32% / 55%)
Quake             - 113% faster (45% / 96%)
Transport Tycoon  -  75% faster (56% / 98%)
Tyrian            - 109% faster (43% / 90%)
Terminal Velocity - 128% faster (39% / 89%)
Worms             -  98% faster (45% / 89%)
Blake Stone       -  98% faster (47% / 93%)
Win 95 desktop    -   6% slower (34% / 32%)
Jazz 2            - 107% faster (43% / 89%)
GLQuake           -  52% faster (44% / 67%)
Croc (SW)         - 143% faster (30% / 73%)
Croc (Virge)      -  49% faster (43% / 64%)
Quake II          - 129% faster (38% / 87%)
GTA               - 106% faster (36% / 74%)
Compared to interpreter average gain of 88%. Compared to rev 173 average gain of 22%.
truth

Re: Dynamic recompiler

Post by truth »

Thanks for the update! I look forward to trying this out.
nerd73
Posts: 116
Joined: Wed 24 Sep, 2014 11:16 pm

Re: Dynamic recompiler

Post by nerd73 »

Got improvements:

Max speed in no skipping test:

Interpreter: 75 MHz 486
Rev 173-186 recompiler: 80 MHz 486
Rev 187 recompiler: 100 MHz 486

Nonetheless the Pentium Overdrive/83 is quite consistent.
startmenu
Posts: 104
Joined: Sat 29 Nov, 2014 7:39 am

Re: Dynamic recompiler

Post by startmenu »

The dynamic recompiler enabled build does not run Windows 95. "IFSMGR" was mentioned on the BSoD screen.
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: Dynamic recompiler

Post by SA1988 »

startmenu wrote:The dynamic recompiler enabled build does not run Windows 95. "IFSMGR" was mentioned on the BSoD screen.
same here :|
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: Dynamic recompiler

Post by leilei »

Not for me, I can get to Win95 and Win98 just fine without any IFSMGR bluescreen on Intel Advanced/EV and AMI Winbios 486 with the DYNAREC enabled. Did you build it?

I should mention it's nice not seeing the Win95 logo stalling for seconds and having the full speed of a Pentium 90 :)
startmenu
Posts: 104
Joined: Sat 29 Nov, 2014 7:39 am

Re: Dynamic recompiler

Post by startmenu »

leilei wrote:Not for me, I can get to Win95 and Win98 just fine without any IFSMGR bluescreen on Intel Advanced/EV and AMI Winbios 486 with the DYNAREC enabled. Did you build it?

I should mention it's nice not seeing the Win95 logo stalling for seconds and having the full speed of a Pentium 90 :)
I have built Rev173 to 187 with CFLAGS "-O3 -march=i686 -fomit-frame-pointer -DDYNAREC -fprofile-use" using GCC 4.8.1 on MinGW.
BIOS: Award SiS 496/497 and Award 430VX PCI
I havn't tested any other BIOS yet...
Sometimes it's just fine, but...
nerd73
Posts: 116
Joined: Wed 24 Sep, 2014 11:16 pm

Re: Dynamic recompiler

Post by nerd73 »

startmenu wrote:
leilei wrote:Not for me, I can get to Win95 and Win98 just fine without any IFSMGR bluescreen on Intel Advanced/EV and AMI Winbios 486 with the DYNAREC enabled. Did you build it?

I should mention it's nice not seeing the Win95 logo stalling for seconds and having the full speed of a Pentium 90 :)
I have built Rev173 to 187 with CFLAGS "-O3 -march=i686 -fomit-frame-pointer -DDYNAREC -fprofile-use" using GCC 4.8.1 on MinGW.
BIOS: Award SiS 496/497 and Award 430VX PCI
I havn't tested any other BIOS yet...
Sometimes it's just fine, but...
Can't test right now, but on rev 186 Win95 worked just fine.
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: Dynamic recompiler

Post by leilei »

I don't use -fprofile-use. I only add -DDYNAREC when I build. rev 187. Award 430VX PCI doesn't crash for me either.

CFLAGS = -O3 -march=i686 -fomit-frame-pointer -DDYNAREC
startmenu
Posts: 104
Joined: Sat 29 Nov, 2014 7:39 am

Re: Dynamic recompiler

Post by startmenu »

leilei wrote:I don't use -fprofile-use. I only add -DDYNAREC when I build. rev 187
I tried to build one without -fprofile-use, it's still BSoD... However to build without both -DDYNAREC and -fprofile-use makes Windows 9x work.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Dynamic recompiler

Post by SarahWalker »

Can you provide all details of the configuration you're trying to use please?

I'd suggest trying an earlier version of GCC btw, my understanding is that 4.8.x is a bit crap.
startmenu
Posts: 104
Joined: Sat 29 Nov, 2014 7:39 am

Re: Dynamic recompiler

Post by startmenu »

Here's my config on PCem rev187

Code: Select all

gameblaster = 0
gus = 0
ssi2001 = 0
model = 25
cpu_manufacturer = 0
cpu = 4
gfxcard = 19
video_speed = 5
sndcard = 8
cpu_speed = 12
has_fpu = 1
slow_video = 1
cache = 2
cga_composite = 0
disc_a = 
disc_b = 
mem_size = 32
cdrom_drive = 73
cdrom_enabled = 1
vid_resize = 0
vid_api = 0
video_fullscreen_scale = 0
video_fullscreen_first = 1
hdc_sectors = 63
hdc_heads = 16
hdc_cylinders = 4161
hdc_fn = c.img
hdd_sectors = 0
hdd_heads = 0
hdd_cylinders = 0
hdd_fn = 
Dynamic recompiler enabled and PGO build.
truth

Re: Dynamic recompiler

Post by truth »

Perhaps post your pcem binary so it can be examined. Also, does your pcem binary work with DOS? Did you verify the Win95 installation?

Please read this thread, too: viewtopic.php?f=2&t=98.
startmenu
Posts: 104
Joined: Sat 29 Nov, 2014 7:39 am

Re: Dynamic recompiler

Post by startmenu »

truth wrote:Perhaps post your pcem binary so it can be examined. Also, does your pcem binary work with DOS? Did you verify the Win95 installation?

Please read this thread, too: viewtopic.php?f=2&t=98.
Yes, DOS works. I installed DOS 6.22 first and then run win95 installer on it. The installation on DOS stage(before the first restart) was successful. But it turned out BSoD after Win95 startup logo.
My binary - built with CFLAGS "-O3 -march=i686 -fomit-frame-pointer -DDYNAREC -fprofile-use" on Windows 7 x64, GCC 4.8.1, mingw32
http://kikyoulinux.info/misc/PCem_Rev187.zip
truth

Re: Dynamic recompiler

Post by truth »

Please test and post a binary with CFLAGS = -O2 -DDYNAREC. Don't add other cflags.
truth

Re: Dynamic recompiler

Post by truth »

I tested your PCem binary and it works with my Win95 image. Therefore, your cflags settings are likely not the cause of the issue, but instead you should verify use of Cache = "A lot" and try disabling the virtual cdrom drive. Otherwise, try reinstalling 95 onto the virtual disk image (may also try a disk image size similar to the one in the window below).

It may be best to attempt reinstallation, if necessary, by way of copying the files on cdrom to a hard drive image; and not by installing directly from cdrom.

Here are my settings which are similar to yours:

Code: Select all

gameblaster = 0
gus = 0
ssi2001 = 0
model = 25
cpu_manufacturer = 0
cpu = 3
gfxcard = 17
video_speed = 5
sndcard = 7
cpu_speed = 11
has_fpu = 1
slow_video = 1
cache = 3
cga_composite = 0
disc_a = 
disc_b = 
mem_size = 64
cdrom_drive = 0
cdrom_enabled = 0
vid_resize = 0
vid_api = 0
video_fullscreen_scale = 0
video_fullscreen_first = 1
hdc_sectors = 63
hdc_heads = 16
hdc_cylinders = 4092
hdc_fn = C:\PCem\Disk.img
hdd_sectors = 0
hdd_heads = 0
hdd_cylinders = 0
hdd_fn = 
startmenu
Posts: 104
Joined: Sat 29 Nov, 2014 7:39 am

Re: Dynamic recompiler

Post by startmenu »

truth wrote:I tested your PCem binary and it works with my Win95 image. Therefore, your cflags settings are likely not the cause of the issue, but instead you should verify use of Cache = "A lot" and try disabling the virtual cdrom drive. Otherwise, try reinstalling 95 onto the virtual disk image (may also try a disk image size similar to the one in the window below).

It may be best to attempt reinstallation, if necessary, by way of copying the files on cdrom to a hard drive image; and not by installing directly from cdrom.

Here are my settings which are similar to yours:

Code: Select all

gameblaster = 0
gus = 0
ssi2001 = 0
model = 25
cpu_manufacturer = 0
cpu = 3
gfxcard = 17
video_speed = 5
sndcard = 7
cpu_speed = 11
has_fpu = 1
slow_video = 1
cache = 3
cga_composite = 0
disc_a = 
disc_b = 
mem_size = 64
cdrom_drive = 0
cdrom_enabled = 0
vid_resize = 0
vid_api = 0
video_fullscreen_scale = 0
video_fullscreen_first = 1
hdc_sectors = 63
hdc_heads = 16
hdc_cylinders = 4092
hdc_fn = C:\PCem\Disk.img
hdd_sectors = 0
hdd_heads = 0
hdd_cylinders = 0
hdd_fn = 
I tried to install Windows Me on VirtualPC. After the first restart, I turned off VPC immediately and mounted the VHD to drag all the stuff on drive C to c.img which was used as PCem's hard drive. And then I executed sys C: on PCem. Wineows Me started but turned BSoD when detecting hardware.
truth

Re: Dynamic recompiler

Post by truth »

I would first try 95 before testing other operating systems, especially since your pcem binary is functioning with my 95 image. Disabling the virtual cdrom drive and testing installation is one possible test to start with; also exclude networking components during 95 installation.

It also would help if you report the exact error during installation of 95 or show a screen image of the error.
startmenu
Posts: 104
Joined: Sat 29 Nov, 2014 7:39 am

Re: Dynamic recompiler

Post by startmenu »

Finally Windows 95 works after being reinstalled. I'll try Win98 later.
config:
430VX, Pentium 75 with a bit of cache, Sound Blaster AWE32
http://kikyoulinux.info/misc/itworks.png
Post Reply