views:

122

answers:

1

Hi Guys,

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
A: 

Hi,

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.

ognian
Hi ognian, I have started to use Code Sourcery tools and now I get a new error related to a missing file c++config.h. I have updated my question with new errors please take a look. Once again I get these errors only when I have the compiler flags -mfpu=neon -mfloat-abi=softfp. Without them It compiles well without any problem.
vikramtheone
That's completely different error. I would suggest to add $CODE_SOURCERY_ROOT/arm-none-linux-gnueabi/include/c++/4.4.1/arm-none-linux-gnueabi to your include path, where $CODE_SOURCERY_ROOT is the location where you installed the toolchain
ognian