Opened 6 years ago

Last modified 10 months ago

#8949 new bug

switch -msse2 to be on by default

Reported by: errge Owned by:
Priority: high Milestone: 8.8.1
Component: Compiler (CodeGen) Version: 7.9
Keywords: Cc: simonmar
Operating System: Unknown/Multiple Architecture: x86
Type of failure: Runtime performance bug Test Case:
Blocked By: #13624 Blocking:
Related Tickets: #13540, #13624 Differential Rev(s):
Wiki Page:

Description

I propose msse2 to be on by default. I guess the default was chosen way back, when Pentium III support was still relevant.

Nowadays we don't really win on the CPU support, because e.g. https://github.com/tibbe/hashable/blob/master/hashable.cabal is built by default with sse2 on the injected C code level. And hashable has a lot of reverse depends, therefore on an end user system (RedHat or Debian) the user is most probably unlucky with a Pentium III CPU anyways.

Flipping this default would also fix the excess precision problem for most users of GHC on the i686 platform.

GHC should provide a -mno-sse2 flag for the cases when this needs to be disabled.

Change History (17)

comment:1 Changed 6 years ago by schyler

I second this.

comment:2 Changed 6 years ago by tibbe

I think we should, like LLVM, switch on -march=native by default and have people who want to build more portable binaries specify their target explicitly. This doesn't preclude turning on -msse2 by default of course.

comment:3 Changed 6 years ago by errge

Johan, -march=native is a very interesting idea, thanks for bringing it up!

If you have ideas about that, please open a new ticket for discussion.

I'd like to keep this ticket/patch/feature request as minimal as possible and only about switching the default if others in the community agree. Implementing your envisioned -march=native seems to be a very useful thing to do, but a much bigger job...

comment:4 Changed 6 years ago by carter

Errge: I'd argue that changing the default needs to be predicated on adding march style machinery! There's enough stuff slated for 7.10 that would benefit from from ghc having more systematic support for micro arch selection feature flags that making msse2 the default on 32bit systems would miss the point of tst work.

I also think that while it would touch more of ghc, such a patch wouldn't be much more complex.

comment:5 in reply to:  2 Changed 6 years ago by simonmar

Replying to tibbe:

I think we should, like LLVM, switch on -march=native by default and have people who want to build more portable binaries specify their target explicitly. This doesn't preclude turning on -msse2 by default of course.

I like -march-native, but I'm not convinced it should be the default. For GHC it will add minimal gain, in exchange for some very obscure crashes when someone forgets to turn it off when building a binary that might need to run on another machine. The Haskell way is correct but slow by default, and I think that's what we should do here.

I think I'm less concerned about -msse2, because it will affect a lot fewer people.

comment:6 Changed 6 years ago by tibbe

I'm fine with only doing -msse2 for now.

The amount of benefit we'll get from -march=native is growing. We're adding more intelligence to the code generator (e.g. memcpy will soon unroll to wider instructions if the target supports it, we have popcnt and bswap) and compiling with -fllvm should benefit too e.g. as code for the vector package would presumably compile to better assembly.

comment:7 Changed 5 years ago by thomie

Type of failure: OtherRuntime performance bug

comment:8 Changed 2 years ago by bgamari

Milestone: 8.4.1
Priority: normalhigh

I am fine doing this for 8.4. Milestonjng.

comment:9 Changed 2 years ago by MikolajKonarski

comment:10 Changed 2 years ago by bgamari

Phyx points out in ticket:13540#comment:4 that,

neither the linux elf nor Windows GHCi linkers (non-dynamic way) currently honor section alignment. so using SSE2 more aggressively would likely cause issues here.

This issue is tracked as #13624.

Last edited 2 years ago by bgamari (previous) (diff)

comment:11 Changed 21 months ago by bgamari

Milestone: 8.4.18.6.1

We can't act on this until the linker issues are sorted out.

comment:12 Changed 20 months ago by George

comment:13 Changed 20 months ago by George

Blocked By: 13624 added

comment:14 Changed 17 months ago by bgamari

Milestone: 8.6.18.8.1

comment:15 Changed 14 months ago by carter

I know this was fixed in the windows linker afaik. Has the alignment issue been addressed on other platforms yet or what are the blockers ?

comment:16 Changed 10 months ago by carter

https://gitlab.haskell.org/ghc/ghc/merge_requests/24 is my first step towards making sse2 always true on x86/x86_64

Note: See TracTickets for help on using tickets.