Live data from Hacker News

Exercises in Emulation: Xbox 360’s FMA Instruction

randomascii.wordpress.com

21–30 of 50 posts

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#21

Earlier quoted context omitted.

Verifying the things you put on your mortgage application are true, like employment details.

I’ve never had that happen - they just looked at my bank account. I wouldn’t want a mortgage provider talking to my employer.

As an employer, I have had mortgage brokers call our HR lead quite often to verify loan applications.

For those who are concerned about privacy: I have found that those loan providers are then selling that data to websites that offer aggregated salary data.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#22
post #3

> I left the Xbox team long before the Xbox One shipped and I haven’t paid any attention to it since then, so I don’t know what they decided to do. From experience trying to play 360 games on an Xbox One, the console reads nothing from the DVD and instead downloads the game from the Internet. It also only works for specific games. I therefore assume they gave up with emulation and simply recompiled certain 360 games…

https://www.eurogamer.net/articles/digitalfoundry-2017-xbox-...

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#23

As far as I know, a correct emulation of FMA involves the double-double approach [1], that is to split a logical mantissa potentially larger than the native mantissa and merge them later. This is of course expensive and probably not a good fit for the OP's purpose anyway. [1] https://hal-ens-lyon.archives-ouvertes.fr/inria-00080427v2/d... has a verified proof.

double-double or quad precision is necessary to emulate double-precision FMA. The article is talking about emulating single-precision FMA with double-precision. The relevant paragraph is: > Luckily the vast majority of floating-point math in games is done to float (32-bit) precision, and I was quite happy to use double (64-bit precision) instructions in the emulation of FMA. One big difference between quad-precision…

Probably I was not as careful in the choice of a word "double-double". My point was that the error recovery (or, as the paper refers, the error-free transformation) seems crucial for FMA emulation in general. You are entirely right that double-double has many pitfalls.

My thinking was that, in this particular case we need around 24 × 3 = 72 bits of mantissa (I haven't verified the exact number, but it clearly exceeds 60 bits) to avoid the double rounding---which double precision cannot provide. The verified algorithm gives a lot more than enough headroom for this particular setting: ExactMult is just a normal double multiply and ExactAdd will recover the error out of double addition. It might even be possible to optimize later cases. But it seems to me that you can't really get rid of the error recovery procedure itself. Well, I may be wrong.

EDIT: Oh, I see your neighboring replies. So I was wrong! The glibc solution however looks pretty expensive and it is unfortunate that there exists no faster alternatives known.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#24

Earlier quoted context omitted.

double-double or quad precision is necessary to emulate double-precision FMA. The article is talking about emulating single-precision FMA with double-precision. The relevant paragraph is: > Luckily the vast majority of floating-point math in games is done to float (32-bit) precision, and I was quite happy to use double (64-bit precision) instructions in the emulation of FMA. One big difference between quad-precision…

Probably I was not as careful in the choice of a word "double-double". My point was that the error recovery (or, as the paper refers, the error-free transformation) seems crucial for FMA emulation in general. You are entirely right that double-double has many pitfalls. My thinking was that, in this particular case we need around 24 × 3 = 72 bits of mantissa (I haven't verified the exact number, but it clearly exceeds…

There is no reason to estimate the required precision as 3 times the original precision, because floating-point addition does not work like that.

If you want to compute the exact result of a floating-point addition, you need approximately emax - emin bits of precision. Floating-point addition is never computed this way.

On the other hand, multiplication does have the property that the required precision for representing the result of multiplying numbers with precisions p and q is p+q.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#25

Earlier quoted context omitted.

Probably I was not as careful in the choice of a word "double-double". My point was that the error recovery (or, as the paper refers, the error-free transformation) seems crucial for FMA emulation in general. You are entirely right that double-double has many pitfalls. My thinking was that, in this particular case we need around 24 × 3 = 72 bits of mantissa (I haven't verified the exact number, but it clearly exceeds…

There is no reason to estimate the required precision as 3 times the original precision, because floating-point addition does not work like that. If you want to compute the exact result of a floating-point addition, you need approximately emax - emin bits of precision. Floating-point addition is never computed this way. On the other hand, multiplication does have the property that the required precision for represent…

We don't compute the exact sum, we just need enough precision to ignore the double rounding. The most pathological cases are therefore either:

- the product is just above the ULP of the addend, or

- the addend is just above half the ULP of the product.

I'm not sure about the latter (the possible bit patterns of the product are constrained) but the former clearly requires 3 times the original precision, and beyond that there is no possibility of double rounding. The same thing can be said for the latter.

Of course all these points are moot when it is known that rounding-to-odd can be used to avoid error recovery at all.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#26
post #13

Do games really rely on the rounding behaviors of floats to not break? Seems like there should always be plenty of margin around that. But maybe something does a loop with these instructions over and over and the error compounds? And wouldn't the solution on x86 be to use the more than double precision floats that are available in the platform? https://en.wikipedia.org/wiki/Extended_precision

They do. A trivial example is input recording for replays -- if you don't have a very similar FP implementation, the replays will desync: https://www.youtube.com/watch?v=XxGg1TCpYrc

Collision detection is sometimes also very FP sensitive. See https://www.youtube.com/watch?v=9hwuz2U1JV8 fixed by https://github.com/dolphin-emu/dolphin/pull/390

https://www.youtube.com/watch?v=eEbmrwnYaXs has a few more examples we've documented.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#27
post #16

Earlier quoted context omitted.

They do. Slight problems with floating point behavior are the cause of many historical problems with GameCube and Wii games in the Dolphin emulator (which also has to emulate PPC on x86/x64) For a simpler example from personal experience, I had a textbook implementation of triangulation via ear clipping to turn polygons into a list of triangles I could send to the GPU. On Windows it worked great but when I ran it on…

> This turned out to be because the rounding behavior on the 360 was different and the algorithm is fundamentally unstable using floats. That sounds like a bug though but I guess that's the point. Unless you're bug for bug compatible a reasonable amount of code will fail a significant amount of time...

Performance is often a critical feature in games.

Nobody will play a janky game and go "yeah, it's a bit rough but I'm sure the floating-point operations are done sensibly if it were to run under emulation, two console generations in the future".

Console games are not like ordinary/business applications where being 15 ms late is almost always better than tying the code to the hardware.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#28

Earlier quoted context omitted.

I’ve never had that happen - they just looked at my bank account. I wouldn’t want a mortgage provider talking to my employer.

As an employer, I have had mortgage brokers call our HR lead quite often to verify loan applications. For those who are concerned about privacy: I have found that those loan providers are then selling that data to websites that offer aggregated salary data.

Just wanted to add another data point and confirm that I've also had to do this as an employer (in the UK). Salary, length of employment and job title at least.

Edit: Also for rental contracts.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#29

Earlier quoted context omitted.

Do mortgage brokers call your employer? What’s your mortgage got to do with your employer?

Looking at the events that lead up to the financial crash, not much you'd think. What with people putting mortgages on their dogs and whatnot.

As a self-employed person who has applied for a mortgage both before and after the crash, I can tell you that a lot has changed. It's just taken me nearly a month of back-and-forth to get approved despite having a near-perfect credit history.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#30
post #22
post #3

> I left the Xbox team long before the Xbox One shipped and I haven’t paid any attention to it since then, so I don’t know what they decided to do. From experience trying to play 360 games on an Xbox One, the console reads nothing from the DVD and instead downloads the game from the Internet. It also only works for specific games. I therefore assume they gave up with emulation and simply recompiled certain 360 games…

https://www.eurogamer.net/articles/digitalfoundry-2017-xbox-...

This makes me wonder if the Halo Master Chief Collection release on PC will be based on emulation.
Post reply on HN