Skip to content

Commit 8a39791

Browse files
Merge pull request #2586 from jasonrandrews/review
Tech review of KleidiCV Learning Path
2 parents c59f9e3 + 135bc19 commit 8a39791

File tree

3 files changed

+150
-90
lines changed

3 files changed

+150
-90
lines changed

content/learning-paths/laptops-and-desktops/kleidicv-on-mac/_index.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,48 @@
11
---
2-
title: Learn how to build and test Kleidicv on Mac OS
2+
title: Build and test KleidiCV on macOS
3+
4+
draft: true
5+
cascade:
6+
draft: true
37

48
minutes_to_complete: 30
59

6-
who_is_this_for: This is an introductory topic for software developers to learn how
7-
to to build and test kleidicv on Mac OS.
10+
who_is_this_for: This is an introductory topic for software developers who want to build and test KleidiCV on macOS.
811

912
learning_objectives:
10-
- Install and compile kleidiCV on macOS
13+
- Install and compile KleidiCV on macOS
1114
- Run KleidiCV example tests
12-
- Enable SME build and verify SME backend
15+
- Enable Scalable Matrix Extensions (SME) and verify increased SME performance
1316

1417
prerequisites:
15-
- An M4 Mac OS computer.
18+
- A Mac with Apple Silicon (M4 generation or newer)
19+
- Basic familiarity with command-line tools
20+
- Xcode command line tools installed
1621

1722
author: Jett Zhou
1823

1924
### Tags
2025
skilllevels: Introductory
21-
subjects: SME
22-
armips:
23-
- ARMv9-A
26+
subjects: Performance and Architecture
2427
tools_software_languages:
25-
- kleidiCV and C/C++
28+
- KleidiCV
29+
- C
2630
operatingsystems:
27-
- Mac OS
28-
29-
31+
- macOS
3032

3133
further_reading:
3234
- resource:
33-
title: kleidicv doc
35+
title: KleidiCV documentation
3436
link: https://gitlab.arm.com/kleidi/kleidicv/-/tree/0.6.0/doc?ref_type=tags
3537
type: documentation
3638
- resource:
3739
title: Announcing Arm KleidiCV 0.1
3840
link: https://developer.arm.com/community/arm-community-blogs/b/ai-blog/posts/kleidicv
3941
type: blog
42+
- resource:
43+
title: Learn about function multiversioning
44+
link: https://learn.arm.com/learning-paths/cross-platform/function-multiversioning/
45+
type: website
4046

4147

4248

content/learning-paths/laptops-and-desktops/kleidicv-on-mac/build-1.md

Lines changed: 63 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,51 @@
11
---
2-
title: Download and Build for the Kleidicv Software
2+
title: Download and build KleidiCV software
33
weight: 2
44

5-
### FIXED, DO NOT MODIFY
65
layout: learningpathall
76
---
87

98
## Introduction
109

11-
Arm KleidiCV is an open-source library of optimized performance-critical routines for Arm CPUs. It is designed for integrating into any CV framework to enable best performance for CV workloads on Arm, with no action needed by application developers.
10+
Arm KleidiCV is an open-source library of optimized, performance-critical routines for Arm CPUs. You can integrate it into any Computer Vision (CV) framework to get the best performance for CV workloads on Arm, with no action needed by application developers.
1211

13-
Each KleidiCV function has three different implementations targeting Neon, SVE2 (Scalable Vector Extension) or Streaming SVE & SME2 (Scalable Matrix Extension). KleidiCV will automatically detect what hardware it's running on and select the best implementation accordingly.KleidiCV can be used as a lightweight standalone image processing library. Alternatively KleidiCV can be used seamlessly as part of the extremely popular OpenCV library.
12+
Each KleidiCV function has different implementations targeting Neon, SVE2 (Scalable Vector Extension), or Streaming SVE and SME2 (Scalable Matrix Extension). KleidiCV automatically detects the hardware it is running on and selects the best implementation. You can use KleidiCV as a lightweight standalone image processing library or as part of the OpenCV library.
1413

15-
Since the Apple M4 family is based on the ARMv9.2‑A architecture, it supports the Scalable Matrix Extension (SME) (or a variant thereof) for matrix-compute acceleration. we will demostrate the build and do run test of the kleidicv, understand how the backend implementation is called for the KleidiCV functions.
14+
Since the Apple M4 family is based on the Armv9.2‑A architecture, it supports the Scalable Matrix Extension (SME) for accelerating matrix computations. In this Learning Path, you will build and test KleidiCV to understand how the backend implementation is called for the KleidiCV functions.
1615

17-
## Host Environment
16+
## Host environment
1817

19-
The host machine utilized is a MacBook Pro (Apple M4 Pro), and the operating system version is detailed below:
18+
The host machine is a MacBook Pro (Apple Silicon M4), and the operating system version is detailed below.
2019

21-
```bash
20+
You can find this information on your Mac by selecting the **Apple menu ()** in the top-left corner of your screen, then selecting **About This Mac**. Alternatively, run the following command in a terminal:
21+
22+
```console
23+
sw_vers
24+
```
25+
26+
The output is similar to:
27+
28+
```output
2229
ProductName: macOS
2330
ProductVersion: 15.5
2431
BuildVersion: 24F74
2532
```
2633

27-
CMake is available for installation through Homebrew if it is not already installed on the host machine.
34+
If CMake is not already installed on your host machine, you can install it using Homebrew.
2835

2936
```bash
3037
brew install cmake
3138
```
3239

33-
The host architecture feature can be verified as outlined below, confirming that FEAT_SME is supported:
40+
You can verify the host architecture features as outlined below, confirming that `FEAT_SME` is supported:
3441

3542
```bash
3643
sysctl -a | grep hw.optional.arm.FEAT
44+
```
45+
46+
The output is:
47+
48+
```output
3749
hw.optional.arm.FEAT_CRC32: 1
3850
hw.optional.arm.FEAT_FlagM: 1
3951
hw.optional.arm.FEAT_FlagM2: 1
@@ -84,9 +96,28 @@ hw.optional.arm.FEAT_SME_F64F64: 1
8496
hw.optional.arm.FEAT_SME_I16I64: 1
8597
```
8698

99+
If you don't have an M4 Mac you will not see the `FEAT_SME` flags set to 1.
100+
101+
## Create a workspace.
102+
103+
You can use an environment variable to define your workspace.
104+
105+
```bash
106+
export WORKSPACE=<your-workspace-directdory>
107+
```
108+
109+
For example,
110+
111+
```bash
112+
mkdir $HOME/kleidi
113+
export WORKSPACE=$HOME/kleidi
114+
```
115+
87116
## Download the Software
88117

89-
To set up KleidiCV and OpenCV, first download the source code from GitLab. In your $WORKSPACE directory, clone KleidiCV using the v0.6.0 release tag.
118+
To set up KleidiCV and OpenCV, first download the source code from GitLab.
119+
120+
In your $WORKSPACE directory, clone KleidiCV using the v0.6.0 release tag.
90121

91122
```bash
92123
cd $WORKSPACE
@@ -98,6 +129,7 @@ Clone the OpenCV repository into $WORKSPACE using the v4.12.0 release tag.
98129
```bash
99130
cd $WORKSPACE
100131
git clone https://github.com/opencv/opencv.git
132+
cd opencv
101133
git checkout 4.12.0
102134
```
103135

@@ -123,53 +155,52 @@ Normally, if our tests show SVE2 or SME2 are slower than NEON, we default to NEO
123155

124156
## Build the KleidiCV standalone
125157

126-
Use the following command to build kleidicv natively:
158+
Use the following command to build KleidiCV natively:
127159

128160
```bash
129-
cmake -S $WORKSPCE/kleidicv \
161+
cmake -S $WORKSPACE/kleidicv \
130162
-B build-kleidicv-benchmark-SME \
131163
-DKLEIDICV_ENABLE_SME2=ON \
132164
-DKLEIDICV_LIMIT_SME2_TO_SELECTED_ALGORITHMS=OFF \
133165
-DKLEIDICV_BENCHMARK=ON \
134166
-DCMAKE_BUILD_TYPE=Release
135-
136167
cmake --build build-kleidicv-benchmark-SME --parallel
137168
```
138-
Once the build completes, the kleidicv API and framework tests appear below:
169+
Once the build completes, the KleidiCV API and framework tests appear below:
139170

140171
```bash
141-
./build-kleidicv-benchmark-SME/test/framework/kleidicv-framework-test
142-
./build-kleidicv-benchmark-SME/test/api/kleidicv-api-test
172+
ls ./build-kleidicv-benchmark-SME/test/framework/kleidicv-framework-test
173+
ls ./build-kleidicv-benchmark-SME/test/api/kleidicv-api-test
143174
```
144175

145-
The Kleidicv benchmark test is available as follows:
176+
The KleidiCV benchmark test is available as follows:
146177

147178
```bash
148-
./build-kleidicv-benchmark-SME/benchmark/kleidicv-benchmark
179+
ls ./build-kleidicv-benchmark-SME/benchmark/kleidicv-benchmark
149180
```
150181
## Build the OpenCV with KleidiCV
151182

152-
The following command can be used to build OpenCV with kleidicv:
183+
The following command can be used to build OpenCV with KleidiCV:
153184

154185
```bash
155-
cmake -S $workspace/opencv /
156-
-B build-opencv-kleidicv-sme /
157-
-DWITH_KLEIDICV=ON /
158-
-DKLEIDICV_ENABLE_SME2=ON /
159-
-DKLEIDICV_SOURCE_PATH=$workspace/kleidicv /
160-
-DBUILD_LIST=imgproc,core,ts /
161-
-DBUILD_SHARED_LIBS=OFF /
162-
-DBUILD_TESTS=ON /
163-
-DBUILD_PERF_TEST=ON /
186+
cmake -S $WORKSPACE/opencv \
187+
-B build-opencv-kleidicv-sme \
188+
-DWITH_KLEIDICV=ON \
189+
-DKLEIDICV_ENABLE_SME2=ON \
190+
-DKLEIDICV_SOURCE_PATH=$WORKSPACE/kleidicv \
191+
-DBUILD_LIST=imgproc,core,ts \
192+
-DBUILD_SHARED_LIBS=OFF \
193+
-DBUILD_TESTS=ON \
194+
-DBUILD_PERF_TEST=ON \
164195
-DWITH_PNG=OFF
165-
166196
cmake --build build-opencv-kleidicv-sme --parallel --target opencv_perf_imgproc opencv_perf_core
167197
```
168198

169199
Upon completion of the build process, the OpenCV test binary will be available at the following location:
170200

171201
```bash
172-
build-opencv-kleidicv-sme/bin/opencv_perf_core
173-
build-opencv-kleidicv-sme/bin/opencv_perf_imgproc
202+
ls build-opencv-kleidicv-sme/bin/opencv_perf_core
203+
ls build-opencv-kleidicv-sme/bin/opencv_perf_imgproc
174204
```
175205

206+
Continue to the next section to run the benchmarks and learn about SME.

0 commit comments

Comments
 (0)