2010-07-20 56 views
1

在我的項目我使用Eigen C++庫的線性代數和只有當我打開矢量化標誌(mfpu =霓虹燈-mfloat-abi = softfp)對於ARM NEON,我得到編譯器錯誤。我無法理解發生了什麼問題。我是否需要在Eigen Library中爲ARM NEON啓用任何預處理器指令?編譯時使用Eigen,線性代數的C++模板庫的項目,使用Eigen


的main.c

#include<iostream> 
#include <Eigen/Core> 

// import most common Eigen types 
using namespace Eigen; 

int main(int, char *[]) 
{ 
    Matrix4f m3; 
    m3 << 1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 0, 0, 0, 0; 
    Matrix4f m4; 

    asm("#begins here"); 
    m4 = m3*m3; 
    asm("#ends here"); 

    std::cout << "m3\n" << m3 << "\nm4:\n" 
     << m4 << std::endl; 

    std::cout << "DONE!!"; 
} 

的makefile

main: main.cpp 
    g++ -mfpu=neon -mfloat-abi=softfp -I /home/ubuntu/Documents/eigen/ main.cpp -o main 

錯誤

[email protected]:~/Documents/mat_mul$ make 
g++ -mfpu=neon -mfloat-abi=softfp -I /home/ubuntu/Documents/eigen/ main.cpp -o main 
In file included from /home/ubuntu/Documents/eigen/Eigen/Core:227, 
       from main.cpp:2: 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h: In function ‘typename Eigen::ei_packet_traits<T>::type Eigen::ei_pload(const Scalar*) [with Scalar = float]’: 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h:163: error: cannot convert ‘const float*’ to ‘const float32_t*’ for argument ‘1’ to ‘__builtin_neon_sf __vector__ vld1q_f32(const float32_t*)’ 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h: In function ‘typename Eigen::ei_packet_traits<T>::type Eigen::ei_ploadu(const Scalar*) [with Scalar = float]’: 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h:166: error: cannot convert ‘const float*’ to ‘const float32_t*’ for argument ‘1’ to ‘__builtin_neon_sf __vector__ vld1q_f32(const float32_t*)’ 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h: In function ‘void Eigen::ei_pstore(Scalar*, const Packet&) [with Scalar = float, Packet = __builtin_neon_sf __vector__]’: 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h:169: error: cannot convert ‘float*’ to ‘float32_t*’ for argument ‘1’ to ‘void vst1q_f32(float32_t*, __builtin_neon_sf __vector__)’ 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h: In function ‘void Eigen::ei_pstoreu(Scalar*, const Packet&) [with Scalar = float, Packet = __builtin_neon_sf __vector__]’: 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h:172: error: cannot convert ‘float*’ to ‘float32_t*’ for argument ‘1’ to ‘void vst1q_f32(float32_t*, __builtin_neon_sf __vector__)’ 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h: In function ‘typename Eigen::ei_unpacket_traits<T>::type Eigen::ei_pfirst(const Packet&) [with Packet = __builtin_neon_sf __vector__]’: 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h:179: error: cannot convert ‘float*’ to ‘float32_t*’ for argument ‘1’ to ‘void vst1q_f32(float32_t*, __builtin_neon_sf __vector__)’ 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h: In function ‘typename Eigen::ei_unpacket_traits<T>::type Eigen::ei_predux(const Packet&) [with Packet = __builtin_neon_sf __vector__]’: 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h:216: error: cannot convert ‘float*’ to ‘float32_t*’ for argument ‘1’ to ‘void vst1_f32(float32_t*, __builtin_neon_sf __vector__)’ 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h: In function ‘typename Eigen::ei_unpacket_traits<T>::type Eigen::ei_predux_mul(const Packet&) [with Packet = __builtin_neon_sf __vector__]’: 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h:289: error: cannot convert ‘float*’ to ‘float32_t*’ for argument ‘1’ to ‘void vst1_f32(float32_t*, __builtin_neon_sf __vector__)’ 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h: In function ‘typename Eigen::ei_unpacket_traits<T>::type Eigen::ei_predux_min(const Packet&) [with Packet = __builtin_neon_sf __vector__]’: 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h:320: error: cannot convert ‘float*’ to ‘float32_t*’ for argument ‘1’ to ‘void vst1_f32(float32_t*, __builtin_neon_sf __vector__)’ 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h: In function ‘typename Eigen::ei_unpacket_traits<T>::type Eigen::ei_predux_max(const Packet&) [with Packet = __builtin_neon_sf __vector__]’: 
/home/ubuntu/Documents/eigen/Eigen/src/Core/arch/NEON/PacketMath.h:348: error: cannot convert ‘float*’ to ‘float32_t*’ for argument ‘1’ to ‘void vst1_f32(float32_t*, __builtin_neon_sf __vector__)’ 
make: *** [main] Error 1 
[email protected]:~/Documents/mat_mul$ 

錯誤我得到了我使用的代碼的Sourcery工具鏈

[email protected]:~/Documents/CodeSourcery_WS/Test_Eigen$ make 
/home/ubuntu/CodeSourcery/Sourcery_G++/bin/arm-none-linux-gnueabi-c++ -mfpu=neon -mfloat-abi=softfp -I /home/ubuntu/Documents/eigen/ main.cpp -o main 
In file included from main.cpp:1: 
/home/ubuntu/CodeSourcery/Sourcery_G++/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/include/c++/4.4.1/iostream:39: fatal error: bits/c++config.h: No such file or directory 
compilation terminated. 
make: *** [main] Error 1 

回答

1

貌似GCC的bug,它真的應該混合float和float32_t沒有錯誤。檢查this了。

編輯:這已在CodeSourcery toolchain中修復。這是從發行說明:

與float32_t編譯器錯誤。修正了從arm_neon.h使用 float32_t類型時導致 編譯器錯誤的錯誤。

+0

Hi ognian,我已經開始使用Code Sourcery工具,現在我得到一個與缺少文件C++ config.h有關的新錯誤。我已經用新錯誤更新了我的問題,請看看。只有當我有編譯器標誌-mfpu = neon -mfloat-abi = softfp時,我纔會再次遇到這些錯誤。沒有它們編譯好沒有任何問題。 – HaggarTheHorrible 2010-07-20 10:58:22

+0

這是完全不同的錯誤。我建議將$ CODE_SOURCERY_ROOT/arm-none-linux-gnueabi/include/C++/4.4.1/arm-none-linux-gnueabi添加到包含路徑中,其中$ CODE_SOURCERY_ROOT是安裝工具鏈的位置 – ognian 2010-07-20 12:16:00