Author Topic: When to use x87 or SSE or SSE2 or SSE3 or SSSE3 or MMX  (Read 16603 times)

Offline hhh3h

  • Jr. Member
  • *
  • Posts: 41
When to use x87 or SSE or SSE2 or SSE3 or SSSE3 or MMX
« on: April 16, 2013, 10:26:58 PM »
Hello, I noticed that many of these supplemental instruction sets are capable of doing math. So I was wondering, if SSE (etc) is available, is there any reason at all to utilize the x87 instructions?

Furthermore these instruction sets also have regular integer arithmetic operations, so if available, would it be faster to use some of these supplemental instruction sets instead of add, adc, mul, imul, etc?

Offline Gerhard

  • Jr. Member
  • *
  • Posts: 51
Re: When to use x87 or SSE or SSE2 or SSE3 or SSSE3 or MMX
« Reply #1 on: April 17, 2013, 06:43:59 PM »
Hi hhh3h,

Hello, I noticed that many of these supplemental instruction sets are capable of doing math. So I was wondering, if SSE (etc) is available, is there any reason at all to utilize the x87 instructions?

the reason is parallelization. You can have, for example, 2 REAL8 values or 4 REAL4 values inside a XMM register and doing the same operation in parallel. With the new YMM register (available for Sandy Bridge and Ivy Bridge), one can load 4 REAL8 or 8 REAL 4. And of course, it's faster.

Gerhard

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: When to use x87 or SSE or SSE2 or SSE3 or SSSE3 or MMX
« Reply #2 on: April 17, 2013, 07:23:18 PM »
I think what hhh3h was getting at was "why still use x87 at all?" I'm not sure, but I think the answer is "transcendental functions" - sine, cosine... maybe logarithms... That kind of thing. I think. I'm really over my head with any of those "new-fangled" instructions - SSE of any version. One of these days I'll have to download some ambition and learn these things!

I understand that SSE is good for "multiple data", and if you haven't got "multiple data", they're not that big a win. I understand that if you're doing graphics, you've got "multiple data". I pretty much lost the plot with graphics after about mode 13h, so I've got a lot of catching up to do before I'll even understand what I'd want to use SSE for...

I'd love to see some examples - as simple as possible - if anybody's got some!

Best,
Frank


Offline Gerhard

  • Jr. Member
  • *
  • Posts: 51
Re: When to use x87 or SSE or SSE2 or SSE3 or SSSE3 or MMX
« Reply #3 on: April 17, 2013, 08:53:16 PM »
Frank,

I'd love to see some examples - as simple as possible - if anybody's got some!

Best,
Frank

please check out that one or that one. Hope that helps. Let me know, if you need more information, because SIMD is a good idea, not only for graphics programming.

Gerhard

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: When to use x87 or SSE or SSE2 or SSE3 or SSSE3 or MMX
« Reply #4 on: April 17, 2013, 09:22:02 PM »
Thanks Gerhard! I'll look at 'em. I'm going to have to make a dump-run with the current hardware and get something manufactured this century before I can get into 'em. :(

Best,
Frank


Offline Gerhard

  • Jr. Member
  • *
  • Posts: 51
Re: When to use x87 or SSE or SSE2 or SSE3 or SSSE3 or MMX
« Reply #5 on: April 18, 2013, 07:52:04 PM »
Frank,

both applications won't crash with older hardware, because that'll be checked during runtime.

Gerhard