mapleFU commented on issue #43687:
URL: https://github.com/apache/arrow/issues/43687#issuecomment-2289609943
> The code checks for CPU support for AVX512 instructions. Then it checks if
a kernel exists. If an AVX512 kernel doesn't exist... no problem, it will look
for the AVX2 kernel.
I mean when a avx512 machine and avx2 `CpuInfo` enabled:
(1) Both are registered
```
void AddMinMaxAvx512AggKernels(ScalarAggregateFunction* func) {
// Enable 32/64 int types for avx512 variants, no advantage on 8/16 int.
AddMinMaxKernels(MinMaxInitAvx512, {int32(), uint32(), int64(), uint64()},
func,
SimdLevel::AVX512);
AddMinMaxKernels(MinMaxInitAvx512, TemporalTypes(), func,
SimdLevel::AVX512);
AddMinMaxKernels(MinMaxInitAvx512, BaseBinaryTypes(), func,
SimdLevel::AVX2);
AddMinMaxKernel(MinMaxInitAvx512, Type::FIXED_SIZE_BINARY, func,
SimdLevel::AVX2);
AddMinMaxKernel(MinMaxInitAvx512, Type::INTERVAL_MONTHS, func,
SimdLevel::AVX512);
}
void AddMinMaxAvx2AggKernels(ScalarAggregateFunction* func) {
// Enable int types for AVX2 variants.
// No auto vectorize for float/double as it use fmin/fmax which has NaN
handling.
AddMinMaxKernels(MinMaxInitAvx2, IntTypes(), func, SimdLevel::AVX2);
AddMinMaxKernels(MinMaxInitAvx2, TemporalTypes(), func, SimdLevel::AVX2);
AddMinMaxKernels(MinMaxInitAvx2, BaseBinaryTypes(), func, SimdLevel::AVX2);
AddMinMaxKernel(MinMaxInitAvx2, Type::FIXED_SIZE_BINARY, func,
SimdLevel::AVX2);
AddMinMaxKernel(MinMaxInitAvx2, Type::INTERVAL_MONTHS, func,
SimdLevel::AVX2);
}
```
(2) When dispatch, firstly, avx2 is set to
`kernel_matches[SimdLevel::AVX2]`, and then, avx512 version is set to
`kernel_matches[SimdLevel::AVX2]`, which overrides the avx2 code
(3.1) When user with avx512 want to select avx512, the code works well, it
check avx512, and doesn't find any thing. then it fallback to avx2
(3.2) When user with avx512 want to select avx2, the code doesn't works
well, it check avx2, and get the kernel compiled with avx512
--
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]