Registered Member
|
Hello,
I'm trying to use Eigen library with Adobe Alchemy (used to port C/C++ code to Flash bytecode thanks to GCC+LLVM+Adobe Flex). The problem is that Alchemy doesn't support _asm code. So we need to compile with GCC with the following parameters: CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -Wall -Dasm=broken -D_asm=broken -D__asm=broken -D__asm__=broken I get the following error (among others): [ 37%] Building CXX object MLT/Src/SDK/CMakeFiles/MLTSDK.dir/dcvKalmanFilter.cpp.o D:/svn/development/ThirdParty/eigen/Eigen/src/Core/util/Memory.h: In function 'void Eigen::internal::queryCacheSizes_intel_direct(int&, int&, int&)': D:/svn/development/ThirdParty/eigen/Eigen/src/Core/util/Memory.h:756: error: 'broken' was not declared in this scope D:/svn/development/ThirdParty/eigen/Eigen/src/Core/util/Memory.h:756: error: expected `;' before 'volatile' Does Eigen have a compilation define to use only C++ code without any inline assembly code ? Best regards, Alan. |
Moderator
|
That's currently not possible. I suggest you to edit your own copy of Eigen and add a:
#undef EIGEN_CPUID right before the #ifdef EIGEN_CPUID in the eigen/Eigen/src/Core/util/Memory.h file. I guess you might have to disable vectorization too? (-DEIGEN_DONT_VECTORIZE) |
Registered Member
|
I did some search in Eigen code (3.04) and found the following:
####################################################################################################################################################################################### D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\arch\NEON\PacketMath.h(66):#define __pld(x) asm volatile ( " pld [%[addr]]\n" :: [addr] "r" (x) : "cc" ); D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\arch\SSE\PacketMath.h(528):// asm("mulps %[a], %[b] \n\taddps %[c], %[b]" : [b] "+x" (res) : [a] "x" (a), [c] "x" (c)); D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\arch\SSE\PacketMath.h(534):// asm("palignr %[i], %[a], %[b] " : [b] "+x" (res) : [a] "x" (a), [i] "i" (i)); We just need to have !defined EIGEN_VECTORIZE_SSE !defined EIGEN_VECTORIZE_ALTIVEC !defined EIGEN_VECTORIZE_NEON and it should be ok by default I guess or we can enforce by defining: EIGEN_DONT_VECTORIZE (like you suggest me) ####################################################################################################################################################################################### D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Sparse\SparseVector.h(328):// asm("#begindot"); D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Sparse\SparseVector.h(341):// asm("#enddot"); Nothing to do because it is 'commented' code ####################################################################################################################################################################################### D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\util\Macros.h(255):#define EIGEN_ASM_COMMENT(X) asm("#" X) We want to avoid that to define it to "asm" command. So the easiest way is to modify above code line to be like this: D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\util\Macros.h(254):#if !defined(EIGEN_ASM_COMMENT) && (defined __GNUC__) And then we define EIGEN_ASM_COMMENT in compilation settings ####################################################################################################################################################################################### D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\products\GeneralBlockPanelKernel.h(604):EIGEN_ASM_COMMENT("mybegin2"); D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\products\GeneralBlockPanelKernel.h(640):EIGEN_ASM_COMMENT("myend"); D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\products\GeneralBlockPanelKernel.h(644):EIGEN_ASM_COMMENT("mybegin4"); Nothing to do if EIGEN_ASM_COMMENT has been deactivated in any way ####################################################################################################################################################################################### D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\util\Memory.h(727): __asm__ __volatile__ ("xchgl %%ebx, %%esi;cpuid; xchgl %%ebx,%%esi": "=a" (abcd[0]), "=S" (abcd[1]), "=c" (abcd[2]), "=d" (abcd[3]) : "a" (func), "c" (id)); D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\util\Memory.h(731): __asm__ __volatile__ ("cpuid": "=a" (abcd[0]), "=b" (abcd[1]), "=c" (abcd[2]), "=d" (abcd[3]) : "a" (func), "c" (id) ); We need to deactivate the use of CPUID instruction, so we need to avoid to define EIGEN_CPUID even if "#if defined(__GNUC__) && ( defined(__i386__) || defined(__x86_64__) )" is valid or "defined(_MSC_VER)" So we need to add those two lines: D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\util\Memory.h(723):#if !defined(EIGEN_FORCE_NO_CPUID) D:\Eigen\Eigen 3.0.4\eigen-eigen-13a11181fc5a\Eigen\src\Core\util\Memory.h(739):#endif And to define EIGEN_FORCE_NO_CPUID in compilation settings. Would you accept that such minor modifications (that don't change the default behavior if you don't use the defines at compiler's command-line) be commited to official Eigen library ? I ask you that because I want to use Eigen in a proprietary solution and would like to avoid to link to an unofficial version of Eigen to fulfill the requirements of LGPL. I think it would add an easy way to have a 'pure C++' that could be helpful on platform that doesn't provide cpuid-like routine. And in our case, the fact that our compiler (even if it is based on GCC) doesn't support inline assembly. If yes, let me know how to proceed. Regards, Alan. |
Moderator
|
Sounds reasonable. Note that the first 3 asm you noticed are not an issue (one is for ARM NEON, and the others are commented).
|
Registered Member
|
Do you want me to commit the proposed changes ?
Or do you prefer to do it yourself ? If you want me to to dit, please could you tell me the procedure? If not, could you please tell me when & where the modifications will be done ? Thank you. Best regards, Alan. |
Moderator
|
The repository is not open for writing. If you have mercurial, the best is that you commit:
hg commit and then generate a patch: hg export tip > filename.patch All the detailed explanations are there: http://eigen.tuxfamily.org/index.php?title=Mercurial |
Registered Member
|
Hello
I've generated the patch to enable 'Pure C/C++' with GCC. Because it seems I can't attach it to this post, I have sent it to eigen-core-team email (with title: "[Patch] How to compile Eigen without _asm directive"). Please could you tell me when it will be (or as soon as it is) integrated ? Best regards, Alan. |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]