Missed optimization opportunities using dvec.h

Missed optimization opportunities using dvec.h

Bild des Benutzers jimdempseyatthecove

Compile this for use on AVX system (Intel C++) and compare runtimes of two loops.

The first loop (not using dvec.h) generates nice vector code but incorporates vinsertf128's and vextractf128 in the preponderant computational section of this loop. This shows as 7 memory references.

The second loop (using dvec.h) generates nice vector code as well, but does not use the the vinsert/vextract in the preponderant computational section of this loop. This shows as4 memory references.

*** the first loop runs faster??? By about 2x!!!!

In looking at the disassembly it is interleaving reads (not unrolled) in the first loop but not in the second loop.

This may be a good example for your compiler optimization team to examine for optimization opportunities.
[cpp]// Felix.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "dvec.h"
#include "omp.h"
#include

#define USE_AVX
#ifdef USE_AVX
struct aosoa
{
F32vec8 a1;
F32vec8 a2;
F32vec8 a3;
F32vec8 a4;
};
const int VecWidth = 8;
#else
struct aosoa
{
F32vec4 a1;
F32vec4 a2;
F32vec4 a3;
F32vec4 a4;
};
const int VecWidth = 4;
#endif
const int N = 64*1024*1024;
const int Nvecs = N / VecWidth;

float* a1; // [N];
float* a2; // [N];
float* a3; // [N];
float* a4; // [N];

aosoa* s; // [Nvecs];

float coeff1 = 1.2345f;
float coeff2 = .987654321f;

int _tmain(int argc, _TCHAR* argv[])
{
a1 = new float[N];
a2 = new float[N];
a3 = new float[N];
a4 = new float[N];
s = new aosoa[Nvecs];
std::cout << "a1 " << &a1[0] << std::endl;
std::cout << "a2 " << &a2[0] << std::endl;
std::cout << "a3 " << &a3[0] << std::endl;
std::cout << "a4 " << &a4[0] << std::endl;
std::cout << "s " << &s[0] << std::endl;
for(int i=0; iJim Dempsey

www.quickthreadprogramming.com
2 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Bild des Benutzers Georg Zitzlsberger (Intel)

Hello Jim,

I've seen you already posted a link in the compiler forum to here:
http://software.intel.com/en-us/forums/showthread.php?t=107141
As it's about the C++ class libraries it fits better to the compiler forum. Let's continue the discussion there.

I'll close the thread at hand.

Best regards,

Georg Zitzlsberger

Melden Sie sich an, um einen Kommentar zu hinterlassen.