none
OpenMP compiler bug, only x64 debug non optimized RRS feed

  • Question

  • Hi everyone,

    i tried to port some parallel SSE code to OpenMP (before parallelization was done using win32 thread API). Unit test work fine for win32 debug and release configuration, but while x64 release works fine, x64 debug failes randomly. During debugging i found out, that this problem also can be reproduced without using SSE.

    The bug can be reproduced unter the following conditions

    • OpenMP for loop
    • Instance of a class is passed by value to a function
    • Class size > 8 byte (so > size of a pointer, but why)
    • Class has no copy constructor, so compiler generates its own one

    If i pass by reference or implement the copy constructor or switch to single threaded everything works fine.

    I tried the code on vs2005, vs2010 and vs2012 with always the same result. has anyone an idea whats wrong?

    Here is example code:

    #include <iostream>
    #include <omp.h>

    #define SIZE 4 // code works with 1 and 2

    struct S
    {
     //S()
     //{
     //}
     //S( const S &other )
     //{
     // for ( int i = 0; i < SIZE; ++i )
     // {
     //  data[ i ] = other.data[ i ];
     // }
     //}
     int data[ SIZE ];
    };

    S foo( S s )
    //S foo( const S &s )
    {
     return s;
    }

    int main( int argc, char **argv )
    {
     #pragma omp parallel for
     for ( int i = 0; i < 100000; ++i )
     {
      S dummy;
      for ( int j = 0; j < SIZE; ++j )
      {
       dummy.data[ j ] = i;
      }

      dummy = foo( dummy );

      for ( int j = 0; j < SIZE; ++j )
      {
       if ( dummy.data[ j ] != i )
       {
        std::cout << ".";
        break;
       }
      }
     }

     return 0;
    }

    Thanks,

    Markus


    • Edited by Markus_Rehak Thursday, September 13, 2012 7:59 AM
    • Moved by Jesse Jiang Friday, September 14, 2012 2:43 AM (From:Visual C++ General)
    Thursday, September 13, 2012 7:57 AM

Answers

All replies