This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Compiling Eigen3 on Zynq baremetal

Tags: None
(comma "," separated)
hshirian
Registered Member
Posts
5
Karma
0

Compiling Eigen3 on Zynq baremetal

Thu Feb 16, 2017 2:56 pm
Hello ,
I'm trying to compile Eigen3 library on Zynq. I first test library on my computer ( Ubuntu x64 ) which works fine. But when i want to compile it for Zynq, it gives me the following errors :
Code: Select all
invalid conversion from 'const int*' to 'const int32_t* {aka const long int*}' [-fpermissive]   test4       line 244, external location: /home/wizard/Desktop/eigen/Eigen/src/Core/arch/NEON/PacketMath.h   C/C++ Problem
invalid conversion from 'const int*' to 'const int32_t* {aka const long int*}' [-fpermissive]   test4       line 247, external location: /home/wizard/Desktop/eigen/Eigen/src/Core/arch/NEON/PacketMath.h   C/C++ Problem
invalid conversion from 'const int*' to 'const int32_t* {aka const long int*}' [-fpermissive]   test4       line 259, external location: /home/wizard/Desktop/eigen/Eigen/src/Core/arch/NEON/PacketMath.h   C/C++ Problem
invalid conversion from 'const int*' to 'const int32_t* {aka const long int*}' [-fpermissive]   test4       line 260, external location: /home/wizard/Desktop/eigen/Eigen/src/Core/arch/NEON/PacketMath.h   C/C++ Problem
invalid conversion from 'int*' to 'int32_t* {aka long int*}' [-fpermissive] test4       line 265, external location: /home/wizard/Desktop/eigen/Eigen/src/Core/arch/NEON/PacketMath.h   C/C++ Problem
invalid conversion from 'int*' to 'int32_t* {aka long int*}' [-fpermissive] test4       line 268, external location: /home/wizard/Desktop/eigen/Eigen/src/Core/arch/NEON/PacketMath.h   C/C++ Problem
invalid conversion from 'int*' to 'int32_t* {aka long int*}' [-fpermissive] test4       line 309, external location: /home/wizard/Desktop/eigen/Eigen/src/Core/arch/NEON/PacketMath.h   C/C++ Problem

Also the following Infos are shown :
Code: Select all
initializing argument 1 of 'void vst1q_s32(int32_t*, int32x4_t)'   test4      line 9123, external location: /home/wizard/Programs/Xilinx_2015/SDK/2015.4/gnu/arm/lin/lib/gcc/arm-xilinx-eabi/4.9.2/include/arm_neon.h   C/C++ Problem
initializing argument 1 of 'int32x4_t vld1q_s32(const int32_t*)'   test4      line 8679, external location: /home/wizard/Programs/Xilinx_2015/SDK/2015.4/gnu/arm/lin/lib/gcc/arm-xilinx-eabi/4.9.2/include/arm_neon.h   C/C++ Problem
initializing argument 1 of 'int32x2_t vld1_dup_s32(const int32_t*)'   test4      line 8893, external location: /home/wizard/Programs/Xilinx_2015/SDK/2015.4/gnu/arm/lin/lib/gcc/arm-xilinx-eabi/4.9.2/include/arm_neon.h   C/C++ Problem

And if i use Eigen2 which doesn't contain NEON codes, it works fine without problem.
What should i do ?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
You can disable explicit vectorization with -DEIGEN_DONT_VECTORIZE. You might also try to update your toolchain to a more recent gcc version as the root of the problem seems to come from the fact that int32_t is defined as a long int, which is wrong on 64 bits systems.
hshirian
Registered Member
Posts
5
Karma
0
Thanks for quick response.
My gcc versions are :
The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- The ASM compiler identification is GNU
Does these versions OK ?

And i have another question too, I try to compile it in baremetal which means i don't have any Operating system. Does Eigen library is standalone or it needs some functions from OS ( Linux ) ?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
gcc 4.9 is fine for a normal usage, but the error you get rather strange and seems to be unrelated to Eigen at first. Eigen's need malloc/free/realloc from the libC for dynamic allocation. If you use fixed sizes only, you can provide empty versions of them to prevent linking errors.
hshirian
Registered Member
Posts
5
Karma
0
Thanks for reply
We have malloc/calloc/free in baremetal. So it's no problem
I don't know if it's related to Eigen or not but the problem is that for example in line 244 of PacketMath.h there is a following code :
Code: Select all
template<> EIGEN_STRONG_INLINE Packet4i pload<Packet4i>(const int*   from) { EIGEN_DEBUG_ALIGNED_LOAD return vld1q_s32(from); }

Pay attention to const int*. but in arm_neon.h for vld1q_s32 we have :
Code: Select all
int32x4_t vld1q_s32(const int32_t*)

So it needs const int32_t* as argument not const int*. Similar problem goes with "vst1q_s32(int32_t*, int32x4_t)" and "vld1_dup_s32(const int32_t*)". I double check arm_neon.h with the latest one and "vld1q_s32" needs const int32_t*.
Isn't that Eigen library problem ?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
ok, now I get your compiler messages. On your system sizeof(int)==2 and thus int32_t has to be a typedef to "long int"... I did not expected to find systems with NEON and 16 bytes int. Sadly, int32_t is C++11 only but that should be manageable.
hshirian
Registered Member
Posts
5
Karma
0
So what should I do now ?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Try the devel branch: https://bitbucket.org/eigen/eigen/commits/96e0f73a35de/ If that works for you I'll backport it to 3.3.
hshirian
Registered Member
Posts
5
Karma
0
Errors are gone & Example code builds successfully !
Thanks ;D


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]