我尝试使用PGI的C ++编译器编译包含Eigen标头的代码,但得到以下错误:
"/opt/local/include/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h", line 413:
error: more than one instance of overloaded function "_mm_prefetch"
matches the argument list:
function "_mm_prefetch(const char *, int)"
function "_mm_prefetch(const void *, _mm_hint)"
argument types are: (const char *, _mm_hint)
template<> EIGEN_STRONG_INLINE void prefetch<float>(const float* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
^
"/opt/local/include/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h", line 414:
error: more than one instance of overloaded function "_mm_prefetch"
matches the argument list:
function "_mm_prefetch(const char *, int)"
function "_mm_prefetch(const void *, _mm_hint)"
argument types are: (const char *, _mm_hint)
template<> EIGEN_STRONG_INLINE void prefetch<double>(const double* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
^
"/opt/local/include/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h", line 415:
error: more than one instance of overloaded function "_mm_prefetch"
matches the argument list:
function "_mm_prefetch(const char *, int)"
function "_mm_prefetch(const void *, _mm_hint)"
argument types are: (const char *, _mm_hint)
template<> EIGEN_STRONG_INLINE void prefetch<int>(const int* addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
^
"/opt/local/include/eigen3/Eigen/src/Core/arch/SSE/Complex.h", line 131: error:
more than one instance of overloaded function "_mm_prefetch" matches
the argument list:
function "_mm_prefetch(const char *, int)"
function "_mm_prefetch(const void *, _mm_hint)"
argument types are: (const char *, _mm_hint)
template<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> * addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
^
"/opt/local/include/eigen3/Eigen/src/Core/arch/SSE/Complex.h", line 343: error:
more than one instance of overloaded function "_mm_prefetch" matches
the argument list:
function "_mm_prefetch(const char *, int)"
function "_mm_prefetch(const void *, _mm_hint)"
argument types are: (const char *, _mm_hint)
template<> EIGEN_STRONG_INLINE void prefetch<std::complex<double> >(const std::complex<double> * addr) { _mm_prefetch((const char*)(addr), _MM_HINT_T0); }
^
5 errors detected in the compilation of "/Users/wooden/CLionProjects/EigenTest/main.cpp".
make[2]: *** [CMakeFiles/EigenTest.dir/main.cpp.o] Error 2
make[1]: *** [CMakeFiles/EigenTest.dir/all] Error 2
make: *** [all] Error 2
只要包含Eigen标头,无论编译代码如何,我都会得到相同的错误。更具体地说,我包括以下内容:
#include <Eigen/Eigen>
尝试编写一个简单的&#34; Hello World&#34;程序。除了Eigen的指令外,CMakeLists.txt也是准系统。
cmake_minimum_required(VERSION 3.10)
project(EigenTest)
set(CMAKE_CXX_STANDARD 11)
add_executable(EigenTest main.cpp)
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
target_link_libraries (EigenTest Eigen3::Eigen)
我应该注意到我在macOS Sierra(10.12.6)上,并且我已经尝试了PGI的v17.10和v18.4。没有特殊标志用于编译。安装的Eigen软件包是MacPorts上最新的软件包(eigen3 3.3.4)。
我之前已经非常轻易地使用了Eigen,并且GCC的一切正常。我之前也没有使用PGI的编译器。我试图同时使用两者的原因是我需要在使用Eigen的代码的某些部分使用OpenACC编译指示。
任何帮助我走向正确方向的帮助都将受到赞赏。
将addr
投放到const void*
而不是const char*
,错误的上述行(或评论所说的行)在Eigen的源文件中,我不会&#39 ; t再次出现编译错误。我可以从Eigen获得基本功能,但更复杂的代码无法成功链接。产生以下错误:
Undefined symbols for architecture x86_64:
"__ZN98_INTERNAL_76__Users_wooden_CLionProjects_MLProject_src_Classification_LogisticRegression_cpp_c51a32f316_mm_castpd_si128E7__m128d", referenced from:
__ZN5Eigen8internal29general_matrix_vector_productIldNS0_22const_blas_data_mapperIdlLi1EEELi1ELb0EdNS2_IdlLi0EEELb0ELi0EE3runEllRKS3_RKS4_Pdld in LogisticRegression.cpp.o
__ZN5Eigen8internal11palign_implILi1E7__m128dE3runERS2_RKS2_ in LogisticRegression.cpp.o
__ZN5Eigen8internal6palignILi1E7__m128dEEvRT0_RKS3_ in LogisticRegression.cpp.o
"__ZN98_INTERNAL_76__Users_wooden_CLionProjects_MLProject_src_Classification_LogisticRegression_cpp_c51a32f316_mm_castsi128_pdE7__m128i", referenced from:
__ZN5Eigen8internal29general_matrix_vector_productIldNS0_22const_blas_data_mapperIdlLi1EEELi1ELb0EdNS2_IdlLi0EEELb0ELi0EE3runEllRKS3_RKS4_Pdld in LogisticRegression.cpp.o
__ZN5Eigen8internal11palign_implILi1E7__m128dE3runERS2_RKS2_ in LogisticRegression.cpp.o
__ZN5Eigen8internal4pexpI7__m128dEET_RKS3_ in LogisticRegression.cpp.o
__ZN5Eigen8internal6palignILi1E7__m128dEEvRT0_RKS3_ in LogisticRegression.cpp.o
ld: symbol(s) not found for architecture x86_64
make[2]: *** [MLProject] Error 2
make[1]: *** [CMakeFiles/MLProject.dir/all] Error 2
make: *** [all] Error 2
按照@chtz对评论的建议使用-DEIGEN_DONT_VECTORIZE
,这会禁用Eigen的内置向量化,项目代码可以编译,链接并成功执行。然而,这产生了一个主要问题,因为Eigen首先用于其矢量化线性代数实现。
至于编译错误,它可能与PGI对@ggael的_mm_castpd_si128
类型的支持有关。
总而言之,似乎与PGI的C ++编译器的Eigen兼容性充其量只是部分。