You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/windowsperf_sampling_cpython_spe/_index.md
+16-7Lines changed: 16 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,22 @@
1
1
---
2
2
title: Sampling CPython with Arm SPE with WindowsPerf
3
+
draft: true
4
+
cascade:
5
+
draft: true
3
6
4
7
minutes_to_complete: 30
5
8
6
-
who_is_this_for: This is an introductory topic for developers keen to understand sampling with ARM SPE extension.
9
+
who_is_this_for: This is an introductory topic for developers keen to understand sampling with the Arm Statistical Profiling Extension (SPE).
7
10
8
11
learning_objectives:
9
-
- Use WindowsPerf with native Windows on Arm workload
10
-
- Understand the basics of sampling with Arm SPE
11
-
- Explore the WindowsPerf command line
12
-
- Build CPython from sources for Windows on Arm ARM64 target
12
+
- Use WindowsPerf with a native Windows on Arm workload.
13
+
- Understand the basics of sampling with Arm SPE.
14
+
- Explore the WindowsPerf command line.
15
+
- Build CPython from sources for Windows on Arm (ARM64).
13
16
14
17
prerequisites:
15
-
- Windows on Arm desktop or development machine with [WindowsPerf installed](/install-guides/wperf)
16
-
- CPU with Arm Statistical Profiling Extension (SPE) support
18
+
- Windows on Arm desktop or development machine with [WindowsPerf](/install-guides/wperf), [Visual Studio](/install-guides/vs-woa/), and [Git](/install-guides/git-woa/) installed.
19
+
- The system must also have an Arm CPU with SPE support.
In this example, you will build a debug build of CPython from sources and execute simple instructions in the Python interactive mode to obtain WindowsPerf sampling results from the CPython runtime image.
8
8
9
-
In this example, you will build a debug build of CPython from sources and then execute simple instructions in the Python interactive mode to obtain WindowsPerf sampling results from a CPython runtime image.
10
-
11
-
## The Arm Statistical Profiling Extension Introduction
9
+
## Introduction to the Arm Statistical Profiling Extension (SPE)
12
10
13
11
The Arm Statistical Profiling Extension (SPE) is a feature defined as part of the Armv8-A architecture, starting from version 8.2. It provides non-invasive, hardware-based statistical sampling for CPUs. Unlike the Performance Monitor Unit (PMU), SPE is a different module that integrates the sampling process into the instruction execution process within the CPU's pipelines.
14
12
15
13
SPE is particularly useful for performance analysis and optimization, as it provides detailed insights into the behavior of the CPU during execution. This can help identify performance bottlenecks and optimize software for better efficiency.
16
14
17
-
## Introduction
15
+
## Overview
16
+
17
+
You will use sampling to determine the CPython program "hot" locations as provided by the Arm Statistical Profiling Extension (SPE).
18
18
19
-
You will use sampling to determine CPython program "hot" locations provided by Arm Statistical Profiling Extension (SPE).
19
+
WindowsPerf includes `record` support for the Arm Statistical Profiling Extension (SPE).
20
20
21
-
WindowsPerf added support (in `record` command) for the [Arm Statistical Profiling Extension (SPE)](https://developer.arm.com/documentation/101136/22-1-3/MAP/Arm-Statistical-Profiling-Extension--SPE-). SPE is an optional feature in ARMv8.2 hardware that allows CPU instructions to be sampled and associated with the source code location where that instruction occurred.
21
+
SPE is an optional feature in ARMv8.2 hardware that allows CPU instructions to be sampled and associated with the source code location where that instruction occurred.
22
22
23
23
{{% notice Note %}}
24
-
Currently SPE is available on Windows On Arm in Test Mode only!
24
+
Currently SPE is available on Windows On Arm in Test Mode only!
25
25
{{% /notice %}}
26
26
27
27
## Before you begin
28
28
29
-
For this learning path you will need:
30
-
* A Windows on Arm (ARM64) native machine with pre-installed WindowsPerf (both driver and `wperf` CLI tool). See [WindowsPerf Install Guide](/install-guides/wperf/) for more details.
29
+
For this Learning Path you will need:
30
+
31
+
* A Windows on Arm (ARM64) native machine with pre-installed WindowsPerf (both driver and `wperf` CLI tool). Refer to the [WindowsPerf Install Guide](/install-guides/wperf/) for more details.
31
32
* Note: The [WindowsPerf release 3.8.0](https://github.com/arm-developer-tools/windowsperf/releases/tag/3.8.0) includes a separate build with Arm SPE (Statistical Profiling Extension) support enabled. To install this version download release asset and you will find WindowsPerf SPE build in the `SPE/` subdirectory.
32
-
* CPU must support Arm SPE extension, an optional feature in ARMv8.2 hardware - we will show you how to check your CPU compatibility using WindowsPerf command-line tool.
33
-
* Basic knowledge of git and Python.
34
-
* See [Install Git on Windows](https://github.com/git-guides/install-git#install-git-on-windows) for more details.
33
+
*[Visual Studio](/install-guides/vs-woa/) and [Git](/install-guides/git-woa/) installed.
34
+
* The CPU must support the Arm SPE extension, an optional feature in ARMv8.2 hardware. You can check your CPU compatibility using the WindowsPerf command-line tool (explained below).
35
35
36
-
### How to check if your ARM64 CPU supports Arm SPE extension
36
+
### How do I check if my Arm CPU supports the Arm SPE extension?
37
37
38
38
#### SPE hardware support detection:
39
39
40
-
You can check if your system supports SPE or if WindowsPerf can detect SPE with `wperf test` command. See below an example of `spe_device.version_name property` value on system with SPE:
40
+
You can check if WindowsPerf detects SPE support with the `wperf test` command.
41
+
42
+
Run the command below and if the `spe_device.version_name` property shows `FEAT_SPE` it means WindowsPerf can use the SPE features.
41
43
42
44
```console
43
45
wperf test
44
46
```
45
47
48
+
Here is the output for a system with SPE support:
49
+
46
50
```output
47
51
Test Name Result
48
52
========= ======
49
53
...
50
54
spe_device.version_name FEAT_SPE
51
55
```
52
56
53
-
#### How do I know if your WindowsPerf binaries and driver support optional SPE?
57
+
#### How do I know if my WindowsPerf binaries and driver support optional SPE?
54
58
55
59
{{% notice Note %}}
56
60
Currently WindowsPerf support of SPE is in development, not all versions of WindowsPerf enable SPE support. Some WindowsPerf releases may contain separate binaries with SPE support enables.
@@ -62,26 +66,28 @@ You can check feature string `FeatureString` of both `wperf` and `wperf-driver`
62
66
wperf --version
63
67
```
64
68
69
+
The output is similar to:
70
+
65
71
```output
66
72
Component Version GitVer FeatureString
67
73
========= ======= ====== =============
68
74
wperf 3.8.0 6d15ddfc +etw-app+spe
69
75
wperf-driver 3.8.0 6d15ddfc +trace+spe
70
76
```
71
77
72
-
If `FeatureString` for both components (`wperf` and `wperf-driver`) contains `+spe`(and `spe_device.version_name` contains `FEAT_SPE`) you are good to go!
78
+
If the `FeatureString` for both `wperf` and `wperf-driver` contains `+spe`you can use the SPE features of WindowsPerf.
73
79
74
-
### Build CPython targeting ARM64
80
+
### Build CPython for ARM64
75
81
76
-
Note: all steps are done on Windows on Arm system with ARM64 CPU.
82
+
Perform the build steps below on your Windows on Arm system.
77
83
78
-
CPython is an open-source project. There is native support in CPython for Windows on Arm starting with version 3.11. In this learning path you will use a debug build of CPython. For this, you will build [CPython](https://github.com/python/cpython) locally from sources in the debug mode on an x86_64 machine and cross-compile it for an ARM64 target.
84
+
CPython is an open-source project which includes native support for Windows on Arm starting with version 3.11.
79
85
80
-
{{% notice Note %}}
81
-
Use the Visual Studio `Developer Command Prompt for VS 2022` which is already set up in the VS environment. Go to Start and search for "Developer Command Prompt for VS 2022".
82
-
{{% /notice %}}
86
+
The SPE features are demonstrated with a debug build of CPython. You can build [CPython](https://github.com/python/cpython) locally from sources in debug mode.
87
+
88
+
Open a Visual Studio `Developer Command Prompt for VS 2022` command prompt. You can find this from Windows Start by searching for "Developer Command Prompt for VS 2022".
83
89
84
-
You should see a prompt as shown below:
90
+
When you open the command prompt, you will see output similar to:
Please use `Developer Command Prompt for VS 2022`with all of the next steps.
102
+
Please use the `Developer Command Prompt for VS 2022`command prompt for the remainder of the steps.
97
103
{{% /notice %}}
98
104
99
-
---
100
-
101
-
Let's build CPython locally in debug mode using the `build.bat` script. You have the option to build CPython directly on your ARM64 machine or cross-compile it on an x64 machine. Below is an example demonstrating how to build it on an ARM64 machine.
105
+
You can build CPython locally in debug mode using the `build.bat` script using the steps below.
This step is optional, but please remember that you may encounter build issues unrelated to this example as the CPython mainline source code that you've just checked out is not stable. Therefore, we recommend that you check out SHA to avoid any unexpected issues and to ensure you are working off the same code base.
131
+
This step is optional, but you may encounter build issues unrelated to this example if the CPython mainline source code is not stable. It's best to check out a specific SHA to avoid any unexpected issues and to ensure you are working off the same code base.
126
132
{{% /notice %}}
127
133
128
-
Use a specific CPython commit to match the sampling output in this example:
134
+
Use a specific CPython commit to match the output for this example:
@@ -141,17 +147,18 @@ Note: switching to '1ff81c0cb67215694f084e51c4d35ae53b9f5cf9'.
141
147
142
148
#### Build CPython from sources
143
149
144
-
The folder `cpython\PCbuild` contains the `build.bat` script you will use to build CPython from sources. Build CPython with debug symbols by invoking the `-d` command line option and select the ARM64 target with `-p ARM64`.
150
+
The `build.bat` script builds CPython from sources. Build CPython with debug symbols by invoking the `-d` command line option and select the ARM64 target with `-p ARM64`.
145
151
146
-
{{% notice Note %}}
147
152
Make sure you are using `Developer Command Prompt for VS 2022`.
148
-
{{% /notice %}}
153
+
154
+
Change to the `PCbuild` directory and run the build command:
149
155
150
156
```console
151
157
cd PCbuild
152
158
build.bat -d -p ARM64
153
159
```
154
-
The output will be similar to:
160
+
161
+
The output is similar to:
155
162
156
163
```output
157
164
Downloading nuget...
@@ -172,26 +179,27 @@ Build succeeded.
172
179
Time Elapsed 00:00:59.50
173
180
```
174
181
175
-
{{% notice Note %}}
176
-
The folder `cpython\PCbuild\arm64` should contain all the executables built in this process. You will use `python_d.exe` in this example.
177
-
{{% /notice %}}
182
+
The folder `cpython\PCbuild\arm64` contains the executables built in this process.
183
+
184
+
You will use `python_d.exe` to run Python.
178
185
179
186
##### Execute interactive mode to make sure all the CPython dependencies and libraries are loaded
180
187
181
-
On your Windows ARM64 machine, open a command prompt and run:
188
+
Continue at the same command prompt, and test that Python runs correctly:
182
189
183
190
```console
184
-
cd c:\path\to\cpython\PCbuild\arm64
191
+
cd arm64
185
192
python_d.exe
186
193
```
187
-
You should see CPython being invoked in interactive mode:
194
+
195
+
You see CPython being invoked in interactive mode:
188
196
189
197
```output
190
198
Python 3.12.0a6+ (heads/main:1ff81c0cb6, Mar 14 2023, 16:26:50) [MSC v.1935 64 bit (ARM64)] on win32
191
199
Type "help", "copyright", "credits" or "license" for more information.
192
200
>>>
193
201
```
194
202
195
-
{{% notice Note %}}
196
-
Your environment should now be fully set up and you are ready to move on to the next step.
197
-
{{% /notice %}}
203
+
Type `quit()` to exit CPython.
204
+
205
+
Your environment s now ready to use WindowsPerf with SPE on CPython.
0 commit comments