AntoinePrv commented on code in PR #50030:
URL: https://github.com/apache/arrow/pull/50030#discussion_r3316142160


##########
cpp/src/parquet/bloom_filter_avx2.cc:
##########
@@ -0,0 +1,46 @@
+// 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.
+
+#include <xsimd/xsimd.hpp>
+
+#include "parquet/bloom_filter_avx2_internal.h"
+
+namespace parquet::internal {
+
+// Parquet SBBF probe (256-bit block, 8 SALT-derived bits per probe). Unrelated
+// to cpp/src/arrow/acero/bloom_filter_avx2.cc -- Acero's blocked bloom filter
+// is a different algorithm (64-bit block, ~4 bits per probe, in-memory only)
+// and the two kernels are not interchangeable. See the Parquet spec for the
+// SBBF on-disk layout this kernel must match.
+//
+// Spelled in xsimd rather than reusing the autovectorized body in
+// bloom_filter_block_inc.h: only clang lowers that body to a single vptest;
+// gcc and MSVC emit a longer horizontal vpor reduction.
+bool FindHashBlockAvx2(const uint32_t* block, const uint32_t* salt, uint32_t 
key) {
+  using batch = xsimd::batch<uint32_t, xsimd::avx2>;
+  const batch mask = batch(uint32_t{1})
+                     << ((batch(key) * batch::load_unaligned(salt)) >> 27);

Review Comment:
   Consider using `xsimd::bitwise_rshift<27>(...)` instead of `>> 27`.
   In the former case 27 is deduced as a compile time constant and the code 
path potentially more performant.



##########
cpp/src/parquet/bloom_filter.cc:
##########
@@ -34,6 +35,35 @@
 #include "parquet/thrift_internal.h"
 #include "parquet/xxhasher.h"
 
+#if defined(ARROW_HAVE_RUNTIME_AVX2)
+#  include "parquet/bloom_filter_avx2_internal.h"
+#endif
+
+#define PARQUET_IMPL_NAMESPACE standard
+#include "parquet/bloom_filter_block_inc.h"
+#undef PARQUET_IMPL_NAMESPACE
+
+#include "arrow/util/dispatch_internal.h"
+
+namespace parquet::internal {
+namespace {
+
+using ::arrow::internal::DynamicDispatch;
+
+struct FindHashBlockDynamicFunction {
+  using FunctionType = decltype(&standard::FindHashBlockImpl);
+
+  static constexpr auto targets() {
+    return std::array{
+        ARROW_DISPATCH_TARGET_NONE(&standard::FindHashBlockImpl)  //
+        ARROW_DISPATCH_TARGET_AVX2(&FindHashBlockAvx2)            //

Review Comment:
   > I don't see other similar places have #if defined(ARROW_HAVE_RUNTIME_AVX2) 
protection
   
   It is not needed, `ARROW_DISPATCH_TARGET_AVX2` handles that.



##########
cpp/src/parquet/bloom_filter_avx2.cc:
##########
@@ -0,0 +1,46 @@
+// 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.
+
+#include <xsimd/xsimd.hpp>
+
+#include "parquet/bloom_filter_avx2_internal.h"
+
+namespace parquet::internal {
+
+// Parquet SBBF probe (256-bit block, 8 SALT-derived bits per probe). Unrelated
+// to cpp/src/arrow/acero/bloom_filter_avx2.cc -- Acero's blocked bloom filter
+// is a different algorithm (64-bit block, ~4 bits per probe, in-memory only)
+// and the two kernels are not interchangeable. See the Parquet spec for the
+// SBBF on-disk layout this kernel must match.
+//
+// Spelled in xsimd rather than reusing the autovectorized body in
+// bloom_filter_block_inc.h: only clang lowers that body to a single vptest;
+// gcc and MSVC emit a longer horizontal vpor reduction.
+bool FindHashBlockAvx2(const uint32_t* block, const uint32_t* salt, uint32_t 
key) {
+  using batch = xsimd::batch<uint32_t, xsimd::avx2>;

Review Comment:
   ```suggestion
     using batch = xsimd::batch<uint32_t>;
   ```
   Is all it takes to make this code run with all SIMD types.



-- 
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