13.07.2015 Views

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CODING FOR SIMD ARCHITECTURESExample 4-7 shows the Streaming SIMD Extensions inlined assembly encoding.Example 4-7. Streaming SIMD Extensions Using Inlined Assembly Encodingvoid add(float *a, float *b, float *c){__asm {mov eax, amov edx, bmov ecx, cmovaps xmm0, XMMWORD PTR [eax]addps xmm0, XMMWORD PTR [edx]movaps XMMWORD PTR [ecx], xmm0}}4.3.1.2 IntrinsicsIntrinsics provide the access to the ISA functionality using C/C++ style codinginstead of assembly language. Intel has defined three sets of intrinsic functions thatare implemented in the Intel C++ Compiler to support the MMX technology,Streaming SIMD Extensions <strong>and</strong> Streaming SIMD Extensions 2. Four new C datatypes, representing <strong>64</strong>-bit <strong>and</strong> 128-bit objects are used as the oper<strong>and</strong>s of theseintrinsic functions. __M<strong>64</strong> is used for MMX integer SIMD, __M128 is used for singleprecisionfloating-point SIMD, __M128I is used for Streaming SIMD Extensions 2integer SIMD, <strong>and</strong> __M128D is used for double precision floating-point SIMD. Thesetypes enable the programmer to choose the implementation of an algorithm directly,while allowing the compiler to perform register allocation <strong>and</strong> instruction schedulingwhere possible. The intrinsics are portable among all Intel architecture-basedprocessors supported by a compiler.The use of intrinsics allows you to obtain performance close to the levels achievablewith assembly. The cost of writing <strong>and</strong> maintaining programs with intrinsics is considerablyless. For a detailed description of the intrinsics <strong>and</strong> their use, refer to theIntel C++ Compiler documentation.4-10

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!