]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
1 | // Licensed to the Apache Software Foundation (ASF) under one |
2 | // or more contributor license agreements. See the NOTICE file | |
3 | // distributed with this work for additional information | |
4 | // regarding copyright ownership. The ASF licenses this file | |
5 | // to you under the Apache License, Version 2.0 (the | |
6 | // "License"); you may not use this file except in compliance | |
7 | // with the License. You may obtain a copy of the License at | |
8 | // | |
9 | // http://www.apache.org/licenses/LICENSE-2.0 | |
10 | // | |
11 | // Unless required by applicable law or agreed to in writing, | |
12 | // software distributed under the License is distributed on an | |
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
14 | // KIND, either express or implied. See the License for the | |
15 | // specific language governing permissions and limitations | |
16 | // under the License. | |
17 | ||
18 | #include "arrow/compute/kernels/aggregate_basic_internal.h" | |
19 | ||
20 | namespace arrow { | |
21 | namespace compute { | |
22 | namespace internal { | |
23 | ||
24 | // ---------------------------------------------------------------------- | |
25 | // Sum implementation | |
26 | ||
27 | template <typename ArrowType> | |
28 | struct SumImplAvx512 : public SumImpl<ArrowType, SimdLevel::AVX512> { | |
29 | using SumImpl<ArrowType, SimdLevel::AVX512>::SumImpl; | |
30 | }; | |
31 | ||
32 | template <typename ArrowType> | |
33 | struct MeanImplAvx512 : public MeanImpl<ArrowType, SimdLevel::AVX512> { | |
34 | using MeanImpl<ArrowType, SimdLevel::AVX512>::MeanImpl; | |
35 | }; | |
36 | ||
37 | Result<std::unique_ptr<KernelState>> SumInitAvx512(KernelContext* ctx, | |
38 | const KernelInitArgs& args) { | |
39 | SumLikeInit<SumImplAvx512> visitor( | |
40 | ctx, args.inputs[0].type, | |
41 | static_cast<const ScalarAggregateOptions&>(*args.options)); | |
42 | return visitor.Create(); | |
43 | } | |
44 | ||
45 | Result<std::unique_ptr<KernelState>> MeanInitAvx512(KernelContext* ctx, | |
46 | const KernelInitArgs& args) { | |
47 | SumLikeInit<MeanImplAvx512> visitor( | |
48 | ctx, args.inputs[0].type, | |
49 | static_cast<const ScalarAggregateOptions&>(*args.options)); | |
50 | return visitor.Create(); | |
51 | } | |
52 | ||
53 | // ---------------------------------------------------------------------- | |
54 | // MinMax implementation | |
55 | ||
56 | Result<std::unique_ptr<KernelState>> MinMaxInitAvx512(KernelContext* ctx, | |
57 | const KernelInitArgs& args) { | |
58 | ARROW_ASSIGN_OR_RAISE(auto out_type, | |
59 | args.kernel->signature->out_type().Resolve(ctx, args.inputs)); | |
60 | MinMaxInitState<SimdLevel::AVX512> visitor( | |
61 | ctx, *args.inputs[0].type, std::move(out_type.type), | |
62 | static_cast<const ScalarAggregateOptions&>(*args.options)); | |
63 | return visitor.Create(); | |
64 | } | |
65 | ||
66 | void AddSumAvx512AggKernels(ScalarAggregateFunction* func) { | |
67 | AddBasicAggKernels(SumInitAvx512, SignedIntTypes(), int64(), func, SimdLevel::AVX512); | |
68 | AddBasicAggKernels(SumInitAvx512, UnsignedIntTypes(), uint64(), func, | |
69 | SimdLevel::AVX512); | |
70 | AddBasicAggKernels(SumInitAvx512, FloatingPointTypes(), float64(), func, | |
71 | SimdLevel::AVX512); | |
72 | } | |
73 | ||
74 | void AddMeanAvx512AggKernels(ScalarAggregateFunction* func) { | |
75 | AddBasicAggKernels(MeanInitAvx512, NumericTypes(), float64(), func, SimdLevel::AVX512); | |
76 | } | |
77 | ||
78 | void AddMinMaxAvx512AggKernels(ScalarAggregateFunction* func) { | |
79 | // Enable 32/64 int types for avx512 variants, no advantage on 8/16 int. | |
80 | AddMinMaxKernels(MinMaxInitAvx512, {int32(), uint32(), int64(), uint64()}, func, | |
81 | SimdLevel::AVX512); | |
82 | AddMinMaxKernels(MinMaxInitAvx512, TemporalTypes(), func, SimdLevel::AVX512); | |
83 | AddMinMaxKernels(MinMaxInitAvx512, BaseBinaryTypes(), func, SimdLevel::AVX2); | |
84 | AddMinMaxKernel(MinMaxInitAvx512, Type::FIXED_SIZE_BINARY, func, SimdLevel::AVX2); | |
85 | AddMinMaxKernel(MinMaxInitAvx512, Type::INTERVAL_MONTHS, func, SimdLevel::AVX512); | |
86 | } | |
87 | ||
88 | } // namespace internal | |
89 | } // namespace compute | |
90 | } // namespace arrow |