- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#include "stdafx.h"
#include
#include
#include
#include
#include
#include
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int j;
__m128 s0, s1, s2, s3;
__declspec(align (16))float block[4][4]={1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4};
for(j = 0; j < 16; j += 4)
{
__m128 v = _mm_load_ps(block
__m128 w = _mm_load_ps(block[j+1]);
__m128 x = _mm_load_ps(block[j+2]);
__m128 y = _mm_load_ps(block[j+3]);
s0 = _mm_add_ps(v,y);
s3 = _mm_sub_ps(v,y);
s1 = _mm_add_ps(w,x);
s2 = _mm_sub_ps(w,x);
}
cout << s0 << endl;//error C2679: binary '<<' : no operator found which takes a right-hand operand of type '__m128' (or there is no acceptable conversion)
return 0;
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ostream & operator << (ostream &out, const __m128 &m)
{
float v[4]; _mm_storeu_ps(v,m);
out << v[3] << " | " << v[2] << " | " << v[1] << " | " << v[0];
return out;
}
it's a simple, albeit valuable tool for learning these things or to debug your code
btw there is a bug in your loop, it should be :
for (int j=0; j<4; j++)
isn't it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#include "stdafx.h"
#include
#include
#include
#include
#include
#include
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int j;
__m128 s0, s1, s2, s3;
__declspec(align (16))float block[4][4]={1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4};
for(j = 0; j < 16; j += 4)
{
__m128 v = _mm_load_ps(block
__m128 w = _mm_load_ps(block[j+1]);
__m128 x = _mm_load_ps(block[j+2]);
__m128 y = _mm_load_ps(block[j+3]);
s0 = _mm_add_ps(v,y);
s3 = _mm_sub_ps(v,y);
s1 = _mm_add_ps(w,x);
s2 = _mm_sub_ps(w,x);
}
cout << s0 << endl;//error C2679: binary '<<' : no operator found which takes a right-hand operand of type '__m128' (or there is no acceptable conversion)
return 0;
}
{
float v[4]; _mm_storeu_ps(v,m);
out << v[3] << " | " << v[2] << " | " << v[1] << " | " << v[0];
return out;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
after puting the output codes i now get the error
#include "stdafx.h"
#include
#include
#include
#include
#include
#include
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int j;
__m128 s0, s1, s2, s3;
__declspec(align (16))float block[4][4]={1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4};
for(j = 0; j < 16; j += 4)
{
__m128 v = _mm_load_ps(block
__m128 w = _mm_load_ps(block[j+1]);
__m128 x = _mm_load_ps(block[j+2]);
__m128 y = _mm_load_ps(block[j+3]);
s0 = _mm_add_ps(v,y);
s3 = _mm_sub_ps(v,y);
s1 = _mm_add_ps(w,x);
s2 = _mm_sub_ps(w,x);
}
ostream & operator << (ostream &out, const __m128 &m)
{ //error C2601: 'operator <<' : local function definitions are illegal
float v[4]; _mm_storeu_ps(v,m);
out << v[3] << " | " << v[2] << " | " << v[1] << " | " << v[0];
return out;
}
}
please i want to see the output s0,s1,s2 and s3. help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Then you can write thinks like : cout << "s0 = " << s0 << " s1 = " << s1 << endl;
Please also note my fix for your buggyloopcontrol in my old post

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page