How much effort should you make to profit from using SSE?

Case 1

Say you have a small class:

class Point3D
{
private:
  float x,y,z;
public:
  operator+=()

  ...etc
};

Point3D &Point3D::operator+=(Point3D &other)
{
  this->x += other.x;
  this->y += other.y;
  this->z += other.z;
}

The naive use of SSE would simply replace these function bodies with a few built-in functions. But will we expect this to make a big difference? MMX is used to attract expensive government platforms IIRC, SSE or are they like other instructions? And even if there is no direct “use of SSE” overhead, will it move the values ​​to the SSE registers and come back again, will it really make it faster?

Case 2

Instead, you work with a less OO-based code base. Instead of an array / vector of Point3D objects, you simply have a large array of floats:

float coordinateData[NUM_POINTS*3];

void add(int i,int j) //yes it unsafe, no overlap check... example only
{
  for (int x=0;x<3;++x)
  {
    coordinateData[i*3+x] += coordinateData[j*3+x];
  }
}

How about using SSE here? It's better?

Finally

SSE , ?

+5
4

, , SSE ( SIMD):

  • 16 ( )

  • , SIMD

  • , , /

  • / (, strip-mining/tiling)

+6

, - , . , . 4 sse- . 4.

, sse- . .

+1

Gamasutra , SSE . " 1".

homepage.

+1

Case One , . , Point3D 16- .

You guessed it right, SSE is best suited for bulk operations, where they can give pretty good speed. Before you start using SSE functions, check what code the compiler is already generating. From experience I know that Visual Studio is very good at SSE optimization.

0
source

All Articles