Skip to content

Commit e36e080

Browse files
Merge pull request #1272 from jasonrandrews/review
review LLVM MCA Learning Path
2 parents c296559 + 9542c39 commit e36e080

File tree

3 files changed

+138
-50
lines changed

3 files changed

+138
-50
lines changed

content/learning-paths/laptops-and-desktops/mca-godbolt/_index.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
---
2-
title: Running MCA with Arm assembly
2+
title: Use LLVM Machine Code Analyzer to understand code performance
33

44
minutes_to_complete: 60
55

6-
who_is_this_for: This is an introductory topic for Arm developers who want to diagnose performance issues of Arm programs using MCA and Compiler Explorer.
6+
who_is_this_for: This is an introductory topic for Arm developers who want to diagnose performance issues of Arm programs using LLVM Machine Code Analyzer (MCA) and Compiler Explorer.
77

88
learning_objectives:
9-
- Estimate the hardware resource pressure and the number of cycles taken to execute your code snippet using llvm-mca
10-
- Understand how this estimate can help diagnose possible performance issues
11-
- Use Compiler Explorer to run llvm-mca
9+
- Estimate the hardware resource pressure and the number of cycles taken to execute your code snippet using llvm-mca.
10+
- Understand how this estimate can help diagnose possible performance issues.
11+
- Use Compiler Explorer to run llvm-mca.
1212

1313
prerequisites:
14-
- Familiarity with Arm assembly
15-
- clang compiler or access to Compiler Explorer
14+
- Familiarity with Arm assembly.
15+
- LLVM version 16 or newer (to include Neoverse V2 support).
1616

1717
author_primary: Rin Dobrescu
1818

1919
### Tags
2020
skilllevels: Introductory
21-
subjects: Performance
21+
subjects: Performance and Architecture
2222
armips:
2323
- Neoverse
24-
- Armv8
2524
tools_software_languages:
2625
- assembly
2726
- llvm-mca
Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
---
2-
title: Using MCA with Compiler Explorer
2+
title: Use MCA with Compiler Explorer
33
weight: 3
44
### FIXED, DO NOT MODIFY
55
layout: learningpathall
66
---
77

88
### What is Compiler Explorer?
9-
Compiler Explorer is an interactive online compiler that lets you edit code in C/C++, Java, Python and many other programming languages. It then allows you to see what the code looks like after being compiled in real time. It supports multiple compilers and has many tools available, including llvm-mca.
9+
10+
Compiler Explorer is an interactive online compiler that lets you enter 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.
11+
12+
Compiler Explorer supports multiple compilers and has many tools available, including `llvm-mca`.
1013

1114
### Running MCA in Compiler Explorer
12-
To access Compiler Explorer, open a browser and go to https://godbolt.org. This leads you to a page that looks as in Figure 1 below:
15+
16+
To access Compiler Explorer, open a browser and go to https://godbolt.org.
17+
18+
This leads you to the page shown below in Figure 1. Your view may be a slightly different.
19+
1320
![godbolt open alt-text#center](open.png "Figure 1. Compiler Explorer")
1421

15-
On the left side of the page is the source code. In Figure 1 it is set to C++, you can click on the programming language to select a different language for the source code. Now copy this code and use it as C++ source:
16-
```
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.
23+
24+
Copy the code below and paste it into Compiler Explorer as C++ source code:
25+
26+
```C
1727
int func(int a, int b, int c, int d, int e, int f) {
1828
a = a + b;
1929
a = a + c;
@@ -24,10 +34,28 @@ int func(int a, int b, int c, int d, int e, int f) {
2434
}
2535
```
2636
27-
On the right side of the page is the disassembly output from the compiler. You can change the compiler by clicking on it and selecting a different one. You can try this now and select `armv8-a clang(trunk)` as the compiler. Then add some compiler flags by typing `-O3` in the `Compiler options` box. You can view the full set of options passed to the compiler by clicking on the green tick next to the compiler. You can now add llvm-mca from the `Add tool` dropdown button, as shown in Figure 2 below:
37+
The right side of the page contains the disassembly output from the compiler.
38+
39+
You can change the compiler by clicking on it and selecting a different one.
40+
41+
Select `armv8-a clang(trunk)` as the compiler to see Arm instructions.
42+
43+
Next, update the compiler flags by typing `-O3` in the `Compiler options` box.
44+
45+
You can view the full set of options passed to the compiler by clicking on the green tick next to the compiler.
46+
47+
Click the `Add tool` dropdown button to add `llvm-mca` as a tool as shown in Figure 2 below:
48+
2849
![tool mca alt-text#center](tool-mca.png "Figure 2. Assembly in Compiler Explorer")
2950
30-
To add more flags to `llvm-mca`, click on the `Arguments` button and type them in. Specify the CPU name to `llvm-mca` by using the `-mcpu` flag. To find what CPUs are supported you can check the [clang documentation](https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-print-supported-cpus). You can try this now and add `-mcpu=neoverse-v2`, as well as any other flags you choose to pass to `llvm-mca`. On the right side of the page is the output from running `llvm-mca` on the disassembly of the source code, as shown in Figure 3 below:
51+
To add more flags to `llvm-mca`, click on the `Arguments` button and type them in.
52+
53+
Add `-mcpu=neoverse-v2`, as well as any other flags you choose to pass to `llvm-mca`.
54+
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).
56+
57+
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:
58+
3159
![argument mca alt-text#center](mca-arguments.png "Figure 3. MCA in Compiler Explorer")
3260
33-
You are now able to run `llvm-mca` using Compiler Explorer.
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.

0 commit comments

Comments
 (0)