lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [04/10] lucenenet git commit: BUG: Lucene.Net.Util.Packed (MonotonicAppendingInt64Buffer + MonotonicBlockPackedReader + MonotonicBlockPackedWriter): JIT bug in x86 environment makes the float calculation incorrect when not explicitly casting to float bef
Date Tue, 16 May 2017 14:28:24 GMT
BUG: Lucene.Net.Util.Packed (MonotonicAppendingInt64Buffer + MonotonicBlockPackedReader + MonotonicBlockPackedWriter):
JIT bug in x86 environment makes the float calculation incorrect when not explicitly casting
to float before casting to long.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/0cc3cfe8
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/0cc3cfe8
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/0cc3cfe8

Branch: refs/heads/master
Commit: 0cc3cfe8773bec6aefe6ab8245cd82cb7994b6aa
Parents: 8eeb071
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun May 14 02:10:19 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Tue May 16 19:17:11 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Codecs/project.json                      |  6 +++---
 .../Util/Packed/MonotonicAppendingLongBuffer.cs         | 12 ++++++++----
 .../Util/Packed/MonotonicBlockPackedReader.cs           |  3 ++-
 .../Util/Packed/MonotonicBlockPackedWriter.cs           |  3 ++-
 4 files changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/0cc3cfe8/src/Lucene.Net.Codecs/project.json
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/project.json b/src/Lucene.Net.Codecs/project.json
index 80a943f..c3e761e 100644
--- a/src/Lucene.Net.Codecs/project.json
+++ b/src/Lucene.Net.Codecs/project.json
@@ -30,12 +30,12 @@
       }
     },
     "net451": {
-      "frameworkAssemblies": {
-        "System.Numerics": "4.0.0.0"
-      },
       "buildOptions": {
         "debugType": "full",
         "define": [ "FEATURE_SERIALIZABLE" ]
+      },
+      "frameworkAssemblies": {
+        "System.Numerics": "4.0.0.0"
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/0cc3cfe8/src/Lucene.Net/Util/Packed/MonotonicAppendingLongBuffer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Util/Packed/MonotonicAppendingLongBuffer.cs b/src/Lucene.Net/Util/Packed/MonotonicAppendingLongBuffer.cs
index c8dd211..bfbaee3 100644
--- a/src/Lucene.Net/Util/Packed/MonotonicAppendingLongBuffer.cs
+++ b/src/Lucene.Net/Util/Packed/MonotonicAppendingLongBuffer.cs
@@ -81,7 +81,8 @@ namespace Lucene.Net.Util.Packed
             }
             else
             {
-                long @base = minValues[block] + (long)(averages[block] * (long)element);
+                // LUCENENET NOTE: IMPORTANT: The cast to float is critical here for it to
work in x86
+                long @base = minValues[block] + (long)(float)(averages[block] * (long)element);
                 if (values[block] == null)
                 {
                     return @base;
@@ -108,7 +109,8 @@ namespace Lucene.Net.Util.Packed
                     int toFill = Math.Min(len, pending.Length - element);
                     for (int r = 0; r < toFill; r++, off++, element++)
                     {
-                        arr[off] = minValues[block] + (long)(averages[block] * (long)element);
+                        // LUCENENET NOTE: IMPORTANT: The cast to float is critical here
for it to work in x86
+                        arr[off] = minValues[block] + (long)(float)(averages[block] * (long)element);
                     }
                     return toFill;
                 }
@@ -118,7 +120,8 @@ namespace Lucene.Net.Util.Packed
                     int read = values[block].Get(element, arr, off, len);
                     for (int r = 0; r < read; r++, off++, element++)
                     {
-                        arr[off] = minValues[block] + (long)(averages[block] * (long)element)
+ ZigZagDecode(arr[off]);
+                        // LUCENENET NOTE: IMPORTANT: The cast to float is critical here
for it to work in x86
+                        arr[off] = minValues[block] + (long)(float)(averages[block] * (long)element)
+ ZigZagDecode(arr[off]);
                     }
                     return read;
                 }
@@ -140,7 +143,8 @@ namespace Lucene.Net.Util.Packed
 
             for (int i = 0; i < pendingOff; ++i)
             {
-                pending[i] = ZigZagEncode(pending[i] - minValues[valuesOff] - (long)(averages[valuesOff]
* (long)i));
+                // LUCENENET NOTE: IMPORTANT: The cast to float is critical here for it to
work in x86
+                pending[i] = ZigZagEncode(pending[i] - minValues[valuesOff] - (long)(float)(averages[valuesOff]
* (long)i));
             }
             long maxDelta = 0;
             for (int i = 0; i < pendingOff; ++i)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/0cc3cfe8/src/Lucene.Net/Util/Packed/MonotonicBlockPackedReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Util/Packed/MonotonicBlockPackedReader.cs b/src/Lucene.Net/Util/Packed/MonotonicBlockPackedReader.cs
index d688001..45c1b8f 100644
--- a/src/Lucene.Net/Util/Packed/MonotonicBlockPackedReader.cs
+++ b/src/Lucene.Net/Util/Packed/MonotonicBlockPackedReader.cs
@@ -81,7 +81,8 @@ namespace Lucene.Net.Util.Packed
             Debug.Assert(index >= 0 && index < valueCount);
             int block = (int)((long)((ulong)index >> blockShift));
             int idx = (int)(index & blockMask);
-            return minValues[block] + (long)(idx * averages[block]) + BlockPackedReaderIterator.ZigZagDecode(subReaders[block].Get(idx));
+            // LUCENENET NOTE: IMPORTANT: The cast to float is critical here for it to work
in x86
+            return minValues[block] + (long)(float)(idx * averages[block]) + BlockPackedReaderIterator.ZigZagDecode(subReaders[block].Get(idx));
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/0cc3cfe8/src/Lucene.Net/Util/Packed/MonotonicBlockPackedWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Util/Packed/MonotonicBlockPackedWriter.cs b/src/Lucene.Net/Util/Packed/MonotonicBlockPackedWriter.cs
index 2a43385..01d6982 100644
--- a/src/Lucene.Net/Util/Packed/MonotonicBlockPackedWriter.cs
+++ b/src/Lucene.Net/Util/Packed/MonotonicBlockPackedWriter.cs
@@ -79,7 +79,8 @@ namespace Lucene.Net.Util.Packed
             long maxZigZagDelta = 0;
             for (int i = 0; i < m_off; ++i)
             {
-                m_values[i] = ZigZagEncode(m_values[i] - min - (long)(avg * i));
+                // LUCENENET NOTE: IMPORTANT: The cast to float is critical here for it to
work in x86
+                m_values[i] = ZigZagEncode(m_values[i] - min - (long)(float)(avg * i));
                 maxZigZagDelta = Math.Max(maxZigZagDelta, m_values[i]);
             }
 


Mime
View raw message