You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ks...@apache.org on 2020/08/11 15:57:47 UTC
[arrow] 18/22: ARROW-9643: [C++] Only register the SIMD variants
when it's supported.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-1.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit abf6b07e8295cd21829fc569b0263b63527b514e
Author: Frank Du <fr...@intel.com>
AuthorDate: Fri Aug 7 11:42:51 2020 -0500
ARROW-9643: [C++] Only register the SIMD variants when it's supported.
Fix illegal instruction on GCC 7.5 build, compiler may use advanced instruction just for a register routine.
Signed-off-by: Frank Du <fr...@intel.com>
Closes #7903 from jianxind/ARROW-9643
Authored-by: Frank Du <fr...@intel.com>
Signed-off-by: Wes McKinney <we...@apache.org>
---
cpp/src/arrow/compute/kernels/aggregate_basic.cc | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/cpp/src/arrow/compute/kernels/aggregate_basic.cc b/cpp/src/arrow/compute/kernels/aggregate_basic.cc
index 2349360..ba083c1 100644
--- a/cpp/src/arrow/compute/kernels/aggregate_basic.cc
+++ b/cpp/src/arrow/compute/kernels/aggregate_basic.cc
@@ -21,6 +21,7 @@
#include "arrow/compute/kernels/aggregate_basic_internal.h"
#include "arrow/compute/kernels/aggregate_internal.h"
#include "arrow/compute/kernels/common.h"
+#include "arrow/util/cpu_info.h"
#include "arrow/util/make_unique.h"
namespace arrow {
@@ -389,12 +390,35 @@ void RegisterScalarAggregateBasic(FunctionRegistry* registry) {
func.get());
aggregate::AddBasicAggKernels(aggregate::SumInit, FloatingPointTypes(), float64(),
func.get());
+ // Add the SIMD variants for sum
+ auto cpu_info = arrow::internal::CpuInfo::GetInstance();
+#if defined(ARROW_HAVE_RUNTIME_AVX2)
+ if (cpu_info->IsSupported(arrow::internal::CpuInfo::AVX2)) {
+ aggregate::AddSumAvx2AggKernels(func.get());
+ }
+#endif
+#if defined(ARROW_HAVE_RUNTIME_AVX512)
+ if (cpu_info->IsSupported(arrow::internal::CpuInfo::AVX512)) {
+ aggregate::AddSumAvx512AggKernels(func.get());
+ }
+#endif
DCHECK_OK(registry->AddFunction(std::move(func)));
func = std::make_shared<ScalarAggregateFunction>("mean", Arity::Unary());
aggregate::AddBasicAggKernels(aggregate::MeanInit, {boolean()}, float64(), func.get());
aggregate::AddBasicAggKernels(aggregate::MeanInit, NumericTypes(), float64(),
func.get());
+ // Add the SIMD variants for mean
+#if defined(ARROW_HAVE_RUNTIME_AVX2)
+ if (cpu_info->IsSupported(arrow::internal::CpuInfo::AVX2)) {
+ aggregate::AddMeanAvx2AggKernels(func.get());
+ }
+#endif
+#if defined(ARROW_HAVE_RUNTIME_AVX512)
+ if (cpu_info->IsSupported(arrow::internal::CpuInfo::AVX512)) {
+ aggregate::AddMeanAvx512AggKernels(func.get());
+ }
+#endif
DCHECK_OK(registry->AddFunction(std::move(func)));
static auto default_minmax_options = MinMaxOptions::Defaults();