Mon Aug 14 15:23:43 CEST 2006
On Sun, 13 Aug 2006, Mikael Pettersson wrote:
> On Sun, 13 Aug 2006 00:02:19 +0100, Joel Reymont wrote:
>> On Aug 12, 2006, at 10:23 PM, Mikael Pettersson wrote:
>>> The fpe-test.c code embedded in erts/configure.in shows how
>>> to enable and catch floating-point exceptions for a number of
>>> CPU/OS combinations.
>> This is obvious in retrospect but it was a pain in the rear and took
>> me a day to find out. The Intel Core Duo processors have SSE2 and
>> these also need to be unmasked for floating-point exceptions to be
>> trapped. Simply unmasking x87 is not enough.
> Traditionally 32-bit x86 only used the x87 by default, since
> SSE2 is a newish addition. Your comment indicates that Apple
> went directly to the modern world (SSE2) when they started
> doing x86. Not a problem: just make the existing SSE2 code
> unconditional and not restricted to 64-bit builds.
Hello Joel, and the rest of the list.
I thought I should expand on Mikaels answer.
If I remember correctly there is no SSE2 support for 32-bit x86, yet. I
had some plans to backport the 64 bit version, but it never happened, and
when I look in hipe.erl I see that my old comment is still in there.
[x87 | Common]; %% XXX: Temporary until x86 has sse2
In theory it is rather simple to get sse2 for the 32-bit x86 though:
1. The code to generate sse2 is already in the 32-bit x86 backend. (This
can probably be used out-of-the-box for Intel Mac)
2. One needs to change the exception stack handling, which is kind of
easy, except that the gcc-headers didn't have the SSE2 fields when I
looked at it the last time. Either one hard codes the offsets by hand, or
hopes that gcc have changed the header stuff. Easy, but I was lazy. (This
has a lot to do with exception stack handling, and I have no idea how it
looks like for the Intel Mac)
3. Change skip_sse2_insn in erts/emulator/sys/unix/sys_float.c to handle
32 bit instructions instead of 64 bit instructions. In particular, the
meanings of 0x40 and 0x41 have changed, and maybe some other instruction
codes that I don't remember right now. (Easy, but needs to be done with
4. The tricky part! Find some way to detect (at runtime, or at least load
time) that the machine doesn't handle SSE2 and fallback to BEAM. Easy, but
probably more expensive than the potential gain. The downside of backwards
compatibility. If core dumps are ok for an old machine, this step can be
skipped. (A no-issue for the Mac Intel)
5. Replace "[x87 | Common]" with "Common" in hipe.erl.
That should be it!
Joel: I hope that helped. How about fixing sse2 for Linux x86 while you
are at it?
Daniel Luna | Top reasons that I have a beard:
luna@REDACTED | a) Laziness.
http://www.update.uu.se/~luna/ | b) I can.
Don't look at my homepage (it stinks).| c) I can get away with it.
More information about the erlang-questions