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
+9-10Lines changed: 9 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,22 @@
1
1
---
2
-
title: Sampling CPython with WindowsPerf and Arm SPE
3
-
draft: true
4
-
cascade:
5
-
draft: true
2
+
title: Sample Instructions with WindowsPerf and Arm SPE
6
3
7
4
minutes_to_complete: 30
8
5
9
-
who_is_this_for: This is an introductory topic for developers keen to understand sampling with the Arm Statistical Profiling Extension (SPE).
6
+
who_is_this_for: This is an introductory topic for developers who would like to learn about sampling CPU instructions with WindowsPerf and the Arm Statistical Profiling Extension (SPE).
10
7
11
8
learning_objectives:
12
9
- Use WindowsPerf with a native Windows on Arm workload.
13
-
- Understand the basics of sampling with Arm SPE.
10
+
- Describe the basic concepts of sampling with Arm SPE.
14
11
- Explore the WindowsPerf command line.
15
-
- Build CPython from sources for Windows on Arm (ARM64).
12
+
- Build CPython from sources for Windows on Arm (AArch64).
16
13
17
14
prerequisites:
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 Windows on Arm system must have an Arm CPU with SPE support.
20
-
15
+
- A Windows on Arm desktop or development machine, with CPU support for SPE.
16
+
- An installation of [WindowsPerf](/install-guides/wperf).
17
+
- An installation of [Visual Studio](/install-guides/vs-woa/).
18
+
- An installation of [Git](/install-guides/git-woa/).
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/windowsperf_sampling_cpython_spe/_review.md
+14-66Lines changed: 14 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,88 +9,36 @@
9
9
# correct_answer: An integer indicating what answer is correct (index starts from 0)
10
10
# explanation: A short (1-3 sentence) explanation of why the correct answer is correct. Can add additional context if desired
11
11
12
-
review:
12
+
review:
13
13
- questions:
14
14
question: >
15
-
The counting model is used for obtaining aggregate counts of occurrences of special events.
15
+
The Arm Statistical Profiling Extension (SPE) is an optional feature in Armv8-A.2 hardware.
16
16
answers:
17
-
- "True"
18
-
- "False"
17
+
- "True."
18
+
- "False."
19
19
correct_answer: 1
20
20
explanation: >
21
-
In the counting model, the occurrences of PMU events are simply aggregated over a given time period.
22
-
21
+
Yes, the Arm Statistical Profiling Extension (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.
23
22
- questions:
24
23
question: >
25
-
The sampling model is used for determining the frequencies of event occurrences produced by program locations at the function, basic block, and/or instruction levels.
24
+
SPE is an acronym for Statistical Profiling Extension. True or false?
26
25
answers:
27
-
- "True"
28
-
- "False"
26
+
- "True."
27
+
- "False."
29
28
correct_answer: 1
30
29
explanation: >
31
-
In the sampling model, the frequencies of event occurrences produced by the program determine "hot" locations at the function, basic block, and/or instruction levels.
32
-
30
+
Yes, SPE is the abbreviated form of Statistical Profiling Extension.
33
31
- questions:
34
32
question: >
35
-
WindowsPerf can be used and executed only on native Windows on Arm hardware, and not in a virtual environment.
33
+
load_filter is one of SPE filters supported by WindowsPerf. True or false?
36
34
answers:
37
-
- "True"
38
-
- "False"
35
+
- "True."
36
+
- "False."
39
37
correct_answer: 1
40
38
explanation: >
41
-
Yes, WindowsPerf currently supports a native Windows on Arm environment only.
42
-
43
-
- questions:
44
-
question: >
45
-
The Arm Statistical Profiling Extension (SPE) is an optional feature in ARMv8.2 hardware.
46
-
answers:
47
-
- "True"
48
-
- "False"
49
-
correct_answer: 1
50
-
explanation: >
51
-
Yes, the Arm Statistical Profiling Extension (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.
52
-
53
-
- questions:
54
-
question: >
55
-
SPE stands for Statistical Profiling Extension.
56
-
answers:
57
-
- "True"
58
-
- "False"
59
-
correct_answer: 1
60
-
explanation: >
61
-
Yes, the Arm Statistical Profiling Extension (SPE) is an optional feature in ARMv8.2 hardware.
62
-
63
-
- questions:
64
-
question: >
65
-
load_filter is one of SPE filters supported by WindowsPerf?
66
-
answers:
67
-
- "True"
68
-
- "False"
69
-
correct_answer: 1
70
-
explanation: >
71
-
Yes, load_filter together with store_filter and branch_filter are SPE filters supported by WindowsPerf.
72
-
73
-
- questions:
74
-
question: >
75
-
store_filter is one of SPE filters supported by WindowsPerf?
76
-
answers:
77
-
- "True"
78
-
- "False"
79
-
correct_answer: 1
80
-
explanation: >
81
-
Yes, load_filter together with store_filter and branch_filter are SPE filters supported by WindowsPerf.
82
-
83
-
- questions:
84
-
question: >
85
-
branch_filter is one of SPE filters supported by WindowsPerf?
86
-
answers:
87
-
- "True"
88
-
- "False"
89
-
correct_answer: 1
90
-
explanation: >
91
-
Yes, load_filter together with store_filter and branch_filter are SPE filters supported by WindowsPerf.
92
-
39
+
Yes, load_filter, store_filter, and branch_filter are SPE filters that WindowsPerf supports.
title: Overview of Arm Statistical Profiling Extenstion
4
+
weight: 2
5
+
---
6
+
7
+
## Arm Statistical Profiling Extension (SPE)
8
+
9
+
The Arm Statistical Profiling Extension (SPE) was introduced in the Armv8.2-A architecture, and is an optional feature from Armv8.1-A.
10
+
11
+
SPE allows CPU instructions to be sampled and associated with the source code location where that instruction occurred.
12
+
13
+
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 pipelines of the CPU.
14
+
15
+
SPE provides a statistical view of the performance characteristics of executed instructions, which can be used by software writers to optimize their code for better performance.
16
+
17
+
SPE is particularly useful for performance analysis and optimization, as it provides detailed insights into the behavior of the CPU during execution.
18
+
19
+
This can help identify performance bottlenecks and optimize software for better efficiency.
20
+
21
+
## Using SPE with WindowsPerf in this Learning Path
22
+
23
+
WindowsPerf includes `record` support for the Arm Statistical Profiling Extension (SPE).
24
+
25
+
You will create a debug build of CPython from source and execute simple instructions in the Python interactive mode to obtain WindowsPerf sampling results from the CPython runtime image.
26
+
27
+
You will use the sampling to detect CPython program hot spots identified by the Arm Statistical Profiling Extension (SPE).
28
+
29
+
{{% notice Note %}}
30
+
SPE is only available on Windows on Arm in Test Mode.
31
+
Windows Test Mode is a feature that allows you to install and test drivers that have not been digitally signed by Microsoft.
WindowsPerf is a versatile performance analysis tool that offers two kinds of support:
9
+
10
+
* For software, it supports CPU PMU events.
11
+
* For hardware, it supports the SPE extension.
12
+
13
+
The type of sampling it can perform depends on the availability of the Arm Statistical Profiling Extension (SPE) in the CPU.
14
+
15
+
If the SPE extension is available, WindowsPerf can leverage hardware sampling to provide detailed performance insights. Otherwise, it relies on software sampling to gather performance data.
16
+
17
+
This flexibility ensures that WindowsPerf can adapt to different hardware configurations and consistently deliver valuable performance metrics:
18
+
19
+
* You can use `wperf sample`, which is sampling mode, for determining the frequencies of event occurrences produced by program locations at the function, basic block, and instruction levels.
20
+
21
+
* You can use `wperf record`, which is the same as sample, but also automatically spawns the process and pins it to the core specified by `-c`. You can use `record` to pass verbatim arguments to the process.
Copy file name to clipboardExpand all lines: content/learning-paths/cross-platform/windowsperf_sampling_cpython_spe/windowsperf_sampling_cpython_spe.md
+33-47Lines changed: 33 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,52 +1,38 @@
1
1
---
2
2
layout: learningpathall
3
-
title: An overview of CPython sampling with SPE
4
-
weight: 2
3
+
title: Setup
4
+
weight: 3
5
5
---
6
6
7
-
In this example, you will build a debug build of CPython from source and execute simple instructions in the Python interactive mode to obtain WindowsPerf sampling results from the CPython runtime image.
8
-
9
-
## Introduction to the Arm Statistical Profiling Extension (SPE)
10
-
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.
12
-
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.
14
-
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
-
19
-
WindowsPerf includes `record` support for the Arm Statistical Profiling Extension (SPE).
20
-
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
-
23
-
{{% notice Note %}}
24
-
SPE is only available on Windows on Arm in Test Mode.
25
-
Windows Test Mode is a feature that allows you to install and test drivers that have not been digitally signed by Microsoft.
26
-
{{% /notice %}}
27
7
28
8
## Before you begin
29
9
30
-
For this Learning Path you will need:
10
+
For this Learning Path, you will need:
31
11
32
-
* 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.
33
-
* 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.
34
-
*[Visual Studio](/install-guides/vs-woa/) and [Git](/install-guides/git-woa/) installed.
35
-
* 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 as explained below.
12
+
* A Windows on Arm (AArch64) native machine with pre-installed WindowsPerf; both the driver and `wperf` CLI tool. See the [WindowsPerf Install Guide](/install-guides/wperf/) for more details.
13
+
14
+
{{% notice Note %}}
15
+
The [WindowsPerf release 3.8.0](https://github.com/arm-developer-tools/windowsperf/releases/tag/3.8.0) includes a separate build with support for Arm SPE enabled. To install this version, download the release asset, and you will find WindowsPerf SPE build in the `SPE/` subdirectory.
### How do I check if my Arm CPU supports the Arm SPE extension?
38
22
23
+
You can check your CPU compatibility using the WindowsPerf command-line tool.
24
+
39
25
#### SPE hardware support detection:
40
26
41
27
You can check if WindowsPerf detects SPE support with the `wperf test` command.
42
28
43
-
Run the command below and if the `spe_device.version_name` property shows `FEAT_SPE` it means WindowsPerf can use the SPE features.
29
+
Run the command below and if the `spe_device.version_name` property shows `FEAT_SPE`, it means that WindowsPerf can use the SPE features.
44
30
45
31
```console
46
32
wperf test
47
33
```
48
34
49
-
Here is the output for a system with SPE support:
35
+
Here an example output for a system with SPE support:
50
36
51
37
```output
52
38
Test Name Result
@@ -55,19 +41,19 @@ Here is the output for a system with SPE support:
55
41
spe_device.version_name FEAT_SPE
56
42
```
57
43
58
-
#### How do I know if my WindowsPerf binaries and driver support optional SPE?
44
+
#### How do I check if the WindowsPerf binaries and driver support SPE?
59
45
60
46
{{% notice Note %}}
61
-
CurrentlyWindowsPerf 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.
47
+
Currently, the WindowsPerf support of SPE is in development, and not all versions of WindowsPerf enable SPE support. Some WindowsPerf releases might contain separate binaries with SPE support enabled.
62
48
{{% /notice %}}
63
49
64
-
You can check feature string `FeatureString` of both `wperf` and `wperf-driver` with `wperf --version` command:
50
+
You can check the feature string `FeatureString` of both `wperf` and `wperf-driver` with `wperf --version` command:
65
51
66
52
```console
67
53
wperf --version
68
54
```
69
55
70
-
The output is similar to:
56
+
The output should be similar to:
71
57
72
58
```output
73
59
Component Version GitVer FeatureString
@@ -76,17 +62,17 @@ The output is similar to:
76
62
wperf-driver 3.8.0 6d15ddfc +trace+spe
77
63
```
78
64
79
-
If the `FeatureString` for both `wperf` and `wperf-driver` contains `+spe` you can use the SPE features of WindowsPerf.
65
+
If the `FeatureString` for both `wperf` and `wperf-driver` contains `+spe`, the SPE features of WindowsPerf are available for you to use.
80
66
81
-
### Build CPython for ARM64
67
+
### Build CPython for AArch64
82
68
83
69
Perform the build steps below on your Windows on Arm system.
84
70
85
-
CPython is an open-source project which includes native support for Windows on Arm starting with version 3.11.
71
+
CPython is an open-source project, which includes native support for Windows on Arm starting with version 3.11.
86
72
87
-
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.
73
+
The SPE features demonstrated here use a debug build of CPython. You can build [CPython](https://github.com/python/cpython) locally from sources in debug mode.
88
74
89
-
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".
75
+
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**.
90
76
91
77
When you open the command prompt, you will see output similar to:
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.
118
+
This step is optional, but you might encounter build issues unrelated to this example if the CPython mainline source code is not stable. It is best to checkout a specific SHA to avoid any unexpected issues and to ensure you are working off the same code base.
133
119
{{% /notice %}}
134
120
135
121
Use a specific CPython commit to match the output for this example:
@@ -148,11 +134,11 @@ Note: switching to '1ff81c0cb67215694f084e51c4d35ae53b9f5cf9'.
148
134
149
135
#### Build CPython from sources
150
136
151
-
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`.
137
+
The `build.bat` script builds CPython from sources. Build CPython with debug symbols by invoking the `-d` command line option, and selecting the ARM64 target with `-p ARM64`.
152
138
153
-
Make sure you are using `Developer Command Prompt for VS 2022`.
139
+
Make sure you are using **Developer Command Prompt for VS 2022**.
154
140
155
-
Change to the `PCbuild` directory and run the build command:
141
+
Change to the `PCbuild` directory, and run the build command:
156
142
157
143
```console
158
144
cd PCbuild
@@ -193,7 +179,7 @@ cd arm64
193
179
python_d.exe
194
180
```
195
181
196
-
You see CPython being invoked in interactive mode:
182
+
You can see CPython being invoked in interactive mode:
197
183
198
184
```output
199
185
Python 3.12.0a6+ (heads/main:1ff81c0cb6, Mar 14 2023, 16:26:50) [MSC v.1935 64 bit (ARM64)] on win32
@@ -203,4 +189,4 @@ Type "help", "copyright", "credits" or "license" for more information.
203
189
204
190
Type `quit()` to exit CPython.
205
191
206
-
Your environment s now ready to use WindowsPerf with SPE on CPython.
192
+
Your environment is now ready to use WindowsPerf with SPE on CPython.
0 commit comments