github.com/apache/arrow/go/v10@v10.0.1/internal/utils/min_max_sse4_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 "unsafe"
    23  
    24  // This file contains convenience functions for utilizing SSE4 intrinsics to quickly
    25  // and efficiently get the min and max from an integral slice.
    26  
    27  //go:noescape
    28  func _int8_max_min_sse4(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer)
    29  
    30  func int8MaxMinSSE4(values []int8) (min, max int8) {
    31  	_int8_max_min_sse4(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max))
    32  	return
    33  }
    34  
    35  //go:noescape
    36  func _uint8_max_min_sse4(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer)
    37  
    38  func uint8MaxMinSSE4(values []uint8) (min, max uint8) {
    39  	_uint8_max_min_sse4(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max))
    40  	return
    41  }
    42  
    43  //go:noescape
    44  func _int16_max_min_sse4(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer)
    45  
    46  func int16MaxMinSSE4(values []int16) (min, max int16) {
    47  	_int16_max_min_sse4(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max))
    48  	return
    49  }
    50  
    51  //go:noescape
    52  func _uint16_max_min_sse4(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer)
    53  
    54  func uint16MaxMinSSE4(values []uint16) (min, max uint16) {
    55  	_uint16_max_min_sse4(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max))
    56  	return
    57  }
    58  
    59  //go:noescape
    60  func _int32_max_min_sse4(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer)
    61  
    62  func int32MaxMinSSE4(values []int32) (min, max int32) {
    63  	_int32_max_min_sse4(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max))
    64  	return
    65  }
    66  
    67  //go:noescape
    68  func _uint32_max_min_sse4(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer)
    69  
    70  func uint32MaxMinSSE4(values []uint32) (min, max uint32) {
    71  	_uint32_max_min_sse4(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max))
    72  	return
    73  }
    74  
    75  //go:noescape
    76  func _int64_max_min_sse4(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer)
    77  
    78  func int64MaxMinSSE4(values []int64) (min, max int64) {
    79  	_int64_max_min_sse4(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max))
    80  	return
    81  }
    82  
    83  //go:noescape
    84  func _uint64_max_min_sse4(values unsafe.Pointer, length int, minout, maxout unsafe.Pointer)
    85  
    86  func uint64MaxMinSSE4(values []uint64) (min, max uint64) {
    87  	_uint64_max_min_sse4(unsafe.Pointer(&values[0]), len(values), unsafe.Pointer(&min), unsafe.Pointer(&max))
    88  	return
    89  }