diff --git a/cpp/fury/util/array_util.cc b/cpp/fury/util/array_util.cc new file mode 100644 index 0000000000..e7d89f275d --- /dev/null +++ b/cpp/fury/util/array_util.cc @@ -0,0 +1,28 @@ +/* + * 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. + */ + +#pragma once +#include "fury/util/platform.h" +#include + +namespace fury { +uint16_t getMaxValue(const uint16_t *arr, size_t length); + +void copyArray(const uint16_t *from, uint8_t *to, size_t length); +} // namespace fury diff --git a/cpp/fury/util/array_util.h b/cpp/fury/util/array_util.h index 9bc7053dc9..65a4cd862f 100644 --- a/cpp/fury/util/array_util.h +++ b/cpp/fury/util/array_util.h @@ -23,7 +23,7 @@ namespace fury { #if defined(FURY_HAS_NEON) -inline uint16_t getMaxValue(const uint16_t *arr, size_t length) { +uint16_t getMaxValue(const uint16_t *arr, size_t length) { if (length == 0) { return 0; // Return 0 for empty arrays } @@ -54,7 +54,7 @@ inline uint16_t getMaxValue(const uint16_t *arr, size_t length) { return max_neon; } -inline void copyArray(const uint16_t *from, uint8_t *to, size_t length) { +void copyArray(const uint16_t *from, uint8_t *to, size_t length) { size_t i = 0; for (; i + 7 < length; i += 8) { uint16x8_t src = vld1q_u16(&from[i]); @@ -68,7 +68,7 @@ inline void copyArray(const uint16_t *from, uint8_t *to, size_t length) { } } #elif defined(FURY_HAS_SSE2) -inline uint16_t getMaxValue(const uint16_t *arr, size_t length) { +uint16_t getMaxValue(const uint16_t *arr, size_t length) { if (length == 0) { return 0; // Return 0 for empty arrays } @@ -100,7 +100,7 @@ inline uint16_t getMaxValue(const uint16_t *arr, size_t length) { return max_sse; } -inline void copyArray(const uint16_t *from, uint8_t *to, size_t length) { +void copyArray(const uint16_t *from, uint8_t *to, size_t length) { size_t i = 0; __m128i mask = _mm_set1_epi16(0xFF); // Mask to zero out the high byte for (; i + 7 < length; i += 8) { @@ -116,7 +116,7 @@ inline void copyArray(const uint16_t *from, uint8_t *to, size_t length) { } } #else -inline uint16_t getMaxValue(const uint16_t *arr, size_t length) { +uint16_t getMaxValue(const uint16_t *arr, size_t length) { if (length == 0) { return 0; // Return 0 for empty arrays } @@ -129,7 +129,7 @@ inline uint16_t getMaxValue(const uint16_t *arr, size_t length) { return max_val; } -inline void copyArray(const uint16_t *from, uint8_t *to, size_t length) { +void copyArray(const uint16_t *from, uint8_t *to, size_t length) { // Fallback for systems without SSE2/NEON for (size_t i = 0; i < length; ++i) { to[i] = static_cast(from[i]);