This bugzilla service is closed. All entries have been migrated to
Bug 652 - Eigen won't vectorize on Intel C++ compiler with msvc 2010
Summary: Eigen won't vectorize on Intel C++ compiler with msvc 2010
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - vectorization (show other bugs)
Version: 3.2
Hardware: All All
: Normal Unknown
Assignee: Nobody
Depends on:
Reported: 2013-08-28 19:55 UTC by Duc Thang Ho
Modified: 2019-12-04 12:35 UTC (History)
2 users (show)

Fix vectorization for Intel Compiler (12.52 KB, application/octet-stream)
2013-08-28 19:55 UTC, Duc Thang Ho
no flags Details

Description Duc Thang Ho 2013-08-28 19:55:22 UTC
Created attachment 377 [details]
Fix vectorization for Intel Compiler

I am using Eigen 3.2 using Intel C++ Composer XE 2013 (the latest version) with MSVC 2010. I test a very simple Eigen program, which basically like this:

Eigen::VectorXf aa(LEN);
 Eigen::VectorXf bb(LEN);
for (int i =0;i<aa.size();++i){
	aa[i] = i;
	bb[i] = i;
aa += bb;

The program is run with /O2, /Ob1, with SSE enabled. SSE2, SSE3, SSE 4.1, SSE 4.2 and even AVX have been tested. However, the program produced the same assembly code with no SSE vectorization. After a careful investigation of Eigen source code, I found the problem in the following lines in Eigen/Core

#ifdef _MSC_VER
  #include <malloc.h> // for _aligned_malloc -- need it regardless of whether vectorization is enabled
  #if (_MSC_VER >= 1500) // 2008 or later
    // Remember that usage of defined() in a #define is undefined by the standard.
    // a user reported that in 64-bit mode, MSVC doesn't care to define _M_IX86_FP.
    #if (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(_M_X64)
      #define EIGEN_SSE2_ON_MSVC_2008_OR_LATER
  // Remember that usage of defined() in a #define is undefined by the standard
  #if (defined __SSE2__) && ( (!defined __GNUC__) || (defined __INTEL_COMPILER) || EIGEN_GNUC_AT_LEAST(4,2) )



    // Defines symbols for compile-time detection of which instructions are
    // used.
    // EIGEN_VECTORIZE_YY is defined if and only if the instruction set YY is used

The problem is Eigen assumed that only MSVC defines _MSC_VER and all other compilers do not. The fact is Intel C++ also defines _MSC_VER (but not _M_IX86_FP). As a result, on Intel C++ compiler, the macro EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC will never be defined as expected (and neither is EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC). Therefore, none of the EIGEN_VECTORIZE* macros necessary for vectorization are defined. A very simple fix that I have used is to replace the line (see attachment)



#if defined(__INTEL_COMPILER) || defined (EIGEN_SSE2_ON_NON_MSVC_BUT_NOT_OLD_GCC) || defined(EIGEN_SSE2_ON_MSVC_2008_OR_LATER)

I suspect that every other versions of Eigen also suffer from this bug. Please acknowledge and fix
Comment 1 Nobody 2019-12-04 12:35:52 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.