[Insight-developers] Rounding and itkMath.h (Class vs Namespace)

Tom Vercauteren tom.vercauteren at m4x.org
Fri Oct 23 05:07:04 EDT 2009


Hey,


> Sorry I am not sure I got you point here. Did you mean that you had to
> replace (from  itk-templatedmathround-2009-07-30.patch)
>
> inline vxl_int_64 RoundHalfIntegerToEven_64(float  x) { return
> _mm_cvtsd_si64(_mm_set_ss(x)); }
>
> by what's in the repository
>
> http://www.itk.org/cgi-bin/viewcvs.cgi/Code/Common/itkMathDetail.h?revision=1.2&root=Insight&sortby=date&view=markup
>
> inline vxl_int_64 RoundHalfIntegerToEven_64(float  x) { return
> _mm_cvtss_si64(_mm_set_ss(x)); }
>
> ?
> Then yes, this seems right. It must have slipped through because I
> mainly use a 32 bit box.
>
>
> Yes this was the change I was referring to.
>
> There also appear to be some problem with it:
>
> http://www.cdash.org/CDash/viewBuildError.php?buildid=454563
>
> http://gcc.gnu.org/ml/gcc-patches/2006-01/msg01759.html
>
> This build appears to use an older version of gcc, 3.4.6 which does not
> appear to have these intrinsics defined. I suppose a compile time test is in
> order here.
>
> Detecting this SSE stuff is very complicated and error prone. We still have
> the outstanding issue of the apple continuous build performing a complete
> rebuild each time due to some issue related to SSE detection. This part is
> just so tricky due to all the different compilers and systems supported.
>
>
Indeed, the availability of these _mm_cvtss_si64 and _mm_cvtsd_si64
intrinsics apparently depend on the compiler, compiler version, architecture
and maybe more...

I guess that we need to ad a try-compile to see whether we may use them or
not. Another option would be to not use them and only implement the assembly
versions.



> Now that you ask, I am starting to doubt. I haven't access to my
> computer right now but I kind of remember that using _mm_cvtss_si64
> and _mm_cvtsd_si64 didn't compile on my 32 bit box. This seems
> supported by the following link
> http://msdn.microsoft.com/en-us/library/bb514009.aspx
> that states that  _mm_cvtsd_si64 is for x64
>
>
> This may be different on linux and apple system then on widows.
> Complicated!
>

Just checked, I don't think that this is platform dependent. It really looks
like _mm_cvtss_si64 and _mm_cvtsd_si64 are only for x86_64, looking at
emmintrin.h from the intel compiler icc (they should know there own
processors), I see:

/*
 * Support for 64-bit extension intrinsics
 */
#if defined(__x86_64) || defined(_M_X64)
extern __int64 __cdecl _mm_cvtsd_si64(__m128d a);
extern __int64 __cdecl _mm_cvttsd_si64(__m128d a);
extern __m128d __cdecl _mm_cvtsi64_sd(__m128d a, __int64 b);
extern __m128i __cdecl _mm_cvtsi64_si128(__int64 a);
extern __int64 __cdecl _mm_cvtsi128_si64(__m128i a);
extern    void __cdecl _mm_stream_si64(__int64 *p, __int64 a);
#endif

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


More information about the Insight-developers mailing list