mobiusklein commented on code in PR #257:
URL: https://github.com/apache/arrow-dotnet/pull/257#discussion_r3113441560


##########
src/Apache.Arrow.Operations/Comparison.cs:
##########
@@ -0,0 +1,710 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+using System;
+using System.Numerics;
+using System.Runtime.Intrinsics;
+
+using Apache.Arrow.Memory;
+using Apache.Arrow.Types;
+
+
+namespace Apache.Arrow.Operations;
+
+public static class BitVectorOps
+{
+    public static ArrowBuffer OnesComplement(ArrowBuffer buffer)
+    {
+        var builder = new ArrowBuffer.BitmapBuilder(buffer.Length * 8);
+        var store = builder.Span;
+        int offset = 0;
+        int size = buffer.Span.Length;
+
+        while ((size - offset) >= 8)
+        {
+            if ((size - offset) >= 64)

Review Comment:
   Combining this with your earlier suggestion about conditioning on hardware 
acceleration, to cascade with fewer branches:
   ```csharp
           if (Vector512.IsHardwareAccelerated)
           {
               while ((size - offset) >= 64) { }
           }
           if (Vector256.IsHardwareAccelerated)
           {
               while ((size - offset) >= 32) { }
           }
           while ((size - offset) >= 16) { }
           while ((size - offset) >= 8) { }
           for (var i = offset; i < size; i++) { }
   ```
   This way, the hardware acceleration check hits once, then loops until it 
runs out of sufficient data to fill the entire register, then drops to the next 
size down. Going much further for faster SIMD is beyond the scope I had in mind.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to