Announcement

Collapse
No announcement yet.

MMX and SIMD opcodes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
    Steve Hutchesson
    Member

  • Steve Hutchesson
    replied
    Ok,

    I have got what you meant. As far as I know from looking at a lot of PB code over time, NO. It would force every compiled program into having to have a proocessor detect built into it and multiple copies of algorithms for different processors.

    The compiler provides the low level functionality to build programs and much of the code that it must provide to create executable code would not improve by choosing MMX or XMM instructions as it involves mainly interaction with the operating system.

    The inline assembler is provided to be able to do the more advanced stuff that is processor model specific.

    Leave a comment:

  • Gabor Toeroe
    Member

  • Gabor Toeroe
    replied
    I meant if the compiled code contains sse/mmx instructions even if the source does not contain them (via inline ASM).

    Originally posted by Steve Hutchesson View Post
    Gabor,

    The latest versions of PB support both MMX and XMM (SSE) opcodes but it is your responsibility to check if the processor supports those opcodes.

    Steve's technical advice is due to the way PowerBASIC minimises the size of EXE code by using the floating point unit for a wide range of default arithmetic operations so if you use MMX specific instructions that in turn use the MMX registers you must reset the registers with EMMS so that you do not interfere with the default operations.

    Leave a comment:

  • Steve Hutchesson
    Member

  • Steve Hutchesson
    replied
    Gabor,

    The latest versions of PB support both MMX and XMM (SSE) opcodes but it is your responsibility to check if the processor supports those opcodes.

    Steve's technical advice is due to the way PowerBASIC minimises the size of EXE code by using the floating point unit for a wide range of default arithmetic operations so if you use MMX specific instructions that in turn use the MMX registers you must reset the registers with EMMS so that you do not interfere with the default operations.

    Leave a comment:

  • José Roca
    Member

  • José Roca
    replied
    Yes, it does. Read the help file, topic ASM statement.

    Leave a comment:

  • Gabor Toeroe
    Member

  • Gabor Toeroe
    replied
    Maybe it was asked somewhere else but I can't find a satisfying answer:

    Does PB support SSE/MMX or do I have to put in my own ASM support for it?

    Originally posted by Steve Rossell View Post
    Recently technical support received an email from a user having problems with his code after executing some MMX instructions. I wanted to pass on this information to the community, so that you also do not encounter this same problem. When you execute an MMX or SIMD instruction (those that use MMX data), the FPU is placed in MMX state. You may then execute additional MMX or CPU opcodes. When you wish to exit MMX state and execute standard FPU opcodes, you must first execute an EMMS opcode. Failure to do so will result in floating-point exceptions or incorrect results.

    Leave a comment:

  • Steve Hutchesson
    Member

  • Steve Hutchesson
    replied
    Gabor,

    No, the XMM registers are not shared with the FP unit so you don't have to worry about that one. The main trick when using XMM (SIMD) is making sure the processor supports the opcodes you are using.

    Leave a comment:

  • Gabor Toeroe
    Member

  • Gabor Toeroe
    replied
    Originally posted by Steve Rossell View Post
    Recently technical support received an email from a user having problems with his code after executing some MMX instructions. I wanted to pass on this information to the community, so that you also do not encounter this same problem. When you execute an MMX or SIMD instruction (those that use MMX data), the FPU is placed in MMX state. You may then execute additional MMX or CPU opcodes. When you wish to exit MMX state and execute standard FPU opcodes, you must first execute an EMMS opcode. Failure to do so will result in floating-point exceptions or incorrect results.
    Is this still the case if you have a CPU with SSE?

    Leave a comment:

  • Steve Rossell
    Member

  • Steve Rossell
    started a topic MMX and SIMD opcodes

    MMX and SIMD opcodes

    Recently technical support received an email from a user having problems with his code after executing some MMX instructions. I wanted to pass on this information to the community, so that you also do not encounter this same problem. When you execute an MMX or SIMD instruction (those that use MMX data), the FPU is placed in MMX state. You may then execute additional MMX or CPU opcodes. When you wish to exit MMX state and execute standard FPU opcodes, you must first execute an EMMS opcode. Failure to do so will result in floating-point exceptions or incorrect results.
Working...
X