C++ and SSE

T

Thomas Rokohl

hi,

i have a little problem with sse vs. c++ and i can't find a solution.
i want to use sse in my programm, so i start to use sse-commands in
vs6 + processor-pack5.

i replace some functions in my code with sse command's, so i modifies
an object like this:

class A : B {
....
public:
....
virtual bool test(MyObject& obj);
__declspec(align(16)) float c1data[12];
}
.....

bool A::test(MyObject& obj){
const __m128 e1x = _mm_load_ps(&c1data[0]);
printf("after e1x = (%f, %f, %f, %f)\n",
e1x.m128_f32[0], e1x.m128_f32[1],
e1x.m128_f32[2], e1x.m128_f32[3]);
return false;
}


and the programm crashes, but print the write data out....

and if i use lokal variables link

bool A::test(MyObject& obj){
__declspec(align(16)) float c1data[12];
const __m128 e1x = _mm_load_ps(&c1data[0]);
printf("after e1x = (%f, %f, %f, %f)\n",
e1x.m128_f32[0], e1x.m128_f32[1],
e1x.m128_f32[2], e1x.m128_f32[3]);
return false;
}

it works( with wrong values ;-) )!



so have someone an idea ?!?


thank you
Thomas Rokohl

P.S (i'm not sure for the right topic but asm is also not correct)
 
V

Victor Bazarov

Thomas Rokohl said:
i have a little problem with sse vs. c++ and i can't find a solution.

Doesn't seem like a language problem...
i want to use sse in my programm, so i start to use sse-commands in
vs6 + processor-pack5.

Whatever "sse-commands" are, they have nothing to do with C++
language, AFAICT.
i replace some functions in my code with sse command's, so i modifies
an object like this:

class A : B {
...
public:
...
virtual bool test(MyObject& obj);
__declspec(align(16)) float c1data[12];

Whatever "__declspec(align(16))" does, it's not standard C++. If
you think it might be screwing things up for you, ask in a Visual
C++ newsgroup: microsoft.public.vc.language.
}
....

bool A::test(MyObject& obj){
const __m128 e1x = _mm_load_ps(&c1data[0]);

Are you sure that 12 floats is enough for this function (_mm_load_ps)
to do its work? Could it be that it needs more than 12?
printf("after e1x = (%f, %f, %f, %f)\n",
e1x.m128_f32[0], e1x.m128_f32[1],
e1x.m128_f32[2], e1x.m128_f32[3]);

Since __m128 is not a standard type, anything related to it would
be unknown here unless you show how it is defined. IOW, it is unclear
that it is allowed to use the 'm128_f32' member of an object of that
type in a 'printf' function.
return false;
}


and the programm crashes, but print the write data out....

It is quite possible that the program crashes due to some COMPLETELY
unrelated problem. Since you didn't post the _entire_ program, it
is rather impossible to divine.
and if i use lokal variables link

bool A::test(MyObject& obj){
__declspec(align(16)) float c1data[12];
const __m128 e1x = _mm_load_ps(&c1data[0]);
printf("after e1x = (%f, %f, %f, %f)\n",
e1x.m128_f32[0], e1x.m128_f32[1],
e1x.m128_f32[2], e1x.m128_f32[3]);
return false;
}

it works( with wrong values ;-) )!

If the values are wrong, how can you be sure that "it works"? It
probably doesn't, and the fact that the values are wrong is just
an indicator that it doesn't work.
so have someone an idea ?!?

The code you posted is so small that it requires too many assumptions
to understand what it is supposed to do. Depending on them, the code
can be judged OK OOH or totally screwed OTOH. If you still think you
have a C++ _language_ problem, read FAQ 5.8 and follow its advice.
If there is a slim chance that (since the program compiles and runs)
it's a logical error (wrong function used or too few array elements in
the data), you're mostly on your own. Read the requirements to the
'_mm_load_ps' function more carefully.
thank you
Thomas Rokohl

P.S (i'm not sure for the right topic but asm is also not correct)

I am not sure either. Have you tried a newsgroup where SSE (whatever
that is) is on topic?

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top