[Insight-developers] vnl_math::pi coming up undefined with vector optimization turned on?

kent williams norman-k-williams at uiowa.edu
Fri Oct 23 15:44:34 EDT 2009


I know what causes the problem, but not what causes the cause:

This CMAKE definition, which gets configured in when VXL is configured:

VCL_STATIC_CONST_INIT_NO_DEFN:INTERNAL=0

Somehow, my crazy CFLAGS are setting that variable to 1.

I think, either way VCL should NOT use this flag and ALWAYS declare the
static member variables in a source file.

On 10/23/09 9:43 AM, "kent williams" <norman-k-williams at uiowa.edu> wrote:

> Here¹s what I¹ve got going. I¹ve downloaded the latest XCode which has a newer
> GCC, but I don¹t have admin privelege on my work box, so it isn¹t installed.
> 
> XCode 3.1.1
> OS X 10.5.8
> GCC 4.0.1 
> 
> //No help, variable specified on the command line.
> CMAKE_CXX_FLAGS:STRING=-g -O3 -DNDEBUG -msse -mmmx -msse2 -msse3
> -UITKIO_DEPRECATED_METADATA_ORIENTATION -m64 -arch x86_64 -Wconversion
> -mmacosx-version-min=10.4  -Wall -W -Wshadow -Wcast-qual -Wwrite-strings
> 
> //No help, variable specified on the command line.
> CMAKE_C_FLAGS:STRING=-g -O3 -DNDEBUG -msse -mmmx -msse2 -msse3
> -UITKIO_DEPRECATED_METADATA_ORIENTATION -m64 -arch x86_64 -Wconversion
> -mmacosx-version-min=10.4  -Wall -W -Wshadow -Wcast-qual -Wwrite-strings
> 
> 
> 
> 
> On 10/23/09 9:25 AM, "Bradley Lowekamp" <blowekamp at mail.nih.gov> wrote:
> 
>> Kent,
>> 
>> On CMAKE_BUILD_TYPE=RELEASE the "-O3" flag is the optimization used. And
>> there are many nightly build with this flag. This is very perplexing.
>> 
>> What version of the OSX, XCode, gcc etc are you using?
>> 
>> As I am currently building with this flag, I don't know how to try to
>> reproduce this error. Do you have a command line cmake with "-D" flags
>> defining the options you are setting, that is able reproduce this problem?
>> 
>> 
>> Brad
>> 
>> On Oct 23, 2009, at 10:10 AM, kent williams wrote:
>> 
>>> Yes, I did a scratch rebuild, and I verified by going back to O2 that this
>>> was the issue.
>>> 
>>> What it looks like is that vcl_math.h isn't declaring all those static
>>> member variables as it should -- very much a VXL library issue, at least on
>>> OSX.
>>> 
>>> It's not a huge deal to me, except we have some very CPU-intensive code that
>>> would benefit from vectorizing in the registration framework.  At least
>>> that's what Shark is telling me.
>>> 
>>> 
>>> On 10/22/09 8:31 PM, "Luis Ibanez" <luis.ibanez at kitware.com> wrote:
>>> 
>>>> Hi Kent,
>>>> 
>>>> <me speculating>
>>>> 
>>>> One of the things that -O3 does is to force full in-lining of templated
>>>> method.
>>>> 
>>>> I'm wondering if the effect is that something that has been typically
>>>> delegated
>>>> to a cxx initialization is now being done in a header.
>>>> 
>>>> That said...
>>>> the default of "Release" build in Linux is to use -O3....
>>>> so...the problem that you are exposing seems to
>>>> be very specific to OS X.
>>>> 
>>>> </me speculating>
>>>> 
>>>> 
>>>> Question:
>>>> 
>>>> When you changed the flags...
>>>> Did you rebuild the toolkit from scratch ?
>>>> 
>>>> 
>>>>      Luis
>>>> 
>>>> 
>>>> ------------------------
>>>> On Thu, Oct 22, 2009 at 4:36 PM, kent williams
>>>> <norman-k-williams at uiowa.edu> wrote:
>>>>> I¹m trying to build ITK from the CVS source as of today.  I¹m not
>>>>> modifying
>>>>> anything at all.  The only thing I did was use our CFLAGS and CXXFLAGS
>>>>> when
>>>>> I run CMake.  The undefined externals are coming during building ITK
>>>>> itself,
>>>>> not in my application.
>>>>> 
>>>>> The problem didn¹t  show up until I added ­O3 to the command line.  Why
>>>>> that
>>>>> would interact with the static const members of  vnl_math I have no idea.
>>>>> 
>>>>> 
>>>>> On 10/22/09 3:21 PM, "Bradley Lowekamp" <blowekamp at mail.nih.gov> wrote:
>>>>> 
>>>>> Hello kent,
>>>>> 
>>>>> I was just looking at this stuff. It turns out the following is not
>>>>> standard
>>>>> c++:
>>>>> 
>>>>> class C {
>>>>> static const double one = 1.0;
>>>>> };
>>>>> 
>>>>> This is because static member variable must be defined in one obj file,
>>>>> not
>>>>> in headers, so that all instance of the object will reference the same
>>>>> address. But some compilers are smart enough to know what you are trying
>>>>> to
>>>>> do here and let is slide.
>>>>> 
>>>>> As to why you are getting this error, are you sure you are linking against
>>>>> the correct libraries? vnl_math::pi should be defined int the vnl library.
>>>>> 
>>>>> victoria:bin blowek1$ nm libitkvnl.a | grep pi
>>>>> 000016d8 S __ZN8vnl_math11one_over_piE
>>>>> 000016e0 S __ZN8vnl_math11two_over_piE
>>>>> 000016e8 S __ZN8vnl_math15two_over_sqrtpiE
>>>>> 000016f0 S __ZN8vnl_math16one_over_sqrt2piE
>>>>> 000016c0 S __ZN8vnl_math2piE
>>>>> 000016c8 S __ZN8vnl_math9pi_over_2E
>>>>> 000016d0 S __ZN8vnl_math9pi_over_4E
>>>>> 
>>>>> Hope this helps,
>>>>> Brad
>>>>> 
>>>>> 
>>>>> 
>>>>> On Oct 22, 2009, at 4:05 PM, kent williams wrote:
>>>>> 
>>>>> I'm trying to build ITK on OS X with the "-O3" flag. I've never had
>>>>> trouble
>>>>> with "-O2" but now I get an undefined external for vnl_math::pi.
>>>>> 
>>>>> The main reason to go with "-O3" is to turn on vector SIMD optimizations
>>>>> --
>>>>> in one application we're trying to optimize, the biggest share of CPU is
>>>>> used in the ImageToImageMetric, and Shark is suggesting that the loops in
>>>>> the hot routines would benefit from vector optimizations.
>>>>> 
>>>>> I don't know why or from whence the problem originates, but what it looks
>>>>> like is that the vnl_math:: constants don't get declared as variables if
>>>>> VCL_STATIC_CONST_INIT_FLOAT_NO_DEFN is defined.
>>>>> 
>>>>> Now I'm no VXL library hacker,so I'm pretty much baffled by this thing.
>>>>> 
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com <http://www.kitware.com>
>>>>> <http://www.kitware.com>
>>>>> 
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>> 
>>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>> 
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.itk.org/mailman/listinfo/insight-developers
>>>>> 
>>>>> ========================================================
>>>>> 
>>>>> Bradley Lowekamp
>>>>> 
>>>>> Lockheed Martin Contractor for
>>>>> 
>>>>> Office of High Performance Computing and Communications
>>>>> 
>>>>> National Library of Medicine
>>>>> 
>>>>> blowekamp at mail.nih.gov
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com <http://www.kitware.com>
>>>>> 
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>> 
>>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>> 
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.itk.org/mailman/listinfo/insight-developers
>>>>> 
>>>>> 
>>> 
>>> _______________________________________________
>>> Powered by www.kitware.com <http://www.kitware.com>
>>> 
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>> 
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>> 
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-developers
>> 
>> ========================================================
>> 
>> Bradley Lowekamp
>> 
>> Lockheed Martin Contractor for
>> 
>> Office of High Performance Computing and Communications
>> 
>> National Library of Medicine
>> 
>> blowekamp at mail.nih.gov
>> 
>> 
>> 
> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20091023/41fc9a04/attachment.htm>


More information about the Insight-developers mailing list