Javasolt válasz Auto-vectorizer in Developer Preview

  • 19. února 2012 13:53
     
     

    I'm trying to evaluate some of the new features, specifically the auto-vectorizer.
    I created a trivial example (Release with optimization and memory alignment are a given):

    float array_sum(const float* buffer, int len)
    {
      float res=0;
      for(int i=0;i<len;++i)
        res+=buffer[i];
      return res;
    }

    But what I see when inspecting the generated code is less than spectacular.

      for(int i=0;i<len;++i)
        res+=buffer[i];
    01261280  addss       xmm1,dword ptr [ecx-8]  
    01261285  lea         ecx,[ecx+20h]  
    01261288  addss       xmm1,dword ptr [ecx-24h]  
    0126128D  addss       xmm1,dword ptr [ecx-20h]  
    01261292  addss       xmm1,dword ptr [ecx-1Ch]  
    01261297  addss       xmm1,dword ptr [ecx-18h]  
    0126129C  addss       xmm1,dword ptr [ecx-14h]  
    012612A1  addss       xmm1,dword ptr [ecx-10h]  
    012612A6  addss       xmm1,dword ptr [ecx-0Ch]  
    012612AB  dec         eax  
    012612AC  jne         array_sum+10h (01261280h)

    Needless to say that an intrinsics implementation of such a function gives about 4x improvement over this code.
    Am I missing a certain flag, or is this the current performance of the compiler?

Všechny reakce

  • 21. února 2012 3:14
     
     Navržená odpověď

    Hi photon2038,

    Welcome to the MSDN Forum.

    According to your description, we found that this questiosn is related to VS11. So it will be moved to "Tools for Metro style apps Forum" for better support, where more experts live.

    Thanks for your understanding.
    Have a nice day!


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us