Compiler errors while building a project which uses Eigen, the C++ template library for linear algebra

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 13:49:53

问题


in my project I'm making use of Eigen C++ library for linear algebra and ONLY when I turn on the vectorization flags (mfpu=neon -mfloat-abi=softfp) for ARM NEON, I get compiler errors. I'm not able to understand whats going wrong. Do I need to enable any preprocessor directives for ARM NEON in the Eigen Library?


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

errors

 ubuntu@ubuntu-desktop:~/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
ubuntu@ubuntu-desktop:~/Documents/mat_mul$ 

Errors I got when I used Code Sourcery toolchain

ubuntu@ubuntu-desktop:~/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:


Looks like gcc bug, it really should mix float and float32_t without errors. Check this out.

Edit: This has been fixed in CodeSourcery toolchain. This is from release notes:

Compiler errors with float32_t. A bug has been fixed that caused compiler errors when using the float32_t type from arm_neon.h.



来源:https://stackoverflow.com/questions/3288043/compiler-errors-while-building-a-project-which-uses-eigen-the-c-template-libr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!