Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Vectorized code causes SIGBUS/SIGSEGV (icpc 14.0.1, Mac)

Evgeny_E_
Beginner
456 Views

I have experienced my program crash because the compiler generates vectorized code where I think it shouldn't. Invoking the code with unaligned input causes SIGBUS or SIGSEGV. One needs to obtain the source code of the Armadillo C++ library version 4.100.1 (http://arma.sourceforge.net/download.html) to reproduce the problem.

Here is the program:

#include <armadillo>
#include <iostream>

int main() {
    arma::Mat<double> A(25, 25);
    std::cout << A.colptr(0) << std::endl << A.colptr(1) << std::endl;
    A.col(1) *= 2.0; // crash here
    return 0;
}

I am using Intel Composer XE 2013-SP1 [icpc (ICC) 14.0.1 20131010] on Mac OS X 10.8.5 with XCode 3.2.1 to compile like so:

$ icpc -mkl -Iarmadillo-4.100.1/include arma_bug.cpp -o arma_bug -vec-report=6
arma_bug.cpp(7): (col. 14) remark: vectorization support: reference dest_45828 has aligned access
arma_bug.cpp(7): (col. 14) remark: vectorization support: reference dest_45828 has aligned access
arma_bug.cpp(7): (col. 14) remark: vectorization support: unroll factor set to 4
arma_bug.cpp(7): (col. 14) remark: LOOP WAS VECTORIZED
arma_bug.cpp(7): (col. 14) remark: vectorization support: reference dest_45828 has aligned access
arma_bug.cpp(7): (col. 14) remark: vectorization support: reference dest_45828 has aligned access
arma_bug.cpp(7): (col. 14) remark: vectorization support: unroll factor set to 4
arma_bug.cpp(7): (col. 14) remark: LOOP WAS VECTORIZED

The crash occurs when invoking a loop in the Armadillo library at arrayops_meat.hpp:839.

    {
    for(uword i=0; i<n_elem; ++i)
      {
      dest *= val;
      }
    }

The compiler makes an assumption that it is safe to vectorize the loop, which is wrong: the dest array can be unaligned. This unaligned access causes the crash. Placing #pragma novector before this loop solves the problem.

I am hoping that someone from Intel could reproduce this and confirm that it is a compiler issue.

0 Kudos
5 Replies
Feilong_H_Intel
Employee
456 Views

Hi Evgeny,

I've reproduced this problem.  Will look into it tomorrow.

Thanks.

0 Kudos
Feilong_H_Intel
Employee
455 Views

Evgeny,

I've entered this issue to our problem-tracking database.  I'll let you know when I get an update from engineering team.

Thanks.

0 Kudos
Evgeny_E_
Beginner
455 Views

To follow up, is this by any chance issue DPD200254088 fixed in Composer 2015 beta update 1?

0 Kudos
Feilong_H_Intel
Employee
455 Views

Evgeny,

From what I see, the fix is expected to be in beta update 1.

0 Kudos
Feilong_H_Intel
Employee
455 Views

15.0 compiler contains the fix for this issue.  FYI.

0 Kudos
Reply