| 1 |
From: Tom Vercauteren <tom.vercauteren@gmail.com>
|
| 2 |
Date: Tue, 19 May 2009 09:29:23 -0400
|
| 3 |
Subject: [PATCH] COMP: Use vanilla implementation in rounding function when gcc-xml is used
|
| 4 |
|
| 5 |
---
|
| 6 |
Utilities/vxl/core/vnl/vnl_math.h | 19 +++++++++++--------
|
| 7 |
1 files changed, 11 insertions(+), 8 deletions(-)
|
| 8 |
Origin: vendor, http://itk.org/gitweb?p=ITK.git;a=commit;h=b106984
|
| 9 |
Last-Update: 2012-12-20
|
| 10 |
|
| 11 |
Index: vxl-1.17.0/core/vnl/vnl_math.h
|
| 12 |
===================================================================
|
| 13 |
--- vxl-1.17.0.orig/core/vnl/vnl_math.h 2012-03-16 16:27:06.000000000 +0100
|
| 14 |
+++ vxl-1.17.0/core/vnl/vnl_math.h 2012-06-01 15:44:56.321752813 +0200
|
| 15 |
@@ -44,16 +44,20 @@
|
| 16 |
#endif
|
| 17 |
|
| 18 |
// Figure out when the fast implementation can be used
|
| 19 |
-#if VNL_CONFIG_ENABLE_SSE2_ROUNDING
|
| 20 |
+#if VNL_CONFIG_ENABLE_SSE2_ROUNDING && defined(__SSE2__)
|
| 21 |
# if !VXL_HAS_EMMINTRIN_H
|
| 22 |
# error "Required file emmintrin.h for SSE2 not found"
|
| 23 |
# else
|
| 24 |
# include <emmintrin.h> // sse 2 intrinsics
|
| 25 |
+# define USE_SSE2_IMPL 1
|
| 26 |
# endif
|
| 27 |
+#else
|
| 28 |
+# define USE_SSE2_IMPL 0
|
| 29 |
#endif
|
| 30 |
// Turn on fast impl when using GCC on Intel-based machines with the following exception:
|
| 31 |
// PPC with Mac OS X
|
| 32 |
-#if defined(__GNUC__) && (!defined(__APPLE__) || !defined(__ppc__) )
|
| 33 |
+// GCCXML
|
| 34 |
+#if defined(__GNUC__) && (defined(__i386__) || defined(__i386) || defined(__x86_64__) || defined(__x86_64)) && (!defined(__APPLE__) || !defined(__ppc__) )
|
| 35 |
# define GCC_USE_FAST_IMPL 1
|
| 36 |
#else
|
| 37 |
# define GCC_USE_FAST_IMPL 0
|
| 38 |
@@ -201,7 +205,7 @@
|
| 39 |
// We assume that the rounding mode is not changed from the default
|
| 40 |
// one (or at least that it is always restored to the default one).
|
| 41 |
|
| 42 |
-#if VNL_CONFIG_ENABLE_SSE2_ROUNDING // Fast sse2 implementation
|
| 43 |
+#if USE_SSE2_IMPL // Fast sse2 implementation
|
| 44 |
|
| 45 |
inline int vnl_math_rnd_halfinttoeven(float x)
|
| 46 |
{
|
| 47 |
@@ -312,7 +316,7 @@
|
| 48 |
// We also assume that the rounding mode is not changed from the default
|
| 49 |
// one (or at least that it is always restored to the default one).
|
| 50 |
|
| 51 |
-#if VNL_CONFIG_ENABLE_SSE2_ROUNDING || GCC_USE_FAST_IMPL || VC_USE_FAST_IMPL
|
| 52 |
+#if USE_SSE2_IMPL || GCC_USE_FAST_IMPL || VC_USE_FAST_IMPL
|
| 53 |
|
| 54 |
inline int vnl_math_rnd_halfintup(float x) { return vnl_math_rnd_halfinttoeven(2*x+0.5f)>>1; }
|
| 55 |
inline int vnl_math_rnd_halfintup(double x) { return vnl_math_rnd_halfinttoeven(2*x+0.5)>>1; }
|
| 56 |
@@ -345,7 +349,7 @@
|
| 57 |
// We assume that the rounding mode is not changed from the default
|
| 58 |
// one (or at least that it is always restored to the default one).
|
| 59 |
|
| 60 |
-#if VNL_CONFIG_ENABLE_SSE2_ROUNDING || GCC_USE_FAST_IMPL || VC_USE_FAST_IMPL
|
| 61 |
+#if USE_SSE2_IMPL || GCC_USE_FAST_IMPL || VC_USE_FAST_IMPL
|
| 62 |
|
| 63 |
inline int vnl_math_rnd(float x) { return vnl_math_rnd_halfinttoeven(x); }
|
| 64 |
inline int vnl_math_rnd(double x) { return vnl_math_rnd_halfinttoeven(x); }
|
| 65 |
@@ -367,7 +371,7 @@
|
| 66 |
// We also assume that the rounding mode is not changed from the default
|
| 67 |
// one (or at least that it is always restored to the default one).
|
| 68 |
|
| 69 |
-#if VNL_CONFIG_ENABLE_SSE2_ROUNDING // Fast sse2 implementation
|
| 70 |
+#if USE_SSE2_IMPL // Fast sse2 implementation
|
| 71 |
|
| 72 |
inline int vnl_math_floor(float x)
|
| 73 |
{
|
| 74 |
@@ -452,7 +456,7 @@
|
| 75 |
// We also assume that the rounding mode is not changed from the default
|
| 76 |
// one (or at least that it is always restored to the default one).
|
| 77 |
|
| 78 |
-#if VNL_CONFIG_ENABLE_SSE2_ROUNDING // Fast sse2 implementation
|
| 79 |
+#if USE_SSE2_IMPL // Fast sse2 implementation
|
| 80 |
|
| 81 |
inline int vnl_math_ceil(float x)
|
| 82 |
{
|
| 83 |
Index: vxl-1.17.0/core/vil/vil_round.h
|
| 84 |
===================================================================
|
| 85 |
--- vxl-1.17.0.orig/core/vil/vil_round.h 2009-05-08 17:47:55.000000000 +0200
|
| 86 |
+++ vxl-1.17.0/core/vil/vil_round.h 2012-06-01 15:44:56.321752813 +0200
|
| 87 |
@@ -25,9 +25,10 @@
|
| 88 |
# endif
|
| 89 |
#endif
|
| 90 |
|
| 91 |
+#define DEFINED_INTEL (defined(__i386__) || defined(__x86_64__))
|
| 92 |
// Turn on fast impl when using GCC on Intel-based machines with the following exception:
|
| 93 |
// PPC with Mac OS X
|
| 94 |
-#if defined(__GNUC__) && (!defined(__APPLE__) || !defined(__ppc__) )
|
| 95 |
+#if defined(__GNUC__) && DEFINED_INTEL
|
| 96 |
# define GCC_USE_FAST_IMPL 1
|
| 97 |
#else
|
| 98 |
# define GCC_USE_FAST_IMPL 0
|