Exercises in Emulation: Xbox 360’s FMA Instruction
randomascii.wordpress.com
randomascii.wordpress.com
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 for x64.
EDIT: I don't know if they did emulation or not - I always believed they did but only managed to certify some games.
- Supposedly the early Xbox One games used a fork/version of DirectX that wasn't ever quite released in that form in Windows 10. Rumors are that has been corrected in the upcoming April Release.
- Also, the early Xbox One games used very different Microsoft Store asset servers/etc. The State of Decay Insider tests seem to indicate that April Release of Windows 10's Microsoft Store can now speak to Xbox asset servers/etc directly. (Indications that the State of Decay game installed from possibly the exact same assets in the April Release as it would on an Xbox One.)
- Finally, early Xbox One games sometimes made assumptions that they ran in lightweight VMs with almost no multitasking (except for Kinect-related restrictions when that was mandatory) and some very specific performance characteristics versus the wild west of available PC hardware. Rumors abound that Hyper-V improvements in Windows 10 solve some of the VM/multitasking issues. Leaving only, perhaps, the need to test on a variety of PC hardware configurations.
Obviously, a lot of speculation there. Presumably a lot more information will surface as the April Release happens and as E3 approaches.
Supposedly a true x64 port of the multiple generations of the Halo engines was an important goal of the 343 team to feel that they knew the engines inside and out, and had a good handle on using that engine for Halo 5 to give a longer lead time on their next engine. (Halo Infinite [6] supposedly will use a brand new engine codenamed "Slipspace".)
Other signs that MCC was most likely a very "proper" port of the engines to x64 include some of the ways bugs riddled the early post-launch phases, especially in multiplayer code.
You can just read that code and see how it’s done. Despite the ridiculous ending there was no mystery to begin with.
The 2011 date from Wikipedia is for when hardware development began. Investigations into what hardware would be used would obviously predate that so there's no contradiction.
Anyway, I'll have to digest that FMA emulation article and see what sort of performance their algorithm achieves. A branchless and vector-math compatible implementation would be important for performance.
[1] https://hal-ens-lyon.archives-ouvertes.fr/inria-00080427v2/d... has a verified proof.
> 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 and double-double is that quad-precision has a much wider exponent range. If you use double-double, you need to worry that the result of the multiplication may underflow a double. In the article you cited:
> First, the value ul has to be the error term of the multiplication a · b, in order to avoid some degenerate underflow cases: the error term becomes so small that its exponent falls outside the admitted range. […] The algorithm will behave correctly even if some computed values are not normal numbers, as long as ul is representable.
… implying that the algorithm may not compute the FMA if the error of the multiplication is not representable, which can happen when it is below the normal range.
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.
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.
- 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.
Employers won’t verify salary. But they will verify employment. I’m not sure if they’ll verify length of employment or not.
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.
Edit: Also for rental contracts.
In normal cases it's fine
Maybe they did recompile the games for backwards compatibility, maybe they do have an emulator, IDK, but I want to know how they would have fixed this issue.
https://github.com/lattera/glibc/blob/b4d5b8b02133e0c317e6c8...
“round-to-odd” is not a standardized rounding mode, even though it is so useful that some argue it should be. It can be emulated by the following sequence:
/* Reset rounding mode and test for inexact simultaneously. */
int j = libc_feupdateenv_test (&env, FE_INEXACT) != 0;
if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7ff)
u.ieee.mantissa1 |= j;
The sequence has the drawback of not pipelining well on modern processors, but it's still faster than any known alternative, and at least the code is short.Looks like the removed FMA4 on the bobcat to jaguar transition.
And wouldn't the solution on x86 be to use the more than double precision floats that are available in the platform?
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 an XBox 360 it looped infinitely. 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...
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.
It would be a bug to release code that required x86 floating point behavior on a non-x86 system, but in this case, it was easily caught during early testing.
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.
I remember that in PearPC the sin function of cocoa (IIRC) would crash if the FMA instructions did not provide enough accuracy. It would access a table of precomputed values out of bounds or so.
These decisions sometimes end up right on a cusp, where a single unit in the last place determines the behavior. In a sensitive physics engine these happen more often than you might think. And when the result changes, all future events are impacted.
This is crucial for replays, it may be crucial for multiplayer, and it can result in unexpected behavior in ways that you only find when writing an emulator.
A slight change in floating-point math may also result in a slightly larger-than-expected number which may then result in a slightly negative number which may result in a NaN (sqrt(-1e39) perhaps) which then results in the poisoning of all future math that uses that number.
> However, for any rounding rule that you might come up with there is a case where the double rounding will give you a different answer from a true FMA.
For every “directed” rounding (up, down, towards zero), rounding the result of one operation first to higher precision and then to the intended precision is identical to rounding directly to the intended precision. For this reason, computing the FMA as “first compute the multiplication in higher precision so that no rounding happens in this step, then add the third operand at the same precision, then round to the nominal precision” does not suffer from double-rounding issues in all these rounding modes (which are all the rounding modes defined by IEEE 754 other than “round to nearest”).
So you do not even need to “come up with” them. They already exist, they are all the standardized rounding modes other than “round to nearest”.
Note: the reasoning above assumes the result of the multiplication is representable as a normal number in the higher-precision format. It is a property of IEEE 754 formats that the next more precise one can always represent the result of the multiplications of two finite numbers from the format below it as a normal number.