[Insight-developers] ITK / CableSwig / gcc 4.1 / 64 bit Linux - _mm_cvtsd_si64 and _mm_cvtss_si64

Wheeler, Frederick W (GE Global Research) wheeler at ge.com
Tue Feb 8 16:41:50 EST 2011


ITK Developers:

I had some errors building ITK with python wrapping and fixed them by
modifying CableSwig.  Here are the details and the fix.

Key CMake params for my build:

BUILD_SHARED_LIBS:BOOL=ON
USE_WRAP_ITK:BOOL=ON
ITK_USE_REVIEW:BOOL=ON
CableSwig_DIR:FILEPATH=$DEV/CableSwig_usr_gcc_rel/lib/CableSwig
WRAP_ITK_PYTHON:BOOL=ON

Using latest ITK from GIT and latest CableSwig from CVS.

% uname -a
Linux snakebite 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009
x86_64 x86_64 x86_64 GNU/Linux
% gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

ITK builds fine when WRAP_ITK_PYTHON is OFF, but with it ON a couple of
declarations are missing.  Here are the errors from gcc:

[ 20%] Generating vcl_complex.xml
cd /local/wheeler/dev/itk_debug/Wrapping/WrapITK/Libraries/VXLNumerics
&& /local/wheeler/dev/CableSwig_usr_gcc_rel/lib/CableSwig/bin/gccxml
-fxml-start=_cable_
-fxml=/local/wheeler/dev/itk_debug/Wrapping/WrapITK/Libraries/VXLNumeric
s/vcl_complex.xml --gccxml-gcc-options
/local/wheeler/dev/itk_debug/Wrapping/WrapITK/Libraries/VXLNumerics/gcc_
xml.inc -DCSWIG -DCABLE_CONFIGURATION -DITK_MANUAL_INSTANTIATION
/local/wheeler/dev/itk_debug/Wrapping/WrapITK/Libraries/VXLNumerics/vcl_
complex.cxx
In file included from
/local/wheeler/dev/itk_src/Code/Common/itkMath.h:32,
                 from
/local/wheeler/dev/itk_src/Code/Common/itkIndex.h:23,
                 from
/local/wheeler/dev/itk_src/Code/Review/itkLabelObjectLine.h:21,
                 from
/local/wheeler/dev/itk_src/Code/Review/itkLabelObject.h:23,
                 from
/local/wheeler/dev/itk_src/Code/Review/itkShapeLabelObject.h:21,
                 from
/local/wheeler/dev/itk_src/Code/Review/itkStatisticsLabelObject.h:21,
                 from
/local/wheeler/dev/itk_debug/Wrapping/WrapITK/Libraries/VXLNumerics/vcl_
complex.cxx:2:
/local/wheeler/dev/itk_src/Code/Common/itkMathDetail.h: In function
'itk::int64_t itk::Math::Detail::RoundHalfIntegerToEven_64(double)':
/local/wheeler/dev/itk_src/Code/Common/itkMathDetail.h:280: error:
'_mm_cvtsd_si64' was not declared in this scope
/local/wheeler/dev/itk_src/Code/Common/itkMathDetail.h: In function
'itk::int64_t itk::Math::Detail::RoundHalfIntegerToEven_64(float)':
/local/wheeler/dev/itk_src/Code/Common/itkMathDetail.h:288: error:
'_mm_cvtss_si64' was not declared in this scope
gmake[2]: *** [Wrapping/WrapITK/Libraries/VXLNumerics/vcl_complex.xml]
Error 1
gmake[2]: Leaving directory `/local/wheeler/dev/itk_debug'
gmake[1]: ***
[Wrapping/WrapITK/Libraries/VXLNumerics/CMakeFiles/VXLNumericsIdx.dir/al
l] Error 2
gmake[1]: Leaving directory `/local/wheeler/dev/itk_debug'
gmake: *** [all] Error 2
[emake] Exiting with status 2


After some digging with gccxml -E it seems the declarations for
_mm_cvtsd_si64 and _mm_cvtss_si64 are in emmintrin.h and xmmintrin.h on
my system in /usr/lib/gcc/x86_64-redhat-linux/4.1.1/include/, so
ITK_COMPILER_SUPPORTS_SSE2_64 gets set to ON by the try_compile.  But
these declarations are not in the gccxml_gnu_*.h versions of these files
in CableSwig_usr_gcc_rel/lib/CableSwig/share/gccxml-0.9/GCC/4.1/ so they
are missing when gccxml runs.

Here are the changes I made to fix the errors.  I made the changes in
the installed files, which seem to be copies of files from the source
tree.  (I've since propagated the changes to the source tree, so if a
'cvs diff' is helpful, let me know.)

diff -C3 \
  CableSwig_src/GCC_XML/Support/GCC/4.1/gccxml_gnu_emmintrin.h \
 
CableSwig_usr_gcc_rel/lib/CableSwig/share/gccxml-0.9/GCC/4.1/gccxml_gnu_
emmintrin.h

*** CableSwig_src/GCC_XML/Support/GCC/4.1/gccxml_gnu_emmintrin.h
2010-07-27 14:34:07.000000000 -0400
---
CableSwig_usr_gcc_rel/lib/CableSwig/share/gccxml-0.9/GCC/4.1/gccxml_gnu_
emmintrin.h 2011-02-08 10:26:18.000000000 -0500
***************
*** 541,546 ****
--- 541,554 ----
  ;

  #ifdef __x86_64__
+ /* Intel intrinsic.  */
+ static __inline long long __attribute__((__always_inline__,
__artificial__))
+ _mm_cvtsd_si64 (__m128d __A)
+ {
+   return __builtin_ia32_cvtsd2si64 ((__v2df) __A);
+ }
+
+ /* Microsoft intrinsic.  */
  static __inline long long __attribute__((__always_inline__))
  _mm_cvtsd_si64x (__m128d __A)
  ;

diff -C3 \
  CableSwig_src/GCC_XML/Support/GCC/4.1/gccxml_gnu_xmmintrin.h \
 
CableSwig_usr_gcc_rel/lib/CableSwig/share/gccxml-0.9/GCC/4.1/gccxml_gnu_
xmmintrin.h

*** CableSwig_src/GCC_XML/Support/GCC/4.1/gccxml_gnu_xmmintrin.h
2010-07-27 14:34:07.000000000 -0400
---
CableSwig_usr_gcc_rel/lib/CableSwig/share/gccxml-0.9/GCC/4.1/gccxml_gnu_
xmmintrin.h 2011-02-08 10:27:52.000000000 -0500
***************
*** 356,361 ****
--- 356,370 ----
  #ifdef __x86_64__
  /* Convert the lower SPFP value to a 32-bit integer according to the
current
     rounding mode.  */
+
+ /* Intel intrinsic.  */
+ static __inline long long __attribute__((__always_inline__,
__artificial__))
+ _mm_cvtss_si64 (__m128 __A)
+ {
+   return __builtin_ia32_cvtss2si64 ((__v4sf) __A);
+ }
+
+ /* Microsoft intrinsic.  */
  static __inline long long __attribute__((__always_inline__))
  _mm_cvtss_si64x (__m128 __A)
  ;

I added the definitions and all seems fine.  Note I left in
__artificial__ as it is used in my copies of emmintrin.h and
xmmintrin.h, even though that is not used elsewhere (that I noticed) in
the gccxml_gnu_*.h versions.  I'm not sure if that is the right thing to
do.

After this change, all 1714 tests pass except for
PythonCannyEdgeDetectionImageFilterTest (SEGFAULT).

Fred Wheeler



More information about the Insight-developers mailing list