Re: [Interest] Qt and SSE2

2018-02-09 Thread Thiago Macieira
On Friday, 9 February 2018 10:09:03 PST Eric Lemanisser wrote:
> That is not my experience: https://godbolt.org/g/ZZG1mp

That's not a valid test because you forgot the -m32 switch. Disabling SSE2 on 
64-bit is nonsensical.

Try this one instead: https://godbolt.org/g/C853Gx

As I said in the other email, you also need -mfpmath=sse. But even if you add 
that to the right compiler, you'll see it performs the addition in SSE, but 
then stores the value on the stack at the end and reloads using the 387 
instructions. If your array is short, this could be a pessimisation.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center



___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt and SSE2

2018-02-09 Thread Thiago Macieira
On Friday, 9 February 2018 08:36:59 PST Thiago Macieira wrote:
> > Qt is built with SSE2 by default since 5.3.0. Is there a reason for not
> > enabling by default SSE2 for application compilation ? If not I'll start
> > working on a change doing that.
> 
> Because we didn't want to force that on users. It's also easy to keep two
> libraries on Linux, one for SSE2 and one for earlier versions. That can't be
> done for binaries.
> 
> Enabling SSE2 alone won't gain you much. You must also either switch to SSE
> math (-mfp-math=sse)

One more thing: SSE2 is enabled by default on 64-bit, since it's part of the 
ABI, on all platforms. It's also enabled by default on 32-bit Mac (SSSE3 
actually is), since the first x86 Macs had that.

So that only leaves 32-bit builds for Windows and Linux, which are quickly 
disappearing. We haven't provided 32-bit binaries for Linux for a couple of 
releases already; the Windows ones are also disappearing.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center



___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt and SSE2

2018-02-09 Thread Eric Lemanisser
That is not my experience: https://godbolt.org/g/ZZG1mp

Le ven. 9 févr. 2018 à 18:58, Marian Beermann  a écrit :

> SSE et al are mostly helpful if you have code either using these
> instructions directly (assembly, intrinsics) or being written in a way
> that the optimizer can easily take advantage of (see what Thiago wrote).
>
> For general application code they generally do very little if anything
> by themselves.
>
> -Marian
>
> On 02/09/2018 05:15 PM, Eric Lemanisser wrote:
> > Qt is built with SSE2 by default since 5.3.0. Is there a reason for not
> > enabling by default SSE2 for application compilation ? If not I'll start
> > working on a change doing that.
> > Also, any plan migrating to SSE3 or SSSE3 ?
> >
> > Eric Lemanissier
>
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt and SSE2

2018-02-09 Thread Marian Beermann
SSE et al are mostly helpful if you have code either using these
instructions directly (assembly, intrinsics) or being written in a way
that the optimizer can easily take advantage of (see what Thiago wrote).

For general application code they generally do very little if anything
by themselves.

-Marian

On 02/09/2018 05:15 PM, Eric Lemanisser wrote:
> Qt is built with SSE2 by default since 5.3.0. Is there a reason for not
> enabling by default SSE2 for application compilation ? If not I'll start
> working on a change doing that.
> Also, any plan migrating to SSE3 or SSSE3 ?
> 
> Eric Lemanissier
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Qt and SSE2

2018-02-09 Thread Thiago Macieira
On Friday, 9 February 2018 08:15:19 PST Eric Lemanisser wrote:
> Qt is built with SSE2 by default since 5.3.0. Is there a reason for not
> enabling by default SSE2 for application compilation ? If not I'll start
> working on a change doing that.

Because we didn't want to force that on users. It's also easy to keep two 
libraries on Linux, one for SSE2 and one for earlier versions. That can't be 
done for binaries.

Enabling SSE2 alone won't gain you much. You must also either switch to SSE 
math (-mfp-math=sse) or enable the vectoriser (-ftree-vectorize or -O3).  The 
vectoriser increases code size, so it's not always welcome.

We force SSE math in Qt builds if SSE is enabled and we also compile both 
QtCore and QtGui with -O3, but not any of the other modules.

> Also, any plan migrating to SSE3 or SSSE3 ?

The gain is very modest from one to the other. There are a couple of functions 
optimised for SSSE3, some more for SSE4.1, and maybe one for SSE4.2. The 
biggest gain is AVX and again with AVX2.

And just like before, on Linux, you can keep AVX2 libraries parallel to SSE2 
and non-optimised ones. That's not the case for any of the other (recent) CPU 
features.

I think the Apple fat binaries also have an architecture "x86_64h" where the 
"h" stands for "Haswell" and do allow parallel binary for AVX2.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center



___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest