Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.

Problem compiling with armadillo

Daniel_H
Beginner
350 Views

Hello all,

I'm using aramadillo (http://arma.sourceforge.net) to elegantly manipulate arrays. All was working well till the last version (4.650.2).
Now it fails compiling with icpc (15.0.1, Linux) pretending there is a resolution problem.  The snippet code still compile fine with g++(4.9.2) and also clang (3.5) showing no error or warning.
I've filed a bug to armadillo team, but they told me it is an Intel issue.

I would be happy if any solution exists to solve this issue as I both need using armadillo and the intel compiler for speed and efficency.

Thanks in advance for any answer.

Daniel

Here is the code:

#define ARMA_DONT_USE_WRAPPER
#define ARMA_DONT_USE_HDF5
#define ARMA_DONT_USE_BLAS
#include <armadillo>

using namespace std;
using namespace arma;

#define LEN 50

int main()
{
 mat::fixed<LEN,9> beta;
 vec::fixed<LEN> alpha;
 mat::fixed<LEN,9> ash1;

 ash1=repmat(alpha,1,9)-beta;

 return(0);
}

and the compilation error:

~ $ icpc -I armadillo-4.650.2/include/  bugarma.cpp 
bugarma.cpp(17): error: more than one operator "=" matches these operands:
            function template "const arma::Mat<double> &arma::Mat<eT>::operator=(const arma::eGlue<T1, T2, eglue_type> &) [with eT=double]"
            function template "const arma::Mat<double> &arma::Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const arma::eGlue<T1, T2, eglue_type> &) [with eT=double, fixed_n_rows=50U, fixed_n_cols=9U]"
            operand types are: arma::Mat<double>::fixed<50U, 9U> = const arma::eGlue<arma::Op<arma::Mat<double>, arma::op_repmat>, arma::Mat<double>::fixed<50U, 9U>, arma::eglue_minus>
   ash1=repmat(alpha,1,9)-beta;
       ^
compilation aborted for bugarma.cpp (code 2)
0 Kudos
8 Replies
Shenghong_G_Intel
350 Views

I've reproduced the issue and will submit to dev team to fix. I do not have a workaround as of now, I'll look into details and maybe ask developer whether a workaround can be provided.

Thanks,

Shenghong

Daniel_H
Beginner
350 Views

Hello Shenghong,

Sorry to bump this thread, but did you by any chance got a workaround or patch so far? I'm stuck on using g++, and missing some speed improvements from icpc.

Thanks,

Daniel

Roberto_N_
Beginner
350 Views

Try to use the member function .eval(), which in words of the API Reference "explicitly forces the evaluation of a delayed expression and outputs a matrix" (armadillo 3.2 or greater). For example,

#include <armadillo> //using armadillo5.000.2

using namespace std;
using namespace arma;

int main()
{
  complex<double> c = 2.0;
  cx_mat33 A = randu<cx_mat>(3,3);

  A = (A*c).eval();  
  return 0;
}

I tested this code with icpc and g++-4.8.     On the other hand, icpc will fail if I use A = A*c instead, where I get the following error:

icpc program.cc -o program -larmadillo
program.cc(8): error: more than one operator "=" matches these operands:
            function template "const arma::Mat<arma::cx_double> &arma::Mat<eT>::operator=(const arma::eOp<T1, eop_type> &) [with eT=arma::cx_double]"
            function template "const arma::Mat<arma::cx_double> &arma::Mat<eT>::fixed<fixed_n_rows, fixed_n_cols>::operator=(const arma::eOp<T1, eop_type> &) [with eT=arma::cx_double, fixed_n_rows=3U, fixed_n_cols=3U]"
            operand types are: arma::cx_mat33 = const arma::eOp<arma::cx_mat33, arma::eop_scalar_times>
    A = (A*c);
      ^

Hope this helps,

Roberto Navarro.

Daniel_H
Beginner
350 Views

Hello Roberto,

Thanks a bunch for that solution. It will save me until a regular fix will be found.

Daniel

Max_G_1
Beginner
350 Views
Hi, I just ran into the same issue with Armadillo and the Intel compiler. Thanks for sharing the work around, Roberto! Is there any progress on a fix of this issue? Max
Daniel_H
Beginner
350 Views

Hello all,

Conrad Sanderson, one of the authors of armadillo, wrote a workaround (thanks a lot :-) in the new release (5.100.2) of the library. This avoids using the eval trick, which apparently has some potential performance issues.

Daniel

Shenghong_G_Intel
350 Views

Hi Max, Daniel,

This issue is fixed in latest 2015 U3 release. Please upgrade your compiler and let me know if it is not fixed for you.

$ source /opt/intel/composer_xe_2015.3.187/bin/compilervars.sh intel64
$ icc temp.cpp -I armadillo-4.650.2/include
$ ./a.out
$

Thanks,

Shenghong

Daniel_H
Beginner
350 Views

Thanks Shenghong,

Unfortunately my license seems having expired and I cannot upgrade. My institution mainframe set-up is out of my control but I'll ask if they plan to upgrade soon. Otherwise I'll investigate on buying a local license.

Daniel

Reply