zeroshade commented on code in PR #14255: URL: https://github.com/apache/arrow/pull/14255#discussion_r982540899
########## go/arrow/compute/internal/kernels/base_arithmetic.go: ########## @@ -0,0 +1,141 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package kernels + +import ( + "fmt" + "math/bits" + + "github.com/apache/arrow/go/v10/arrow" + "github.com/apache/arrow/go/v10/arrow/compute/internal/exec" + "github.com/apache/arrow/go/v10/arrow/internal/debug" + "golang.org/x/exp/constraints" +) + +type ArithmeticOp int8 + +const ( + OpAdd ArithmeticOp = iota + OpAddChecked + OpSub + OpSubChecked +) + +func getGoArithmeticBinaryOpsFloating[T constraints.Float](op ArithmeticOp) binaryOps[T, T, T] { + Op := map[ArithmeticOp]func(a, b T, e *error) T{ + OpAdd: func(a, b T, _ *error) T { return a + b }, + OpAddChecked: func(a, b T, _ *error) T { return a + b }, + OpSub: func(a, b T, _ *error) T { return a - b }, + OpSubChecked: func(a, b T, _ *error) T { return a - b }, + }[op] + + return binaryOps[T, T, T]{ + arrArr: func(_ *exec.KernelCtx, left, right, out []T) error { + var err error + for i := range out { + out[i] = Op(left[i], right[i], &err) Review Comment: I'd have to check the assembly as I don't know offhand whether or not it can inline it in this case. But that's a good point, I'll double check the resulting assembly and see if it is inlining it and if not, what I can do to ensure it does. -- 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]
