github.com/apache/arrow/go/v10@v10.0.1/internal/utils/min_max_avx2_amd64.go (about) 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, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 17 //go:build !noasm 18 // +build !noasm 19 20 package utils 21 22 import ( 23 "unsafe" 24 ) 25 26 // This file contains convenience functions for utilizing AVX2 intrinsics to quickly 27 // and efficiently get the min and max from an integral slice. 28 29 //go:noescape 30 func _int8_max_min_avx2(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer) 31 32 func int8MaxMinAVX2(values []int8) (min, max int8) { 33 _int8_max_min_avx2(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max)) 34 return 35 } 36 37 //go:noescape 38 func _uint8_max_min_avx2(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer) 39 40 func uint8MaxMinAVX2(values []uint8) (min, max uint8) { 41 _uint8_max_min_avx2(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max)) 42 return 43 } 44 45 //go:noescape 46 func _int16_max_min_avx2(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer) 47 48 func int16MaxMinAVX2(values []int16) (min, max int16) { 49 _int16_max_min_avx2(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max)) 50 return 51 } 52 53 //go:noescape 54 func _uint16_max_min_avx2(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer) 55 56 func uint16MaxMinAVX2(values []uint16) (min, max uint16) { 57 _uint16_max_min_avx2(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max)) 58 return 59 } 60 61 //go:noescape 62 func _int32_max_min_avx2(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer) 63 64 func int32MaxMinAVX2(values []int32) (min, max int32) { 65 _int32_max_min_avx2(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max)) 66 return 67 } 68 69 //go:noescape 70 func _uint32_max_min_avx2(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer) 71 72 func uint32MaxMinAVX2(values []uint32) (min, max uint32) { 73 _uint32_max_min_avx2(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max)) 74 return 75 } 76 77 //go:noescape 78 func _int64_max_min_avx2(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer) 79 80 func int64MaxMinAVX2(values []int64) (min, max int64) { 81 _int64_max_min_avx2(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max)) 82 return 83 } 84 85 //go:noescape 86 func _uint64_max_min_avx2(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer) 87 88 func uint64MaxMinAVX2(values []uint64) (min, max uint64) { 89 _uint64_max_min_avx2(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max)) 90 return 91 }