Registered Member
|
Hello Community,
i want to use Eigen on a Windows Mobile 6.0 Smartphone. Using Visual Studio 2008 i had to change the following in Eigen source to bypass compilation errors: IO.h - commented out the following functions MatrixBase<Derived>::format(const IOFormat& fmt) const std::ostream & operator << (std::ostream & s, const MatrixBase<Derived> & m) Memory.h changed the define order to use the handmade alignement. i also tried with already aligned memory allocation (msdn says the normal malloc is already aligned on Windows CE). Now my problem: Eigen::SVD <MatrixXf> svd_matrix(input_matrix); using the function void SVD<MatrixType>::compute(const MatrixType& matrix); gives NAN results by chance. The problem lies in the while() loop in the compute function. Sometimes some calculation results in this loop gets infinite, so the whole result is a matrix of NAN. The funny thing is 25% of the calculations are correct, the rest is NAN. It is reproduceable which calculations work an which give NAN. Getting NAN is only the case running on the Smartphone (armv4i). The same code with same input works fine on x86 g++. Do you have any ideas to fix or diagnose this problem? (Do you need additional information or source?) Thank you in advance, Jakob |
Moderator
|
that's very strange because it used to work with MSVC, can you put the compilation errors ?
ok, I guess to make this working out of the box we would have to detect windows CE specifically. Do you now which preprocessor token can be used to detect this platform ?
I guess you are using the 2.0.4 version ? I checked the source code and actually the epsilon is hardcoded as follow: Scalar eps = ei_pow(Scalar(2),ei_is_same_type<Scalar,float>::ret ? Scalar(-23) : Scalar(-52)); that is very bad because I guess that on windows CE the respective precisions of floats and doubles are not the same. This line should be replaced by: Scalar eps = std::numeric_limits<Scalar>::epsilon() Does that fix your issue ? Otherwise no need to investigate further because this SVD implementation has been replaced by another one in the devel branch. |
Registered Member
|
using the latest Eigen (2.0.4) source i get:
The functions are not available in the Mobile SDK. According to MSDN malloc (Windows CE 5.0) the malloc function guarantees alignment in Windows CE in the same way as LocalAlloc in the Win32 API.
Using the 2.0.4 source there is only the warning described here left, using 2.0 there aren't any more warnings or errors.
i think you can use one of following defines:
Unfortunaly this didn't fix the issue. I will try working with the devel version and report back. Thank you so far, Jakob |
Registered Member
|
I tried the SVD transformation now with the latest Developement Version (SVD last change 16th August). It doesn't work.
I set up a WIN32 and the Window Mobile project for comparison (it works perfectly on WIN32). I attached the debug views of certain breakpoints to show you my results. When entering the compute() function, both input matrices are the same, so no other calculation could have disrupted the result. In Breakpoint (bp) 1 and 2 are only differences in not initialised data and Scalars. The Scalars don't look really good in WINCE. In bp 3 (after the firest big for loop, see screenshots) the WINCE matrix differs from the WIN32 version. When going step by step, first difference is the first scale value in the loop (bp scale). I rewrote the line to get the intermediate results (bp scale rewritten). Eigen::Cwise<Type>::abs() gives different values on WINCE (see screenshots). Is this a bad thing? So my first question would be: Are the Scalars in WINCE ok and are the different values in abs() intentional? If you say supporting Windows Mobile would consume too much time because of too many changes, it's ok. But otherwise i'm willing to help you there. The Breakpoint screenshots: download Jakob |
Moderator
|
ok, one first thing to do would be to run the Eigen unit tests on Windows Mobile. For that you need cmake, run it to generate a MSVC project (during the configuration/generation set the variable EIGEN_BUILD_TESTS to on). In MSVC build the tests (this will take a while), and in a console you can run "ctest -V" in the build directory to run them all.
Another question: does your target supports SSE instruction ? in doubt you can try to define: #define EIGEN_DONT_VECTORIZE before including any Eigen header file. |
Registered Member
|
Or better, EIGEN_DONT_ALIGN, which contrary to EIGEN_DONT_VECTORIZE will allow to bypass the problems with aligned_malloc. (Only with the devel branch though)
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
i already tried EIGEN_DONT_VECTORIZE which didn't have any influence on the result. i also tested with EIGEN_DONT_ALIGN now, which also didn't make it work. tested it on the test_svd and my project.
I cmaked the Eigen suite with this cmake for windows mobile. After some minor changes in the main.h (there is no lib for time.h, needs to be WinMain instead of main, need special lib for exceptions) i compiled the tests. you can find the build output for all test projects here.
Running the test on the mobile, 17 of 58 failed with assertions. The others returned with no error or with no error and handled exceptions. Please have a look at the output from all test projects here. I used the Developement branch checkout from Aug 23, 2009. |
Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]