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

SVG problems on Windows Mobile

Tags: None
(comma "," separated)
Jako
Registered Member
Posts
4
Karma
0

SVG problems on Windows Mobile

Tue Aug 18, 2009 5:30 pm
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
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: SVG problems on Windows Mobile

Tue Aug 18, 2009 10:50 pm
Jako wrote: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)


that's very strange because it used to work with MSVC, can you put the compilation errors ?

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).


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 ?


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?


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.
Jako
Registered Member
Posts
4
Karma
0

Re: SVG problems on Windows Mobile

Wed Aug 19, 2009 7:53 pm
ggael wrote:can you put the compilation errors ?

using the latest Eigen (2.0.4) source i get:
VS9 Compiler wrote:Memory.h:
1>Memory.h(90) : error C3861: '_aligned_malloc': identifier not found
1>Memory.h(155) : error C3861: '_aligned_free': identifier not found

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.

VS9 Compiler wrote:1>io.h(117) : error C2143: syntax error : missing ';' before '<'
1>io.h(117) : error C2433: 'MatrixBase' : 'inline' not permitted on data declarations
1>io.h(117) : error C2734: 'MatrixBase' : const object must be initialized if not extern
1>io.h(117) : error C2734: 'MatrixBase' : const object must be initialized if not extern
1>io.h(117) : error C2988: unrecognizable template declaration/definition
1>io.h(117) : error C2059: syntax error : '<'
1>io.h(117) : error C2039: 'format' : is not a member of '`global namespace''

1>io.h(179) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>io.h(179) : error C2143: syntax error : missing ',' before '<'

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.
ggael wrote:Do you now which preprocessor token can be used to detect this platform ?

i think you can use one of following defines:
Preprocessor wrote:_WIN32_WCE=$(CEVER)
UNDER_CE=$(CEVER)
WINCE

ggael wrote:Scalar eps = std::numeric_limits<Scalar>::epsilon()
Does that fix your issue ?

Unfortunaly this didn't fix the issue. I will try working with the devel version and report back.

Thank you so far,

Jakob
Jako
Registered Member
Posts
4
Karma
0

Re: SVG problems on Windows Mobile

Sun Aug 23, 2009 4:02 pm
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
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: SVG problems on Windows Mobile

Tue Aug 25, 2009 6:58 am
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.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: SVG problems on Windows Mobile

Wed Aug 26, 2009 2:21 am
ggael wrote: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.


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!
Jako
Registered Member
Posts
4
Karma
0

Re: SVG problems on Windows Mobile

Mon Aug 31, 2009 12:44 pm
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.

run the Eigen unit tests on Windows Mobile

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.
26>test_rrqr - 6 error(s), 11 warning(s), output_all.txt zeile 35549
40>test_triangular - 2 error(s), 8 warning(s), output_all.txt zeile 81890
48>test_miscmatrices - 1 error(s), 6 warning(s), output_all.txt zeile 86625
50>test_diagonalmatrices - 1 error(s), 65 warning(s), output_all.txt zeile 91916
63>test_mixingtypes - 107 error(s), 1 warning(s), output_all.txt zeile 102427
========== Build: 58 succeeded, 5 failed, 3 up-to-date, 6 skipped ==========


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.


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]