This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Unaligned array assertion failure when using openmp

Tags: None
(comma "," separated)
michaelengelmann
Registered Member
Posts
2
Karma
0
Hi,

I am trying to implement multithreading in a program I've written, but I've run into an issue I can't resolve. The program works with no problems when run sequentially, but it causes unaligned array assertion failures when I try to parallelize a section in a for loop. I think I've traced it down to the declaration of quaternions in a function within the loop. The following test code demonstrates the issue I'm seeing. Everything is fine in the master thread, but all of the other threads have the assertion failure. Oddly, it seems to also happen with an Array of size 4, but not an Array of size 3. I'm probably missing something obvious. Any suggestions would be greatly appreciated,

Best Regards,
Mike

Code: Select all
#define EIGEN_DONT_PARALLELIZE

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

using namespace std;
using namespace Eigen;

int main() {
   initParallel();

   #pragma omp parallel for
   for(int n = 0; n < omp_get_max_threads();n++){

      // This works
      Array<float,3,1> test1 = Array<float,3,1>::Zero();
      #pragma omp critical
      cout << "Thread #: " << omp_get_thread_num() << ", test array 1:" << endl << test1 << endl;

      Array<float,4,1> test2 = Array<float,4,1>::Ones();
      #pragma omp critical
      cout << "Thread #: " << omp_get_thread_num() << ", test array 2:" << endl << test2 << endl;
      /* Causes Aligned Array Assertion Failure on all but master thread
       * Expression: (reinterpret_cast<size_t>(eigen_unaligned_array_assert_workaround_gcc47(array)) & (15)) == 0 && "this assertion is explained here: " "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" " **** READ THIS WEB PAGE !!! ****"
       * Assertion failed!
       */

      Quaternionf testQ(1,0,0,0);
      #pragma omp critical
      cout << "Thread #: " << omp_get_thread_num() << ", test quaternion: " << endl << testQ.coeffs() << endl;
      /* Causes Aligned Array Assertion Failure on all but master thread
       * Expression: (reinterpret_cast<size_t>(eigen_unaligned_array_assert_workaround_gcc47(array)) & (15)) == 0 && "this assertion is explained here: " "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" " **** READ THIS WEB PAGE !!! ****"
       * Assertion failed!
       */
   }

   return 0;
}
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Works fine here (OSX and Linux). This is probably because the alignment of the stack is not preserved within the generated threads. I guess You are running on windows? Then you can either disable static alignment globally with EIGEN_DONT_ALIGN_STATICALLY or locally using Array<float,4,1,DontAlign>, or Quaternion<float,DontAlign> types. This will disable vectorization for these objects.
michaelengelmann
Registered Member
Posts
2
Karma
0
Thanks for the quick reply!

Yes, I am using windows. I appreciate the advice.

Best Regards,
Mike


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft