From 0b6acbd23613f1b315a36567d084a0e741778c0a Mon Sep 17 00:00:00 2001 From: Michael Platings Date: Mon, 22 Jan 2024 22:00:58 +0000 Subject: [PATCH] Enable cpplint & shellcheck Also fix or suppress cpplint errors. --- .gitlab-ci.yml | 2 +- docker/Dockerfile | 2 + intrinsiccv/include/dispatch.h | 2 +- intrinsiccv/include/intrinsiccv.h | 66 ++++---- intrinsiccv/include/morphology/workspace.h | 1 - intrinsiccv/include/neon.h | 6 +- intrinsiccv/include/neon_intrinsics.h | 148 +++++++++--------- intrinsiccv/include/operations.h | 3 + intrinsiccv/include/sve2.h | 6 +- intrinsiccv/include/types.h | 1 + intrinsiccv/include/utils.h | 1 + intrinsiccv/src/arithmetics/multiply_sve2.cpp | 2 +- intrinsiccv/src/arithmetics/scale_neon.cpp | 7 +- .../src/arithmetics/transpose_neon.cpp | 6 +- intrinsiccv/src/conversions/merge_neon.cpp | 4 +- intrinsiccv/src/conversions/split_neon.cpp | 5 +- intrinsiccv/src/conversions/yuv_to_rgb_sc.h | 2 + intrinsiccv/src/morphology/morphology_sc.h | 53 ++++--- intrinsiccv/src/resize/resize_sc.h | 12 +- scripts/ci.sh | 5 + scripts/cpplint.sh | 35 +++++ test/api/test_min_max.cpp | 2 - test/api/test_saturating_multiply.cpp | 30 ++-- 23 files changed, 227 insertions(+), 174 deletions(-) create mode 100755 scripts/cpplint.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d33718f37..d12633a5c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -image: registry.gitlab.arm.com/intrinsiccv/intrinsiccv:2 +image: registry.gitlab.arm.com/intrinsiccv/intrinsiccv:3 build: tags: diff --git a/docker/Dockerfile b/docker/Dockerfile index b5f42be90..3eed4a1e9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get update \ patch \ pipx \ python3-six \ + shellcheck \ software-properties-common \ wget @@ -39,6 +40,7 @@ RUN wget -q https://apt.llvm.org/llvm-snapshot.gpg.key -O /etc/apt/trusted.gpg.d libclang-rt-${LLVM_VERSION}-dev \ llvm-${LLVM_VERSION} +RUN pipx install cpplint==1.6.1 RUN pipx install gcovr==6.0 RUN pipx install reuse==3.0.0 diff --git a/intrinsiccv/include/dispatch.h b/intrinsiccv/include/dispatch.h index 0c035eb0f..43a248d9c 100644 --- a/intrinsiccv/include/dispatch.h +++ b/intrinsiccv/include/dispatch.h @@ -100,7 +100,7 @@ static inline IFuncImplType default_ifunc_resolver( HwCapTy hwcap, __ifunc_arg_t *arg) { \ IFuncImpls impls = impls_builder(); \ return default_ifunc_resolver(make_hwcaps(hwcap, arg), impls); \ - }; \ + } \ \ extern "C" retty intrinsiccv_##api_name(__VA_ARGS__) \ INTRINSICCV_ATTR_IFUNC("intrinsiccv_" #api_name "_ifunc_resolver") diff --git a/intrinsiccv/include/intrinsiccv.h b/intrinsiccv/include/intrinsiccv.h index a2d378a97..a85c7b499 100644 --- a/intrinsiccv/include/intrinsiccv.h +++ b/intrinsiccv/include/intrinsiccv.h @@ -14,11 +14,11 @@ extern "C" { #define INTRINSICCV_C_API(name) intrinsiccv_##name -#define INTRINSICCV_BINARY_OP(name, type, ...) \ - void INTRINSICCV_C_API(name)(const type *src_a, size_t src_a_stride, \ - const type *src_b, size_t src_b_stride, \ - type *dst, size_t dst_stride, size_t width, \ - size_t height __VA_OPT__(, ) __VA_ARGS__) +#define INTRINSICCV_BINARY_OP(name, type, ...) \ + void INTRINSICCV_C_API(name)( \ + const type *src_a, size_t src_a_stride, const type *src_b, \ + size_t src_b_stride, type *dst, size_t dst_stride, size_t width, \ + size_t height __VA_OPT__(, ) __VA_ARGS__) // NOLINT(whitespace/parens) /// Adds the values of the corresponding elements in `src_a` and `src_b`, and /// puts the result into `dst`. @@ -31,15 +31,15 @@ extern "C" { /// @param src_a Pointer to the first source data. Must be non-null. /// @param src_b Pointer to the second source data. Must be non-null. /// @param src_a_stride Distance in bytes from the start of one row to the -/// start of the next row for the src_a. -/// Must not be less than width * sizeof(type). +/// start of the next row for the src_a. +/// Must not be less than width * sizeof(type). /// @param src_b_stride Distance in bytes from the start of one row to the -/// start of the next row for the src_b. -/// Must not be less than width * sizeof(type). +/// start of the next row for the src_b. +/// Must not be less than width * sizeof(type). /// @param dst Pointer to the destination data. Must be non-null. -/// @param dst_stride Distance in bytes from the start of one row to the -/// start of the next row for the destination. -/// Must not be less than width * sizeof(type). +/// @param dst_stride Distance in bytes from the start of one row to the +/// start of the next row for the destination. +/// Must not be less than width * sizeof(type). /// @param width How many elements are in a row /// @param height How many rows are in the data /// @@ -63,15 +63,15 @@ INTRINSICCV_BINARY_OP(saturating_add_u64, uint64_t); /// @param src_a Pointer to the first source data. Must be non-null. /// @param src_b Pointer to the second source data. Must be non-null. /// @param src_a_stride Distance in bytes from the start of one row to the -/// start of the next row for the src_a. -/// Must not be less than width * sizeof(type). +/// start of the next row for the src_a. +/// Must not be less than width * sizeof(type). /// @param src_b_stride Distance in bytes from the start of one row to the -/// start of the next row for the src_b. -/// Must not be less than width * sizeof(type). +/// start of the next row for the src_b. +/// Must not be less than width * sizeof(type). /// @param dst Pointer to the destination data. Must be non-null. -/// @param dst_stride Distance in bytes from the start of one row to the -/// start of the next row for the destination. -/// Must not be less than width * sizeof(type). +/// @param dst_stride Distance in bytes from the start of one row to the +/// start of the next row for the destination. +/// Must not be less than width * sizeof(type). /// @param width How many elements are in a row /// @param height How many rows are in the data /// @@ -95,15 +95,15 @@ INTRINSICCV_BINARY_OP(saturating_sub_u64, uint64_t); /// @param src_a Pointer to the first source data. Must be non-null. /// @param src_b Pointer to the second source data. Must be non-null. /// @param src_a_stride Distance in bytes from the start of one row to the -/// start of the next row for the src_a. -/// Must not be less than width * sizeof(type). +/// start of the next row for the src_a. +/// Must not be less than width * sizeof(type). /// @param src_b_stride Distance in bytes from the start of one row to the -/// start of the next row for the src_b. -/// Must not be less than width * sizeof(type). +/// start of the next row for the src_b. +/// Must not be less than width * sizeof(type). /// @param dst Pointer to the destination data. Must be non-null. -/// @param dst_stride Distance in bytes from the start of one row to the -/// start of the next row for the destination. -/// Must not be less than width * sizeof(type). +/// @param dst_stride Distance in bytes from the start of one row to the +/// start of the next row for the destination. +/// Must not be less than width * sizeof(type). /// @param width How many elements are in a row /// @param height How many rows are in the data /// @@ -124,15 +124,15 @@ INTRINSICCV_BINARY_OP(saturating_absdiff_s32, int32_t); /// @param src_a Pointer to the first source data. Must be non-null. /// @param src_b Pointer to the second source data. Must be non-null. /// @param src_a_stride Distance in bytes from the start of one row to the -/// start of the next row for the first source data. -/// Must not be less than width * sizeof(type). +/// start of the next row for the first source data. +/// Must not be less than width * sizeof(type). /// @param src_b_stride Distance in bytes from the start of one row to the -/// start of the next row for the second source data. -/// Must not be less than width * sizeof(type). +/// start of the next row for the second source data. +/// Must not be less than width * sizeof(type). /// @param dst Pointer to the destination data. Must be non-null. -/// @param dst_stride Distance in bytes from the start of one row to the -/// start of the next row for the destination data. -/// Must not be less than width * sizeof(type). +/// @param dst_stride Distance in bytes from the start of one row to the +/// start of the next row for the destination data. +/// Must not be less than width * sizeof(type). /// @param width How many elements are in a row for the output. /// @param height How many rows are in the output. /// @param scale Currently unused parameter. diff --git a/intrinsiccv/include/morphology/workspace.h b/intrinsiccv/include/morphology/workspace.h index a0552a4dd..b69353e8e 100644 --- a/intrinsiccv/include/morphology/workspace.h +++ b/intrinsiccv/include/morphology/workspace.h @@ -198,7 +198,6 @@ class MorphologyWorkspace final { // [Step 2] Process the preloaded data. operation.process_horizontal(Rectangle{rect.width(), 1ul}, wide_rows, db_indirect_rows.write_at().at(index)); - } // for (...; index < horizontal_height; ...) db_indirect_rows.swap(); diff --git a/intrinsiccv/include/neon.h b/intrinsiccv/include/neon.h index b18c83443..a3983890b 100644 --- a/intrinsiccv/include/neon.h +++ b/intrinsiccv/include/neon.h @@ -5,6 +5,8 @@ #ifndef INTRINSICCV_NEON_H #define INTRINSICCV_NEON_H +#include + #include "neon_intrinsics.h" #include "operations.h" #include "utils.h" @@ -333,7 +335,7 @@ class SeparableFilter { using BorderInfoType = typename intrinsiccv::FixedBorderInfo3x3; using BorderOffsets = typename BorderInfoType::Offsets; - SeparableFilter(FilterType filter) { filter_ = filter; } + explicit SeparableFilter(FilterType filter) { filter_ = filter; } static constexpr Margin margin() { return Margin{1ul}; } @@ -463,7 +465,7 @@ class SeparableFilter { using BorderInfoType = typename intrinsiccv::FixedBorderInfo5x5; using BorderOffsets = typename BorderInfoType::Offsets; - SeparableFilter(FilterType filter) { filter_ = filter; } + explicit SeparableFilter(FilterType filter) { filter_ = filter; } static constexpr Margin margin() { return Margin{2ul}; } diff --git a/intrinsiccv/include/neon_intrinsics.h b/intrinsiccv/include/neon_intrinsics.h index dd95f56c9..0c8b6b5fa 100644 --- a/intrinsiccv/include/neon_intrinsics.h +++ b/intrinsiccv/include/neon_intrinsics.h @@ -130,56 +130,56 @@ static inline uint64x1_t vget_low(uint64x2_t vec) { return vget_low_u32(vec); } // vminq* // ----------------------------------------------------------------------------- -static inline int8x16_t vminq(int8x16_t lhs, int8x16_t rhs) { return vminq_s8(lhs, rhs); }; -static inline uint8x16_t vminq(uint8x16_t lhs, uint8x16_t rhs) { return vminq_u8(lhs, rhs); }; -static inline int16x8_t vminq(int16x8_t lhs, int16x8_t rhs) { return vminq_s16(lhs, rhs); }; -static inline uint16x8_t vminq(uint16x8_t lhs, uint16x8_t rhs) { return vminq_u16(lhs, rhs); }; -static inline int32x4_t vminq(int32x4_t lhs, int32x4_t rhs) { return vminq_s32(lhs, rhs); }; -static inline uint32x4_t vminq(uint32x4_t lhs, uint32x4_t rhs) { return vminq_u32(lhs, rhs); }; +static inline int8x16_t vminq(int8x16_t lhs, int8x16_t rhs) { return vminq_s8(lhs, rhs); } +static inline uint8x16_t vminq(uint8x16_t lhs, uint8x16_t rhs) { return vminq_u8(lhs, rhs); } +static inline int16x8_t vminq(int16x8_t lhs, int16x8_t rhs) { return vminq_s16(lhs, rhs); } +static inline uint16x8_t vminq(uint16x8_t lhs, uint16x8_t rhs) { return vminq_u16(lhs, rhs); } +static inline int32x4_t vminq(int32x4_t lhs, int32x4_t rhs) { return vminq_s32(lhs, rhs); } +static inline uint32x4_t vminq(uint32x4_t lhs, uint32x4_t rhs) { return vminq_u32(lhs, rhs); } // ----------------------------------------------------------------------------- // vmaxq* // ----------------------------------------------------------------------------- -static inline int8x16_t vmaxq(int8x16_t lhs, int8x16_t rhs) { return vmaxq_s8(lhs, rhs); }; -static inline uint8x16_t vmaxq(uint8x16_t lhs, uint8x16_t rhs) { return vmaxq_u8(lhs, rhs); }; -static inline int16x8_t vmaxq(int16x8_t lhs, int16x8_t rhs) { return vmaxq_s16(lhs, rhs); }; -static inline uint16x8_t vmaxq(uint16x8_t lhs, uint16x8_t rhs) { return vmaxq_u16(lhs, rhs); }; -static inline int32x4_t vmaxq(int32x4_t lhs, int32x4_t rhs) { return vmaxq_s32(lhs, rhs); }; -static inline uint32x4_t vmaxq(uint32x4_t lhs, uint32x4_t rhs) { return vmaxq_u32(lhs, rhs); }; +static inline int8x16_t vmaxq(int8x16_t lhs, int8x16_t rhs) { return vmaxq_s8(lhs, rhs); } +static inline uint8x16_t vmaxq(uint8x16_t lhs, uint8x16_t rhs) { return vmaxq_u8(lhs, rhs); } +static inline int16x8_t vmaxq(int16x8_t lhs, int16x8_t rhs) { return vmaxq_s16(lhs, rhs); } +static inline uint16x8_t vmaxq(uint16x8_t lhs, uint16x8_t rhs) { return vmaxq_u16(lhs, rhs); } +static inline int32x4_t vmaxq(int32x4_t lhs, int32x4_t rhs) { return vmaxq_s32(lhs, rhs); } +static inline uint32x4_t vmaxq(uint32x4_t lhs, uint32x4_t rhs) { return vmaxq_u32(lhs, rhs); } // ----------------------------------------------------------------------------- // vminvq* // ----------------------------------------------------------------------------- -static inline int8_t vminvq(int8x16_t src) { return vminvq_s8(src); }; -static inline uint8_t vminvq(uint8x16_t src) { return vminvq_u8(src); }; -static inline int16_t vminvq(int16x8_t src) { return vminvq_s16(src); }; -static inline uint16_t vminvq(uint16x8_t src) { return vminvq_u16(src); }; -static inline int32_t vminvq(int32x4_t src) { return vminvq_s32(src); }; -static inline uint32_t vminvq(uint32x4_t src) { return vminvq_u32(src); }; +static inline int8_t vminvq(int8x16_t src) { return vminvq_s8(src); } +static inline uint8_t vminvq(uint8x16_t src) { return vminvq_u8(src); } +static inline int16_t vminvq(int16x8_t src) { return vminvq_s16(src); } +static inline uint16_t vminvq(uint16x8_t src) { return vminvq_u16(src); } +static inline int32_t vminvq(int32x4_t src) { return vminvq_s32(src); } +static inline uint32_t vminvq(uint32x4_t src) { return vminvq_u32(src); } // ----------------------------------------------------------------------------- // vmaxvq* // ----------------------------------------------------------------------------- -static inline int8_t vmaxvq(int8x16_t src) { return vmaxvq_s8(src); }; -static inline uint8_t vmaxvq(uint8x16_t src) { return vmaxvq_u8(src); }; -static inline int16_t vmaxvq(int16x8_t src) { return vmaxvq_s16(src); }; -static inline uint16_t vmaxvq(uint16x8_t src) { return vmaxvq_u16(src); }; -static inline int32_t vmaxvq(int32x4_t src) { return vmaxvq_s32(src); }; -static inline uint32_t vmaxvq(uint32x4_t src) { return vmaxvq_u32(src); }; +static inline int8_t vmaxvq(int8x16_t src) { return vmaxvq_s8(src); } +static inline uint8_t vmaxvq(uint8x16_t src) { return vmaxvq_u8(src); } +static inline int16_t vmaxvq(int16x8_t src) { return vmaxvq_s16(src); } +static inline uint16_t vmaxvq(uint16x8_t src) { return vmaxvq_u16(src); } +static inline int32_t vmaxvq(int32x4_t src) { return vmaxvq_s32(src); } +static inline uint32_t vmaxvq(uint32x4_t src) { return vmaxvq_u32(src); } // ----------------------------------------------------------------------------- // vrshrn_n* // ----------------------------------------------------------------------------- -template static inline int8x8_t vrshrn_n(int16x8_t vec) { return vrshrn_n_s16(vec, n); }; -template static inline uint8x8_t vrshrn_n(uint16x8_t vec) { return vrshrn_n_u16(vec, n); }; -template static inline int16x4_t vrshrn_n(int32x4_t vec) { return vrshrn_n_s32(vec, n); }; -template static inline uint16x4_t vrshrn_n(uint32x4_t vec) { return vrshrn_n_u32(vec, n); }; -template static inline int32x2_t vrshrn_n(int64x2_t vec) { return vrshrn_n_s64(vec, n); }; -template static inline uint32x2_t vrshrn_n(uint64x2_t vec) { return vrshrn_n_u64(vec, n); }; +template static inline int8x8_t vrshrn_n(int16x8_t vec) { return vrshrn_n_s16(vec, n); } +template static inline uint8x8_t vrshrn_n(uint16x8_t vec) { return vrshrn_n_u16(vec, n); } +template static inline int16x4_t vrshrn_n(int32x4_t vec) { return vrshrn_n_s32(vec, n); } +template static inline uint16x4_t vrshrn_n(uint32x4_t vec) { return vrshrn_n_u32(vec, n); } +template static inline int32x2_t vrshrn_n(int64x2_t vec) { return vrshrn_n_s64(vec, n); } +template static inline uint32x2_t vrshrn_n(uint64x2_t vec) { return vrshrn_n_u64(vec, n); } // ----------------------------------------------------------------------------- // vshll_n* @@ -196,67 +196,67 @@ template static inline uint64x2_t vshll_n(uint32x2_t vec) { return vshll // vshlq_n* // ----------------------------------------------------------------------------- -template static inline int8x16_t vshlq_n(int8x16_t vec) { return vshlq_n_s8(vec, n); }; -template static inline uint8x16_t vshlq_n(uint8x16_t vec) { return vshlq_n_u8(vec, n); }; -template static inline int16x8_t vshlq_n(int16x8_t vec) { return vshlq_n_s16(vec, n); }; -template static inline uint16x8_t vshlq_n(uint16x8_t vec) { return vshlq_n_u16(vec, n); }; -template static inline int32x4_t vshlq_n(int32x4_t vec) { return vshlq_n_s32(vec, n); }; -template static inline uint32x4_t vshlq_n(uint32x4_t vec) { return vshlq_n_u32(vec, n); }; -template static inline int64x2_t vshlq_n(int64x2_t vec) { return vshlq_n_s64(vec, n); }; -template static inline uint64x2_t vshlq_n(uint64x2_t vec) { return vshlq_n_u64(vec, n); }; +template static inline int8x16_t vshlq_n(int8x16_t vec) { return vshlq_n_s8(vec, n); } +template static inline uint8x16_t vshlq_n(uint8x16_t vec) { return vshlq_n_u8(vec, n); } +template static inline int16x8_t vshlq_n(int16x8_t vec) { return vshlq_n_s16(vec, n); } +template static inline uint16x8_t vshlq_n(uint16x8_t vec) { return vshlq_n_u16(vec, n); } +template static inline int32x4_t vshlq_n(int32x4_t vec) { return vshlq_n_s32(vec, n); } +template static inline uint32x4_t vshlq_n(uint32x4_t vec) { return vshlq_n_u32(vec, n); } +template static inline int64x2_t vshlq_n(int64x2_t vec) { return vshlq_n_s64(vec, n); } +template static inline uint64x2_t vshlq_n(uint64x2_t vec) { return vshlq_n_u64(vec, n); } // ----------------------------------------------------------------------------- // vdupq* // ----------------------------------------------------------------------------- -static inline int8x16_t vdupq_n(int8_t src) { return vdupq_n_s8(src); }; -static inline uint8x16_t vdupq_n(uint8_t src) { return vdupq_n_u8(src); }; -static inline int16x8_t vdupq_n(int16_t src) { return vdupq_n_s16(src); }; -static inline uint16x8_t vdupq_n(uint16_t src) { return vdupq_n_u16(src); }; -static inline int32x4_t vdupq_n(int32_t src) { return vdupq_n_s32(src); }; -static inline uint32x4_t vdupq_n(uint32_t src) { return vdupq_n_u32(src); }; -static inline int64x2_t vdupq_n(int64_t src) { return vdupq_n_s64(src); }; -static inline uint64x2_t vdupq_n(uint64_t src) { return vdupq_n_u64(src); }; +static inline int8x16_t vdupq_n(int8_t src) { return vdupq_n_s8(src); } +static inline uint8x16_t vdupq_n(uint8_t src) { return vdupq_n_u8(src); } +static inline int16x8_t vdupq_n(int16_t src) { return vdupq_n_s16(src); } +static inline uint16x8_t vdupq_n(uint16_t src) { return vdupq_n_u16(src); } +static inline int32x4_t vdupq_n(int32_t src) { return vdupq_n_s32(src); } +static inline uint32x4_t vdupq_n(uint32_t src) { return vdupq_n_u32(src); } +static inline int64x2_t vdupq_n(int64_t src) { return vdupq_n_s64(src); } +static inline uint64x2_t vdupq_n(uint64_t src) { return vdupq_n_u64(src); } // ----------------------------------------------------------------------------- // vmull* // ----------------------------------------------------------------------------- -static inline int16x8_t vmull(int8x8_t lhs, int8x8_t rhs) { return vmull_s8(lhs, rhs); }; -static inline uint16x8_t vmull(uint8x8_t lhs, uint8x8_t rhs) { return vmull_u8(lhs, rhs); }; -static inline int32x4_t vmull(int16x4_t lhs, int16x4_t rhs) { return vmull_s16(lhs, rhs); }; -static inline uint32x4_t vmull(uint16x4_t lhs, uint16x4_t rhs) { return vmull_u16(lhs, rhs); }; -static inline int64x2_t vmull(int32x2_t lhs, int32x2_t rhs) { return vmull_s32(lhs, rhs); }; +static inline int16x8_t vmull(int8x8_t lhs, int8x8_t rhs) { return vmull_s8(lhs, rhs); } +static inline uint16x8_t vmull(uint8x8_t lhs, uint8x8_t rhs) { return vmull_u8(lhs, rhs); } +static inline int32x4_t vmull(int16x4_t lhs, int16x4_t rhs) { return vmull_s16(lhs, rhs); } +static inline uint32x4_t vmull(uint16x4_t lhs, uint16x4_t rhs) { return vmull_u16(lhs, rhs); } +static inline int64x2_t vmull(int32x2_t lhs, int32x2_t rhs) { return vmull_s32(lhs, rhs); } // ----------------------------------------------------------------------------- // vmull_high* // ----------------------------------------------------------------------------- -static inline int16x8_t vmull_high(int8x16_t lhs, int8x16_t rhs) { return vmull_high_s8(lhs, rhs); }; -static inline uint16x8_t vmull_high(uint8x16_t lhs, uint8x16_t rhs) { return vmull_high_u8(lhs, rhs); }; -static inline int32x4_t vmull_high(int16x8_t lhs, int16x8_t rhs) { return vmull_high_s16(lhs, rhs); }; -static inline uint32x4_t vmull_high(uint16x8_t lhs, uint16x8_t rhs) { return vmull_high_u16(lhs, rhs); }; -static inline int64x2_t vmull_high(int32x4_t lhs, int32x4_t rhs) { return vmull_high_s32(lhs, rhs); }; +static inline int16x8_t vmull_high(int8x16_t lhs, int8x16_t rhs) { return vmull_high_s8(lhs, rhs); } +static inline uint16x8_t vmull_high(uint8x16_t lhs, uint8x16_t rhs) { return vmull_high_u8(lhs, rhs); } +static inline int32x4_t vmull_high(int16x8_t lhs, int16x8_t rhs) { return vmull_high_s16(lhs, rhs); } +static inline uint32x4_t vmull_high(uint16x8_t lhs, uint16x8_t rhs) { return vmull_high_u16(lhs, rhs); } +static inline int64x2_t vmull_high(int32x4_t lhs, int32x4_t rhs) { return vmull_high_s32(lhs, rhs); } // ----------------------------------------------------------------------------- // vqmovn* // ----------------------------------------------------------------------------- -static inline int8x8_t vqmovn(int16x8_t src) { return vqmovn_s16(src); }; -static inline uint8x8_t vqmovn(uint16x8_t src) { return vqmovn_u16(src); }; -static inline int16x4_t vqmovn(int32x4_t src) { return vqmovn_s32(src); }; -static inline uint16x4_t vqmovn(uint32x4_t src) { return vqmovn_u32(src); }; -static inline int32x2_t vqmovn(int64x2_t src) { return vqmovn_s64(src); }; +static inline int8x8_t vqmovn(int16x8_t src) { return vqmovn_s16(src); } +static inline uint8x8_t vqmovn(uint16x8_t src) { return vqmovn_u16(src); } +static inline int16x4_t vqmovn(int32x4_t src) { return vqmovn_s32(src); } +static inline uint16x4_t vqmovn(uint32x4_t src) { return vqmovn_u32(src); } +static inline int32x2_t vqmovn(int64x2_t src) { return vqmovn_s64(src); } // ----------------------------------------------------------------------------- // vqmovn_high* // ----------------------------------------------------------------------------- -static inline int8x16_t vqmovn_high(int8x8_t low, int16x8_t src) { return vqmovn_high_s16(low, src); }; -static inline uint8x16_t vqmovn_high(uint8x8_t low, uint16x8_t src) { return vqmovn_high_u16(low, src); }; -static inline int16x8_t vqmovn_high(int16x4_t low, int32x4_t src) { return vqmovn_high_s32(low, src); }; -static inline uint16x8_t vqmovn_high(uint16x4_t low, uint32x4_t src) { return vqmovn_high_u32(low, src); }; -static inline int32x4_t vqmovn_high(int32x2_t low, int64x2_t src) { return vqmovn_high_s64(low, src); }; +static inline int8x16_t vqmovn_high(int8x8_t low, int16x8_t src) { return vqmovn_high_s16(low, src); } +static inline uint8x16_t vqmovn_high(uint8x8_t low, uint16x8_t src) { return vqmovn_high_u16(low, src); } +static inline int16x8_t vqmovn_high(int16x4_t low, int32x4_t src) { return vqmovn_high_s32(low, src); } +static inline uint16x8_t vqmovn_high(uint16x4_t low, uint32x4_t src) { return vqmovn_high_u32(low, src); } +static inline int32x4_t vqmovn_high(int32x2_t low, int64x2_t src) { return vqmovn_high_s64(low, src); } // ----------------------------------------------------------------------------- // NEON load operations @@ -398,14 +398,14 @@ static inline uint8x16_t vreinterpretq_u8(uint32x4_t vec) { return vreinterpretq static inline uint8x16_t vreinterpretq_u8(int64x2_t vec) { return vreinterpretq_u8_s64(vec); } static inline uint8x16_t vreinterpretq_u8(uint64x2_t vec) { return vreinterpretq_u8_u64(vec); } -static inline uint64x2_t vreinterpretq_u64(int8x16_t vec) { return vreinterpretq_u64_s8(vec); }; -static inline uint64x2_t vreinterpretq_u64(uint8x16_t vec) { return vreinterpretq_u64_u8(vec); }; -static inline uint64x2_t vreinterpretq_u64(int16x8_t vec) { return vreinterpretq_u64_s16(vec); }; -static inline uint64x2_t vreinterpretq_u64(uint16x8_t vec) { return vreinterpretq_u64_u16(vec); }; -static inline uint64x2_t vreinterpretq_u64(int32x4_t vec) { return vreinterpretq_u64_s32(vec); }; -static inline uint64x2_t vreinterpretq_u64(uint32x4_t vec) { return vreinterpretq_u64_u32(vec); }; -static inline uint64x2_t vreinterpretq_u64(int64x2_t vec) { return vreinterpretq_u64_s64(vec); }; -static inline uint64x2_t vreinterpretq_u64(uint64x2_t vec) { return vec; }; +static inline uint64x2_t vreinterpretq_u64(int8x16_t vec) { return vreinterpretq_u64_s8(vec); } +static inline uint64x2_t vreinterpretq_u64(uint8x16_t vec) { return vreinterpretq_u64_u8(vec); } +static inline uint64x2_t vreinterpretq_u64(int16x8_t vec) { return vreinterpretq_u64_s16(vec); } +static inline uint64x2_t vreinterpretq_u64(uint16x8_t vec) { return vreinterpretq_u64_u16(vec); } +static inline uint64x2_t vreinterpretq_u64(int32x4_t vec) { return vreinterpretq_u64_s32(vec); } +static inline uint64x2_t vreinterpretq_u64(uint32x4_t vec) { return vreinterpretq_u64_u32(vec); } +static inline uint64x2_t vreinterpretq_u64(int64x2_t vec) { return vreinterpretq_u64_s64(vec); } +static inline uint64x2_t vreinterpretq_u64(uint64x2_t vec) { return vec; } // clang-format on diff --git a/intrinsiccv/include/operations.h b/intrinsiccv/include/operations.h index f12497faf..fa15ea81c 100644 --- a/intrinsiccv/include/operations.h +++ b/intrinsiccv/include/operations.h @@ -5,6 +5,9 @@ #ifndef INTRINSICCV_OPERATIONS_H #define INTRINSICCV_OPERATIONS_H +#include +#include + #include "traits.h" #include "types.h" diff --git a/intrinsiccv/include/sve2.h b/intrinsiccv/include/sve2.h index c0996eca3..be274b193 100644 --- a/intrinsiccv/include/sve2.h +++ b/intrinsiccv/include/sve2.h @@ -7,6 +7,8 @@ #include +#include + #include "operations.h" #include "utils.h" #include "workspace/separable.h" @@ -482,7 +484,7 @@ class SeparableFilter { using BorderInfoType = typename intrinsiccv::FixedBorderInfo3x3; using BorderOffsets = typename BorderInfoType::Offsets; - SeparableFilter(FilterType filter) INTRINSICCV_STREAMING_COMPATIBLE { + explicit SeparableFilter(FilterType filter) INTRINSICCV_STREAMING_COMPATIBLE { filter_ = filter; } @@ -618,7 +620,7 @@ class SeparableFilter { using BorderInfoType = typename intrinsiccv::FixedBorderInfo5x5; using BorderOffsets = typename BorderInfoType::Offsets; - SeparableFilter(FilterType filter) INTRINSICCV_STREAMING_COMPATIBLE { + explicit SeparableFilter(FilterType filter) INTRINSICCV_STREAMING_COMPATIBLE { filter_ = filter; } diff --git a/intrinsiccv/include/types.h b/intrinsiccv/include/types.h index e27edfb92..f6703c738 100644 --- a/intrinsiccv/include/types.h +++ b/intrinsiccv/include/types.h @@ -7,6 +7,7 @@ #include #include +#include #include "config.h" #include "ctypes.h" diff --git a/intrinsiccv/include/utils.h b/intrinsiccv/include/utils.h index cdb7b8695..3d3591816 100644 --- a/intrinsiccv/include/utils.h +++ b/intrinsiccv/include/utils.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "config.h" diff --git a/intrinsiccv/src/arithmetics/multiply_sve2.cpp b/intrinsiccv/src/arithmetics/multiply_sve2.cpp index 39c58f804..4077a94c7 100644 --- a/intrinsiccv/src/arithmetics/multiply_sve2.cpp +++ b/intrinsiccv/src/arithmetics/multiply_sve2.cpp @@ -66,4 +66,4 @@ INTRINSICCV_INSTANTIATE_TEMPLATE(uint16_t); INTRINSICCV_INSTANTIATE_TEMPLATE(int16_t); INTRINSICCV_INSTANTIATE_TEMPLATE(int32_t); -} // namespace intrinsiccv::sve2 \ No newline at end of file +} // namespace intrinsiccv::sve2 diff --git a/intrinsiccv/src/arithmetics/scale_neon.cpp b/intrinsiccv/src/arithmetics/scale_neon.cpp index 2fac8675b..9845ddfd9 100644 --- a/intrinsiccv/src/arithmetics/scale_neon.cpp +++ b/intrinsiccv/src/arithmetics/scale_neon.cpp @@ -180,10 +180,9 @@ void scale(const T *src, size_t src_stride, T *dst, size_t dst_stride, if (width * height < 2500) { // empirical value ScaleFloat operation(scale, shift); apply_operation_by_rows(operation, rect, src_rows, dst_rows); - } - // For bigger inputs, it's faster to pre-calculate the table - // and map those values during the run - else { + } else { + // For bigger inputs, it's faster to pre-calculate the table + // and map those values during the run ScaleTbx operation(scale, shift); apply_operation_by_rows(operation, rect, src_rows, dst_rows); } diff --git a/intrinsiccv/src/arithmetics/transpose_neon.cpp b/intrinsiccv/src/arithmetics/transpose_neon.cpp index 9ab546cf6..d785b4184 100644 --- a/intrinsiccv/src/arithmetics/transpose_neon.cpp +++ b/intrinsiccv/src/arithmetics/transpose_neon.cpp @@ -69,7 +69,7 @@ static void vector_path(Rows src_rows, constexpr size_t buffer_size = num_of_lanes; // Last transpose step is always done on 64 bit elements - uint64x2_t trn_result_b64[buffer_size]; + uint64x2_t trn_result_b64[buffer_size]; // NOLINT(runtime/arrays) // The 64 bit transpose spans through all the vectors, so its "order" is the // same as the number of vectors @@ -148,7 +148,7 @@ static void transpose(Rectangle rect, Rows data_rows) { inner_loop.unroll_once([&](size_t hindex) { // Allocate temporary memory for one tile - ScalarType tmp[num_of_lanes * num_of_lanes]; + ScalarType tmp[num_of_lanes * num_of_lanes]; // NOLINT(runtime/arrays) Rows tmp_rows{tmp, num_of_lanes * sizeof(ScalarType)}; // Transpose a tile from the top right area, save the result @@ -242,7 +242,7 @@ void transpose(const void *src, size_t src_stride, void *dst, size_t dst_stride, transpose(src, src_stride, dst, dst_stride, src_width, src_height, inplace); break; - }; + } } } // namespace intrinsiccv::neon diff --git a/intrinsiccv/src/conversions/merge_neon.cpp b/intrinsiccv/src/conversions/merge_neon.cpp index adb7ed80b..bc61c9ab3 100644 --- a/intrinsiccv/src/conversions/merge_neon.cpp +++ b/intrinsiccv/src/conversions/merge_neon.cpp @@ -98,8 +98,8 @@ class Merge3 final : public UnrollTwice { dst[2] = src_c[0]; } -#if !INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE private: +#if !INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE template static const uint8_t *lookup_table(); @@ -306,8 +306,8 @@ class Merge4 final : public UnrollTwice { dst[3] = src_d[0]; } -#if !INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE private: +#if !INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE // Polymorphic retinterpret_cast<>() between vector types where the element // size is doubled. For example, if 'VectorType' is 'uint8x16_t', this // method returns 'reinterpret_cast(vector)'. diff --git a/intrinsiccv/src/conversions/split_neon.cpp b/intrinsiccv/src/conversions/split_neon.cpp index 9c440bb44..7b61c005e 100644 --- a/intrinsiccv/src/conversions/split_neon.cpp +++ b/intrinsiccv/src/conversions/split_neon.cpp @@ -57,8 +57,7 @@ class Split3 final : public UnrollTwice { using VectorType = typename VecTraits::VectorType; #if !INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE - public: - Split3() { Split3Init(); }; + Split3() { Split3Init(); } #endif #if INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE @@ -90,8 +89,8 @@ class Split3 final : public UnrollTwice { dst2[0] = src[2]; } -#if !INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE private: +#if !INTRINSICCV_PREFER_INTERLEAVING_LOAD_STORE uint8x16_t index1_, index2_, index3_; template void Split3Init() {} diff --git a/intrinsiccv/src/conversions/yuv_to_rgb_sc.h b/intrinsiccv/src/conversions/yuv_to_rgb_sc.h index 36e61b20e..0d2ca35c5 100644 --- a/intrinsiccv/src/conversions/yuv_to_rgb_sc.h +++ b/intrinsiccv/src/conversions/yuv_to_rgb_sc.h @@ -5,6 +5,8 @@ #ifndef INTRINSICCV_YUV_TO_RGB_SC_H #define INTRINSICCV_YUV_TO_RGB_SC_H +#include + #include "conversions/yuv_to_rgb.h" #include "intrinsiccv.h" #include "sve2.h" diff --git a/intrinsiccv/src/morphology/morphology_sc.h b/intrinsiccv/src/morphology/morphology_sc.h index c9bc7ef4c..1ca0201cd 100644 --- a/intrinsiccv/src/morphology/morphology_sc.h +++ b/intrinsiccv/src/morphology/morphology_sc.h @@ -104,18 +104,19 @@ class VerticalOp final { src_rows += step; }); - loop.tail([&](size_t /* index */) INTRINSICCV_STREAMING_COMPATIBLE { - const ScalarType *src_row = &src_rows[index]; - auto row0 = svld1(VecTraits::svptrue(), &src_row[0]); - auto row1 = svld1_vnum(VecTraits::svptrue(), &src_row[0], 1); - auto row2 = svld1_vnum(VecTraits::svptrue(), &src_row[0], 2); - auto row3 = svld1_vnum(VecTraits::svptrue(), &src_row[0], 3); - acc0 = O::operation(VecTraits::svptrue(), acc0, row0); - acc1 = O::operation(VecTraits::svptrue(), acc1, row1); - acc2 = O::operation(VecTraits::svptrue(), acc2, row2); - acc3 = O::operation(VecTraits::svptrue(), acc3, row3); - ++src_rows; - }); + loop.tail([&](size_t /* index */) // NOLINT(readability/casting) + INTRINSICCV_STREAMING_COMPATIBLE { + const ScalarType *src_row = &src_rows[index]; + auto row0 = svld1(VecTraits::svptrue(), &src_row[0]); + auto row1 = svld1_vnum(VecTraits::svptrue(), &src_row[0], 1); + auto row2 = svld1_vnum(VecTraits::svptrue(), &src_row[0], 2); + auto row3 = svld1_vnum(VecTraits::svptrue(), &src_row[0], 3); + acc0 = O::operation(VecTraits::svptrue(), acc0, row0); + acc1 = O::operation(VecTraits::svptrue(), acc1, row1); + acc2 = O::operation(VecTraits::svptrue(), acc2, row2); + acc3 = O::operation(VecTraits::svptrue(), acc3, row3); + ++src_rows; + }); // Save partial results which do not contain the first row. auto partial_acc0 = acc0; @@ -194,14 +195,15 @@ class VerticalOp final { src_rows += step; }); - loop.tail([&](size_t /* index */) INTRINSICCV_STREAMING_COMPATIBLE { - const ScalarType *src_row = &src_rows[index]; - auto row0 = svld1(VecTraits::svptrue(), &src_row[0]); - auto row1 = svld1_vnum(VecTraits::svptrue(), &src_row[0], 1); - acc0 = O::operation(VecTraits::svptrue(), acc0, row0); - acc1 = O::operation(VecTraits::svptrue(), acc1, row1); - ++src_rows; - }); + loop.tail([&](size_t /* index */) // NOLINT(readability/casting) + INTRINSICCV_STREAMING_COMPATIBLE { + const ScalarType *src_row = &src_rows[index]; + auto row0 = svld1(VecTraits::svptrue(), &src_row[0]); + auto row1 = svld1_vnum(VecTraits::svptrue(), &src_row[0], 1); + acc0 = O::operation(VecTraits::svptrue(), acc0, row0); + acc1 = O::operation(VecTraits::svptrue(), acc1, row1); + ++src_rows; + }); // Save partial results which do not contain the first row. auto partial_acc0 = acc0; @@ -253,11 +255,12 @@ class VerticalOp final { src_rows += step; }); - loop.tail([&](size_t /* index */) INTRINSICCV_STREAMING_COMPATIBLE { - auto row = svld1(pg, &src_rows[index]); - acc = O::operation(pg, acc, row); - ++src_rows; - }); + loop.tail([&](size_t /* index */) // NOLINT(readability/casting) + INTRINSICCV_STREAMING_COMPATIBLE { + auto row = svld1(pg, &src_rows[index]); + acc = O::operation(pg, acc, row); + ++src_rows; + }); // Save partial result which does not contain the first row. auto partial_acc = acc; diff --git a/intrinsiccv/src/resize/resize_sc.h b/intrinsiccv/src/resize/resize_sc.h index 0f6c6c1f9..107d345b2 100644 --- a/intrinsiccv/src/resize/resize_sc.h +++ b/intrinsiccv/src/resize/resize_sc.h @@ -148,11 +148,13 @@ INTRINSICCV_TARGET_FN_ATTS static void resize_to_quarter_u8_sc( LoopUnroll2 loop{src_height, /* Process two rows */ 2}; // Process two rows at once. - loop.unroll_once([&](size_t) INTRINSICCV_STREAMING_COMPATIBLE { - process_parallel_rows(src_rows, src_width, dst_rows, dst_width); - src_rows += 2; - ++dst_rows; - }); + loop.unroll_once([&](size_t) // NOLINT(readability/casting) + INTRINSICCV_STREAMING_COMPATIBLE { + process_parallel_rows(src_rows, src_width, dst_rows, + dst_width); + src_rows += 2; + ++dst_rows; + }); // Handle an odd row, if any. if (dst_height > (src_height / 2)) { diff --git a/scripts/ci.sh b/scripts/ci.sh index 0649287c0..e13201880 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -17,6 +17,11 @@ apt-get -y --no-install-recommends install qemu-user # Check format of C++ files CHECK_ONLY=ON VERBOSE=ON scripts/format.sh +scripts/cpplint.sh + +# Check format of shell scripts +shellcheck scripts/*.sh + # Check license headers reuse lint diff --git a/scripts/cpplint.sh b/scripts/cpplint.sh new file mode 100755 index 000000000..0ad7a9754 --- /dev/null +++ b/scripts/cpplint.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# SPDX-FileCopyrightText: 2024 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 + +set -eu + +# ------------------------------------------------------------------------------ + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +set -x + +# Run cpplint. +# +# Disabled categories rationale: +# * build/header_guard - our header guards are not coupled to the directory +# structure because they're designed to be used from other projects. +# * build/include_subdir - it's OK to include a header in the same directory +# and not prefix it with the directory name. +# * readability/todo - it's OK to add a comment stating that there's work to +# be done without knowing who will do it. +# * runtime/references - it's OK to pass non-const references if an argument +# is intended to be modified. +# * whitespace/line_length - handled by clang-format. +# +# False positives should not be disabled but instead suppressed by adding a +# NOLINT(category) comment to the affected line. +cpplint \ + --recursive \ + --exclude=build \ + --counting=detailed \ + --filter=-build/header_guard,-build/include_subdir,-readability/todo,-runtime/references,-whitespace/line_length \ + . diff --git a/test/api/test_min_max.cpp b/test/api/test_min_max.cpp index c10cf475d..811a8493d 100644 --- a/test/api/test_min_max.cpp +++ b/test/api/test_min_max.cpp @@ -275,8 +275,6 @@ class MinMaxLoc : public testing::Test {}; using MinMaxLocElementTypes = ::testing::Types; TYPED_TEST_SUITE(MinMaxLoc, MinMaxLocElementTypes); -using namespace std; - TYPED_TEST(MinMaxLoc, API) { MinMaxLocTest{}.test(); MinMaxLocTest{}.test(); diff --git a/test/api/test_saturating_multiply.cpp b/test/api/test_saturating_multiply.cpp index bbb031be2..bf14c39b4 100644 --- a/test/api/test_saturating_multiply.cpp +++ b/test/api/test_saturating_multiply.cpp @@ -59,21 +59,21 @@ class SaturatingMultiplyTest final : public BinaryOperationTest { } else { static const std::vector kTestElements = { // clang-format off - { min(), min(), max()}, - { min(), max(), min()}, - { min(), -1, max()}, - {min() + 2, -1,max() - 1}, - { 6, -8, -48}, - { -2, 2, -4}, - { -1, -1, 1}, - { 0, 0, 0}, - { 1, 1, 1}, - { 2, 2, 4}, - { 6, 8, 48}, - {max() - 2, -1,min() + 3}, - { max(), 1, max()}, - { max(), 2, max()}, - { max(), max(), max()}, + { min(), min(), max()}, + { min(), max(), min()}, + { min(), -1, max()}, + {min() + 2, -1, max() - 1}, + { 6, -8, -48}, + { -2, 2, -4}, + { -1, -1, 1}, + { 0, 0, 0}, + { 1, 1, 1}, + { 2, 2, 4}, + { 6, 8, 48}, + {max() - 2, -1, min() + 3}, + { max(), 1, max()}, + { max(), 2, max()}, + { max(), max(), max()}, // clang-format on }; -- GitLab