Original Post
Hi, recently I noticed that my program actually slows down when compiled with SIMD optimization enabled on VC++ 2005. I bagan to test my matrix/vector libray and with SIMD enabled performance fall down up to 30% for matrix-matrix multiplication. AFAIK matrix mult should be considerably faster when calculations are done in parallel, but it is instead way slower. Do someone know if this is a known bug in VC++, if there are code setups to be avoided in order to gat advantage of SIMD optimization or if there is something wrong in my code? This is my matrix class (and the multiplication method):
//In the form of ROWxCOL
class matrix
{
public:
real mat[4][4];
public:
matrix() { Identity(); }
matrix(const matrix &src)
{ memcpy(this, &src, 16 * sizeof(real)); }
.
.
.
}
const matrix matrix::operator * (const matrix &m) const
{
matrix t;
register int i;
for(i = 0; i < 4; ++i)
{
t.mat[0] = mat[0]*m.mat[0][0] + mat[1]*m.mat[1][0] +
mat[2]*m.mat[2][0] + mat[3]*m.mat[3][0];
t.mat[1] = mat[0]*m.mat[0][1] + mat[1]*m.mat[1][1] +
mat[2]*m.mat[2][1] + mat[3]*m.mat[3][1];
t.mat[2] = mat[0]*m.mat[0][2] + mat[1]*m.mat[1][2] +
mat[2]*m.mat[2][2] + mat[3]*m.mat[3][2];
t.mat[3] = mat[0]*m.mat[0][3] + mat[1]*m.mat[1][3] +
mat[2]*m.mat[2][3] + mat[3]*m.mat[3][3];
}
return t;
}