Skip to content

Commit 74a9fc6

Browse files
committed
Updates to the MCA learning path
1 parent 4e2afe5 commit 74a9fc6

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

content/learning-paths/cross-platform/mca-godbolt/_index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ prerequisites:
1414
- Familiarity with Arm assembly.
1515
- LLVM version 16 or newer, which includes support for Neoverse V2.
1616

17-
author: Rin Dobrescu
17+
author: Asher Dobrescu
1818

1919
### Tags
2020
skilllevels: Introductory
2121
subjects: Performance and Architecture
2222
armips:
23-
- Neoverse
2423
- Cortex-A
24+
- Cortex-X
25+
- Neoverse
2526
tools_software_languages:
2627
- Assembly
2728
- llvm-mca

content/learning-paths/cross-platform/mca-godbolt/background.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ Machine Code Analyzer (MCA) is a performance analysis tool that uses information
2525

2626
### How can MCA be useful?
2727

28-
MCA takes as input a snippet of assembly code and then simulates the execution of that code in a loop of iterations, and the default is 100.
28+
MCA takes as input a snippet of assembly code and then simulates the execution of that code in a loop of iterations, and the default is 100.
2929

30-
MCA then outputs a performance report, which contains information such as the latency and throughput of the assembly block and the resource usage for each instruction.
30+
MCA then outputs a performance report, which contains information such as the latency and throughput of the assembly block and the resource usage for each instruction.
3131

3232
Using this information, you can identify bottlenecks in performance such as resource pressure and data dependencies. There are many options you can give MCA to get performance metrics. The options are explained in the [llvm-mca documentation](https://llvm.org/docs/CommandGuide/llvm-mca.html).
3333

34+
### How to acquire MCA
35+
36+
MCA is available as part of most Linux distributions, however the version tends to lag behind the current LLVM release. A recent version of MCA is also shipped as part of the Arm Toolchain for Linux (ATfL). You can find more information about ATfL and installation steps in the [ATfL user guide](https://developer.arm.com/documentation/110477/211/?lang=en). The set of cores available for performance estimation in MCA is determined by the LLVM version. You can check the version you are currently using by running `llvm-mca --version`. Using a recent version of LLVM is recommended in order to take advantage of improvements made to MCA. The most recent release can be obtained directly from LLVM, by downloading one of their [release packages](https://github.com/llvm/llvm-project/releases/). LLVM also makes nightly builds available to [download for Debian/Ubuntu](https://apt.llvm.org) based systems.

content/learning-paths/cross-platform/mca-godbolt/mca_on_godbolt.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ layout: learningpathall
77

88
### What is Compiler Explorer?
99

10-
Compiler Explorer is an interactive online compiler that is compatible with code in C/C++, Java, Python, and many other programming languages. It allows you to see what the code looks like after being compiled in real time.
10+
Compiler Explorer is an interactive online compiler that is compatible with code in C/C++, Java, Python, and many other programming languages. It allows you to see what the code looks like after being compiled in real time. This is helpful when you want to try different compiler versions without installing them.
1111

1212
Compiler Explorer supports multiple compilers and has many tools available, including `llvm-mca`.
1313

1414
### Running MCA in Compiler Explorer
1515

16-
To access Compiler Explorer, open a browser and go to https://godbolt.org.
16+
To access Compiler Explorer, open a browser and go to https://godbolt.org.
1717

18-
This leads you to the page shown below in Figure 1. Your view might be slightly different.
18+
This leads you to the page shown below in Figure 1. Your view might be slightly different.
1919

20-
![godbolt open alt-text#center](open.webp "Figure 1. Compiler Explorer")
20+
![godbolt open alt-text#center](open.png "Figure 1. Compiler Explorer")
2121

22-
The left side of the page contains the source code. In Figure 1, the language is set to C++, but you can click on the programming language to select a different language for the source code.
22+
The left side of the page contains the source code. In Figure 1, the language is set to C++, but you can click on the programming language to select a different language for the source code.
2323

2424
Copy the code below and paste it into Compiler Explorer as C++ source code:
2525

@@ -34,28 +34,28 @@ int func(int a, int b, int c, int d, int e, int f) {
3434
}
3535
```
3636
37-
The right side of the page contains the disassembly output from the compiler.
37+
The right side of the page contains the disassembly output from the compiler.
3838
39-
You can change the compiler by clicking on it and selecting a different one.
39+
You can change the compiler by clicking on it and selecting a different one.
4040
41-
Select `armv8-a clang(trunk)` as the compiler to see Arm instructions.
41+
Select `armv8-a clang(trunk)` as the compiler to see Arm instructions.
4242
43-
Next, update the compiler flags by typing `-O3` in the `Compiler options` box.
43+
Next, update the compiler flags by typing `-O3` in the `Compiler options` box.
4444
45-
You can view the full set of options passed to the compiler by clicking on the green tick next to the compiler.
45+
You can view the full set of options passed to the compiler by clicking on the green tick next to the compiler.
4646
4747
Click the `Add tool` drop-down button to add `llvm-mca` as a tool as shown in Figure 2 below:
4848
4949
![tool mca alt-text#center](tool-mca.png "Figure 2. Assembly in Compiler Explorer")
5050
51-
To add more flags to `llvm-mca`, click on the `Arguments` button and type them in.
51+
To add more flags to `llvm-mca`, click on the `Arguments` button and type them in.
5252
53-
Add `-mcpu=neoverse-v2`, as well as any other flags you choose to pass to `llvm-mca`.
53+
Add `-mcpu=neoverse-v2`, as well as any other flags you choose to pass to `llvm-mca`.
5454
55-
To find what CPUs are supported you can check the [clang documentation](https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-print-supported-cpus).
55+
To find what CPUs are supported you can check the [clang documentation](https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-print-supported-cpus).
5656
5757
The right side of the page now contains the output from running `llvm-mca` on the disassembly of the source code, as shown in Figure 3 below:
5858
5959
![argument mca alt-text#center](mca-arguments.png "Figure 3. MCA in Compiler Explorer")
6060
61-
You are now able to run `llvm-mca` using Compiler Explorer. This is helpful when you want to try different compiler versions without installing them.
61+
You are now able to run `llvm-mca` using Compiler Explorer.

content/learning-paths/cross-platform/mca-godbolt/running_mca.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ layout: learningpathall
66
---
77
### MCA example with Arm assembly
88

9-
You have learned what MCA is and what kind of information it provides. Now you are going to use MCA to identify a performance issue and improve a snippet of Arm assembly.
9+
You have learned what MCA is and what kind of information it provides. Now you are going to use MCA to identify a performance issue and improve a snippet of Arm assembly.
1010

1111
The example below demonstrates how to run `llvm-mca`, what the expected output is, and the conclusions you can draw using the performance metrics MCA provides.
1212

13-
The example below computes the sum of 6 numbers.
13+
The example below computes the sum of 6 numbers.
1414

1515
Use a text editor to save the program below in a file named `sum_test1.s`:
1616

@@ -389,8 +389,10 @@ Average Wait times (based on the timeline view):
389389
10 3.6 1.9 0.7 <total>
390390
```
391391

392-
You can see by looking at the timeline view that instructions no longer depend on each other and can execute in parallel.
392+
You can see by looking at the timeline view that instructions no longer depend on each other and can execute in parallel.
393393

394-
Instructions also spend less time waiting in the scheduler's queue. This explains why the performance of `sum_test2.s` is so much better than `sum_test1.s`.
394+
Instructions also spend less time waiting in the scheduler's queue. This explains why the performance of `sum_test2.s` is so much better than `sum_test1.s`.
395+
396+
Note the use of the flag `-mcpu=neoverse-v2` throughout all of those examples. This flag tells MCA to simulate the performance of the code in `sum_test1.s` and `sum_test2.s` on a Neoverse V2 core. This flag can be changed to any core supported in MCA. You can find what cores are supported in MCA by running `llvm-mca -mcpu=help <<<''`. You can also look at the LLVM sources in [llvm-project](https://github.com/llvm/llvm-project/tree/main/llvm/test/tools/llvm-mca/AArch64), which will give you more detailed examples. For instance, when looking at the Neoverse cores, there is currently support for the N1, N2, N3 and the V1, V2, V3 cores.
395397

396398
In the next section, you can try running `llvm-mca` with Compiler Explorer.

0 commit comments

Comments
 (0)