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

gcc ubsan problem (Col/Full)PivHouseholderQR on MatrixXf

Tags: None
(comma "," separated)
kavvak
Registered Member
Posts
9
Karma
0
Dear All,

The following code:
Code: Select all
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <fstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <vector>
#include <random>
#include <Eigen/QR>

using namespace std;
using namespace Eigen;
using Eigen::MatrixXf;
using Eigen::VectorXf;
                extern "C"{
   void testPack(
         int* n,      //1
         int* p,      //2
         float* xi,
         int* testo
      ){
      const int nin=*n,pin=*p,testn=*testo;
      MatrixXf x=MatrixXf::Random(nin,pin);;   
      ColPivHouseholderQR<MatrixXf> QR(x);
               }
}

(Eigen 3.2.5)
Triggers many gcc-ubsan warnings of the form:

Code: Select all
/usr/lib/gcc/x86_64-linux-gnu/5/include/emmintrin.h:140:21: runtime error: load of misaligned address 0x61a00001fe84 for type 'const double', which requires 8 byte alignment
0x61a00001fe84: note: pointer points here
  34 dd 35 bf 43 86 83 3e  cc 9c 7c be 1b f1 b1 be  46 9d 73 bf fe 6e 38 bd  80 ef 48 bf 1f 7f d5 bf
               



But if I use

Code: Select all
   
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <fstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <vector>
#include <random>
#include <Eigen/QR>

using namespace std;
using namespace Eigen;
using Eigen::MatrixXd;
using Eigen::VectorXd;
extern "C"{
   void testPack2(
         int* n,      //1
         int* p,      //2
         double* xi,
         int* testo
      ){
                const int nin=*n,pin=*p,testn=*testo;
      MatrixXd x=MatrixXd::Random(nin,pin);
      ColPivHouseholderQR<MatrixXd> QR(x);
     }
}


gcc-ubsan doesn't complain any more. Unfortunatly, I do not control the version of Eigen this
is to run on (that will always trail the latest Eigen version by several months) and would prefer to run the float version of the code. I also get a similar warning
when I am calling FullPivHouseholderQR/HouseholderQR instead of ColPivHouseholderQR.

Thanks in advance,
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
gcc-ubsan is wrong because the intrinsic _mm_load_sd does not require any special alignment. Nevertheless, in the devel branch I've remove this trick a few days ago because it is not useful anymore on todays CPUs. We could do the same in the 3.2 branch for the 3.2.7 version. In the meantime, you can just ignore this harmless warning.
kavvak
Registered Member
Posts
9
Karma
0
Ok, thanks for the info!


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar