C++ and SSE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Rokohl

    C++ and SSE

    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(alig n(16)) float c1data[12];
    }
    .....

    bool A::test(MyObjec t& obj){
    const __m128 e1x = _mm_load_ps(&c1 data[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(MyObjec t& obj){
    __declspec(alig n(16)) float c1data[12];
    const __m128 e1x = _mm_load_ps(&c1 data[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)
  • Victor Bazarov

    #2
    Re: C++ and SSE

    "Thomas Rokohl" <rokohl@raygina .de> wrote...[color=blue]
    > i have a little problem with sse vs. c++ and i can't find a solution.[/color]

    Doesn't seem like a language problem...
    [color=blue]
    > i want to use sse in my programm, so i start to use sse-commands in
    > vs6 + processor-pack5.[/color]

    Whatever "sse-commands" are, they have nothing to do with C++
    language, AFAICT.
    [color=blue]
    > 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(alig n(16)) float c1data[12];[/color]

    Whatever "__declspec(ali gn(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.publi c.vc.language.
    [color=blue]
    > }
    > ....
    >
    > bool A::test(MyObjec t& obj){
    > const __m128 e1x = _mm_load_ps(&c1 data[0]);[/color]

    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?
    [color=blue]
    > printf("after e1x = (%f, %f, %f, %f)\n",
    > e1x.m128_f32[0], e1x.m128_f32[1],
    > e1x.m128_f32[2], e1x.m128_f32[3]);[/color]

    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.
    [color=blue]
    > return false;
    > }
    >
    >
    > and the programm crashes, but print the write data out....[/color]

    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.
    [color=blue]
    >
    > and if i use lokal variables link
    >
    > bool A::test(MyObjec t& obj){
    > __declspec(alig n(16)) float c1data[12];
    > const __m128 e1x = _mm_load_ps(&c1 data[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 ;-) )![/color]

    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.
    [color=blue]
    >
    >
    >
    > so have someone an idea ?!?[/color]

    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.
    [color=blue]
    >
    >
    > thank you
    > Thomas Rokohl
    >
    > P.S (i'm not sure for the right topic but asm is also not correct)[/color]

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

    Victor


    Comment

    Working...