Visual Studio 11 Development Guide (18) C ++ 11 Update-Use of Automatic Vector Machines

Source: Internet
Author: User
Use of the Automatic Vector

In the msdn document, the reason for the current Compiler's automatic performance is the ability to "outline" loop and support SIMD commands, which in most cases call automatic performance, x 86 processors/x 64 modern processors run eight times faster.

In versions earlier than Visual Studio 11, SIMD commands and overview records are automatically optimized.

And the following cycle in Visual Studio C/C ++ in 2010

 

1.for (int i=0;i <MAX_;i++)2.    {3.        a[i]=i*7.0;4.    }

 

The following assembler code is provided for the floating point numbers used for instruction and register operations. (Latency, fmul, fstp, fstp, ST (1) (0), St))

1.; 38   :     for (int i=0;i <MAX_;i++)2. 3.    fld    QWORD PTR __real@401c0000000000004.    add    esp, 45.    mov    esi, eax6.    xor    eax, eax7.    mov    DWORD PTR _i$83361[ebp], eax8.$LN3@wmain:9. 10.; 39   :     {11.; 40   :         a[i]=i*7.0;12. 13.    fild    DWORD PTR _i$83361[ebp]14.    inc    eax15.    mov    DWORD PTR _i$83361[ebp], eax16.    fmul    ST(0), ST(1)17.    fstp    QWORD PTR [esi+eax*8-8]18.    cmp    eax, 100000000                ; 05f5e100H19.    jl    SHORT $LN3@wmain20. 21.; 41   :     }

 

Visual Studio 11 is in the same loop,By default,The following code is implemented in the specific tracing record code of the assembler. (Movsd, ultra-low, cvtdq2pd, xmm0, xmm1))

 

 

1.; 38   :     for (int i=0;i <MAX_;i++)2. 3.    movsd    xmm1, QWORD PTR __real@401c0000000000004.    add    esp, 45.    mov    esi, eax6.    xor    ecx, ecx7.    npad    58.$LL9@wmain:9. 10.; 39   :     {11.; 40   :         a[i]=i*7.0;12. 13.    movd    xmm0, ecx14.    cvtdq2pd xmm0, xmm015.    inc    ecx16.    mulsd    xmm0, xmm117.    movsd    QWORD PTR [esi+ecx*8-8], xmm018.    cmp    ecx, 100000000                ; 05f5e100H19.    jl    SHORT $LL9@wmain20. 21.; 41   :     }

 

 

Is it possible to disable this function?

Is not enough to go to the C ++ project of this attribute,. Code Generation. Enable enhanced Instruction SetAnd select(/Arch: ia32)(By default, it isNot Set, Which means whether automatic vectoring is enabled), as shown in

On the testing machine,Not Set, Corresponding: Sse2.

Does it affect performance?

It is an iteration loop of 10 thousand. Let's take a look at the optimized results.

No description

Description

Automatic Parallelism

In this document, we can now use the multi-processor vs 11Parallel processing function,To enable multi-core optimization. New commands/QparTo enable this function.

 

Accelerate large-scale parallel processing (AGP) Support for C ++

VS 11 will also enable it to take advantage of the possibility of graphics cards in gpgpu. In other words, it can mix traditional code CPU and GPU code.

 

Download vs11 now

Http://www.microsoft.com/click/services/Redirect2.ashx? Cr_cc = 200098144

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.