Supermodel icon indicating copy to clipboard operation
Supermodel copied to clipboard

Some CPU updates and small/harmless optimizations

Open toxieainc opened this issue 3 years ago • 12 comments

toxieainc avatar Jul 18 '22 20:07 toxieainc

This one might take me a while to get through. I'm in crunch mode on a different project right now but will try to look throughout the next week. The CPU changes require some close scrutiny. I'm surprised to see changes to some pretty basic instructions in the PowerPC core that I was certain were emulated correctly.

trzy avatar Jul 20 '22 18:07 trzy

PowerPC is basically untouched, i just tried to make the compilers life easier there (simple optimizations with no functional change). Only Z80 and M68K feature real changes, but most of them rather harmless. Only one M68K change i would think of as severe, as previously it touched out of bounds memory: https://github.com/trzy/Supermodel/pull/5/commits/52067d036c2395f9b94e01dd3049e29dcca07825#diff-45ce0215fdf46faf7104219b13eee8e51686bbe4985074d0deab29f23909085dL239

toxieainc avatar Jul 20 '22 20:07 toxieainc

The M68K and Z80 changes are also straight ports from MAME/MESS. I didn't want to pull each and everything over though, only the changes i considered rather harmless AND also making sure that i didn't throw something away that you guys touched independently from MAME in the meantime.

toxieainc avatar Jul 20 '22 21:07 toxieainc

I can't speak for Bart but commits with mostly cosmetic changes are quite annoying. Also adds to the chance of breaking something unintentionally. We either have to test and go through everything or just merge the changes and hope for the best.

dukeeeey avatar Jul 20 '22 21:07 dukeeeey

It depends on what you understand under cosmetic changes. The M68K and Z80 changes are real fixes ported over from MAME/MESS, not just reformatting or the like. Cause the latter i also think are just distractions.

I could omit the PowerPC changes though if you think these are unnecessary.

toxieainc avatar Jul 21 '22 05:07 toxieainc

I would like to keep the changes done to check_condition_code() though, as there i actually double checked with godbolt that better code falls out AND as that one is actually really performance critical (shows up in top spots during profiling via the opcodes/functions that need to use it). Functionality is 100% the same.

toxieainc avatar Jul 21 '22 05:07 toxieainc

I’ll take a look at it later this week/this weekend. Is this making an actual difference in frame rate? Not many systems struggle with Supermodel these days. I think some of the code in the CPU emulator is structured to reflect the logic descriptions in the PowerPC ISA manual so we don’t want to obscure that logic too much.

Sent from my iPhone

On Jul 20, 2022, at 10:52 PM, toxie @.***> wrote:

 I would like to keep the changes done to check_condition_code() though, as there i actually double checked with godbolt that better code falls out AND as that one is actually really performance critical (shows up in top spots during profiling via the opcodes/functions that need to use it). Functionality is 100% the same.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

trzy avatar Jul 21 '22 16:07 trzy

The PPC profiling for Daytona2 shows that the ppc_execute goes down by 3.5% (averaged over 3 runs of both variants (old and new)). So nothing earth shattering, but also not nothing. As said, basically only check_condition_code() should make a real difference here, and i don't think that readability or anything else is really affected by the change, IMHO rather the opposite (as one can/should rely that all results are always just 0 or 1).

toxieainc avatar Jul 21 '22 21:07 toxieainc

(oh, and ppc_execute is >50% of CPU on my machine when disabling throttling and vsync)

toxieainc avatar Jul 21 '22 21:07 toxieainc

I will take a look at this next week when I'm back home. I've been tied up with my startup this week and last.

trzy avatar Jul 30 '22 00:07 trzy

No hurry..

toxieainc avatar Jul 30 '22 12:07 toxieainc

This should now be good to go given your review. Thanks!!

toxieainc avatar Aug 08 '22 07:08 toxieainc

Thanks for removing the Z80 stuff. I think this looks good!

trzy avatar Aug 10 '22 03:08 trzy