Posts: 4
Threads: 0
Joined: Jun 2010
Reputation:
0
06-07-2010, 05:59 AM
(This post was last modified: 06-07-2010, 06:00 AM by her34.)
Thank you everyone for detailed response. Very insightful.
Seeing all that makes me curious about what theoretical speed an intel cpu would need to be at in order to emulate ps2 100% through interpreter.
Is it possible to calculate a quick rough estimate?
Posts: 195
Threads: 0
Joined: Feb 2009
Reputation:
5
Entirely depends on the code being run and the R5900 is by no means all there is to the PS2. It has coprocessors and custom chips which use more CPU time.
Posts: 4
Threads: 0
Joined: Jun 2010
Reputation:
0
Although many variables can affect, could a general ballpark be estimated?
If you calulate worst case scenario for each component (max cycles to interpret) multiplied to clock speed, and then sum up would that give ball park? or are there more things to consider?
for example:
ps2 cpu core @ 299mhz = 5 cycles to interpret --> 1495 intel cpu cycles
ps2 fpu @ 299mhz = 5 cycles to interpret --> 1495 intel cpu cycles
ps2 vu0 @ 150mhz = 5 cycles to interpret --> 750 intel cpu cycles
ps2 vu1 @ 150mhz = 5 cycles to interpret --> 750 intel cpu cycles
Graphics Synthesizer @ 147 MHz = ?
Total intel cpu cycles = ?
Posts: 195
Threads: 0
Joined: Feb 2009
Reputation:
5
The worst case is absolutely ridiculous, you don't even want to think about it. It's just depressing. Fortunately it has nothing to do with running real software.
Posts: 1.452
Threads: 64
Joined: Nov 2008
Reputation:
17
Location: Meshoppen, PA
(06-09-2010, 07:09 AM)her34 Wrote: If you calulate worst case scenario for each component (max cycles to interpret) multiplied to clock speed, and then sum up would that give ball park? or are there more things to consider?
for example:
ps2 cpu core @ 299mhz = 5 cycles to interpret --> 1495 intel cpu cycles
ps2 fpu @ 299mhz = 5 cycles to interpret --> 1495 intel cpu cycles
ps2 vu0 @ 150mhz = 5 cycles to interpret --> 750 intel cpu cycles
ps2 vu1 @ 150mhz = 5 cycles to interpret --> 750 intel cpu cycles
Typically an interpreter costs a lot more than 5 cycles per instruction. It costs about 40-60 cycles just to load and decode the MIPS instruction and dispatch it to the interpreter's instruction executor. Actual instruction execution usually takes 4-20 cycles -- 4 being the bare minimum.
Jake Stine (Air) - Programmer - PCSX2 Dev Team
Posts: 195
Threads: 0
Joined: Feb 2009
Reputation:
5
06-10-2010, 06:16 AM
(This post was last modified: 06-10-2010, 06:21 AM by pseudonym.)
Well decoding MIPS instructions is certainly tougher than SL3 or SL4, but 40-60 cycles to fetch and decode is a bit excessive I think. The fetch stage is slow because of vtlb, but that can be skipped for anything but PS2 linux. Our decode is also suboptimal... though if we're talking worst cases you have to use up to three tables before you have the actual instruction.
EDIT: Never mind, cached memory accesses are slower than I thought. 60 cycles is actually optimistic.
Posts: 4
Threads: 0
Joined: Oct 2011
Reputation:
0
The advantages of dynamic recompilation are:
more speed
more speed (nothing else really)
The disadvantages of dynamic recompilation are:
quite complicated
hard to debug
not as exact as interpretive emulation
not portable to systems with other processors
problems with self-modifying code
This means, as long as you can pull the whole emulation off at a decent speed by using traditional emulation (perferable even a portable solution), just do it and don't give dynamic recompilation a second thought.
Although I've seen people toying with dynarecs for 6502 and similar 8-bit processors it's not worth the hassle, since a nice CPU core written in C would be portable to different systems and should run at full speed on any current and even most older computers.
Even most 16-bit processors should be tried in interpretive emulation before thinking of dynamic recompilation. One of the few reasonable 16-bit candidates would be the 68000, because it is widely used and quite complex, so a dynarec for it might speed up a lot of emulators if you stick to the same API.
Where dynamic recompilation really shines is 32-bit and 64-bit processors, because it makes sense to do operations on hardware registers when the original code does so. Especially the MIPS (used in PSX and N64, eg.) and SuperH (Saturn eg.) processors with thei