- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
I would like to ask somebody to tell me, why is my SSE code for vector and matrix operations is slower. I must do something wrong, but dont know what. My vector addition for example:
data type:
typedef union
{
__m128 data;
float elements[4];
} vector4d;
{
__m128 data;
float elements[4];
} vector4d;
with SSE (using intrinsics):
inline vector4dadd(vector4d a, vector4d b)
{
vector4d c;
c.data = _mm_add_ps(a.data, b.data);
return c;
};
{
vector4d c;
c.data = _mm_add_ps(a.data, b.data);
return c;
};
without SSE:
inline vector4d add_sisd(vector4d a, vector4d b)
{
return set(a.elements[0]+b.elements[0],a.elements[1]+b.elements[1],a.elements[2]+b.elements[2],0);
};
{
return set(a.elements[0]+b.elements[0],a.elements[1]+b.elements[1],a.elements[2]+b.elements[2],0);
};
(set() simply returnsa vector4d with theparameter values)
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Without more information, we're simply guessing. For example, you might be performing scalar operations on the components before or after. Remember also that the compiler would unroll at least by 8 in order to use mm_add_ps in pairs, when performing automatic vectorization. We don't even know which compiler you're using.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No other operations are performed. i just put each function into a loop and measured the time the computation takes.
First i tried in debug mode, without any optimization. The sisd's time was the 50% of the simd version
With all optimizations on, it was 30% (3 times faster!!!!)
I dont know the compiler version. I have Visual C++ 6.0 with service pack 5 and Processor Pack (for SP5), with default compiler settings.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page