KleidiCV Coverage Report


Directory: ./
File: kleidicv/src/arithmetics/compare_sc.h
Date: 2026-01-20 20:58:59
Exec Total Coverage
Lines: 23 23 100.0%
Functions: 12 12 100.0%
Branches: 36 36 100.0%

Line Branch Exec Source
1 // SPDX-FileCopyrightText: 2023 - 2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 #ifndef KLEIDICV_COMPARE_SC_H
6 #define KLEIDICV_COMPARE_SC_H
7
8 #include "kleidicv/kleidicv.h"
9 #include "kleidicv/sve2.h"
10
11 namespace KLEIDICV_TARGET_NAMESPACE {
12
13 template <typename ScalarType>
14 class ComparatorEqual : public UnrollTwice {
15 public:
16 using ContextType = Context;
17 using VecTraits = KLEIDICV_TARGET_NAMESPACE::VecTraits<ScalarType>;
18 using VectorType = typename VecTraits::VectorType;
19 using SignedScalarType = typename std::make_signed<ScalarType>::type;
20 using SignedVecTraits =
21 KLEIDICV_TARGET_NAMESPACE::VecTraits<SignedScalarType>;
22 using SignedVectorType = typename SignedVecTraits::VectorType;
23
24 // NOLINTBEGIN(readability-make-member-function-const)
25 1051 VectorType vector_path(ContextType ctx, VectorType src_a,
26 VectorType src_b) KLEIDICV_STREAMING {
27 1051 svbool_t pg = ctx.predicate();
28 1051 svbool_t predicate = svcmpeq(pg, src_a, src_b);
29 2102 return svsel(predicate, VecTraits::svdup(255), VecTraits::svdup(0));
30 1051 }
31 // NOLINTEND(readability-make-member-function-const)
32 }; // end of class ComparatorEqual
33
34 template <typename ScalarType>
35 class ComparatorGreater : public UnrollTwice {
36 public:
37 using ContextType = Context;
38 using VecTraits = KLEIDICV_TARGET_NAMESPACE::VecTraits<ScalarType>;
39 using VectorType = typename VecTraits::VectorType;
40 using SignedScalarType = typename std::make_signed<ScalarType>::type;
41 using SignedVecTraits =
42 KLEIDICV_TARGET_NAMESPACE::VecTraits<SignedScalarType>;
43 using SignedVectorType = typename SignedVecTraits::VectorType;
44
45 // NOLINTBEGIN(readability-make-member-function-const)
46 1051 VectorType vector_path(ContextType ctx, VectorType src_a,
47 VectorType src_b) KLEIDICV_STREAMING {
48 1051 svbool_t pg = ctx.predicate();
49 1051 svbool_t predicate = svcmpgt(pg, src_a, src_b);
50 2102 return svsel(predicate, VecTraits::svdup(255), VecTraits::svdup(0));
51 1051 }
52 // NOLINTEND(readability-make-member-function-const)
53 }; // end of class ComparatorGreater
54
55 template <typename Comparator, typename ScalarType>
56 576 kleidicv_error_t compare_sc(const ScalarType *src_a, size_t src_a_stride,
57 const ScalarType *src_b, size_t src_b_stride,
58 ScalarType *dst, size_t dst_stride, size_t width,
59 size_t height) KLEIDICV_STREAMING {
60
8/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 285 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 285 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 285 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 285 times.
576 CHECK_POINTER_AND_STRIDE(src_a, src_a_stride, height);
61
8/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 282 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 282 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 282 times.
570 CHECK_POINTER_AND_STRIDE(src_b, src_b_stride, height);
62
8/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 279 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 279 times.
564 CHECK_POINTER_AND_STRIDE(dst, dst_stride, height);
63
12/12
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 273 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 273 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 276 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 273 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 273 times.
558 CHECK_IMAGE_SIZE(width, height);
64
65 546 Comparator operation{};
66 546 Rectangle rect{width, height};
67 546 Rows<const ScalarType> src_a_rows{src_a, src_a_stride};
68 546 Rows<const ScalarType> src_b_rows{src_b, src_b_stride};
69 546 Rows<ScalarType> dst_rows{dst, dst_stride};
70
71 546 apply_operation_by_rows(operation, rect, src_a_rows, src_b_rows, dst_rows);
72
73 546 return KLEIDICV_OK;
74 576 }
75
76 } // namespace KLEIDICV_TARGET_NAMESPACE
77
78 #endif // KLEIDICV_COMPARE_SC_H
79