[Insight-developers] vnl_test_math failing in several platforms

Simon Warfield warfield at bwh.harvard.edu
Sun Feb 6 12:16:23 EST 2005


Hans Johnson wrote:

>Luis,
>
>I looked at this some time ago, but did not come up with a full
>solution. The problem seems to be that the test is very sensitive to
>exactly how floating point values are handeled. It seems to be hardcoded
>assuming a particular floating point representation used by default on
>intel compilers (i.e. 80 bits of precision for round off errors).
>
I think what the code has is hard coding for the bit patterns of certain 
types of floats e.g. what bit pattern constitutes a NaN.
It goes to some trouble to avoid trusting the compiler or platform code 
for e.g. isnan, and instead supplies its own idea of what a NaN is, and 
checks whether the compiler or platform is getting that right.

I wrote to the insight-developers list on 08/11/2004 about some changes 
to make this work with Intel.

> Another was that the code in vnl_numeric_limits.cxx that defines e.g. 
> NaN was using a bit pattern not correct for the Intel layout.
> In particular, the Intel layout has an 80 bit long double in a 12 byte 
> aligned structure, and so byte 9 needs to be set to 0x7f, not byte 11 
> as the code was doing.
> Then, there are some issues with isnanl, isinfl etc. with the Intel 
> compiler up to version 8.0.  Apparently these are resolved in version 
> 8.1 of the compiler, so the code calls the correct builtin functions 
> for that or newer versions, and for 8.0 and earlier it makes a good 
> try at working around the compiler problem (its pretty ugly in there).


On top of the horror that was already there, I made changes to ensure 
the Intel long double format works, and added the platform specific code 
for the Intel 8.0 compiler.
The 8.1 compiler has since been released, and this fixed bugs in the 
isnanl, isinfl macro definitions the compiler uses, but if you check out 
the dashboard when I submitted some builds with this compiler, I think 
there are still some problems in the math tests.

This code also seems to be failing with GCC on linux with Intel EM64T/AMD64.


> It is
>very sensitive to how floating point optimization and round off occurs.
>
>I think this test needs different initializations for each of the
>following cases:
>1) gcc compiler when -ffloat-store
>2) icc compiler when -pc64 is used
>3) gcc on an Alpha processor
>
>I hope this cryptic message helps.  
>
>Hans
>
>
>On Feb 04, 2005 09:45 AM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>
>  
>
>>The test vnl_test_math is failing in several platforms
>>
>>
>>http://www.itk.org/Testing/Dashboard/20050204-0500-Nightly/TestDetail/__Utilities_vxl_core_vnl_tests_vnl_test_math.html
>>
>>the problem seems to be related to the use of the type
>>
>>                   "long double"
>>
>>
>>The relevant lines are:
>>
>>     Insight/Utilities/vxl/core/vnl/tests/test_math.cxx
>>
>>
>>line 98:
>>long double qnan_q = vcl_numeric_limits<long double>::quiet_NaN();
>>
>>line 143:
>>testlib_test_assert("!isfinite(qnan_q)", !vnl_math_isfinite(qnan_q));
>>
>>We already have the following comment in this file, regarding the
>>isnan
>>test for the same type "long double"
>>
>>
>>   /* This test fails on some platforms, but ITK does not need it.
>>If it is ever fixed in vnl proper, we will include the fix here. */
>>/*testlib_test_assert(" isnan(qnan_q) ", vnl_math_isnan(qnan_q));*/
>>
>>
>>
>>
>>Does anybody see a problem with commenting out the 'isfinite' test too
>>?
>>
>>
>>Does anybody care about "long double"  ?
>>
>>
>>
>>
>>     Luis
>>
>>
>>
>>
>>
>>_______________________________________________
>>Insight-developers mailing list
>>Insight-developers at itk.org
>>http://www.itk.org/mailman/listinfo/insight-developers
>>
>>    
>>
>
>
>
>Hans Johnson
>hans-johnson at uiowa.edu
>
>_______________________________________________
>Insight-developers mailing list
>Insight-developers at itk.org
>http://www.itk.org/mailman/listinfo/insight-developers
>  
>


-- 
Simon K. Warfield, Ph.D. warfield at bwh.harvard.edu Phone:617-732-7090
http://www.spl.harvard.edu/~warfield           FAX:  617-582-6033
Associate Professor of Radiology,          Harvard Medical School
Director, Computational Radiology Laboratory
Thorn 329, Dept Radiology,  Brigham and Women's Hospital 
75 Francis St, Boston, MA, 02115
MA 280, Dept Radiology, Children's Hospital Phone: 617-355-4566



More information about the Insight-developers mailing list