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/laptops-and-desktops/mca-godbolt/_index.md
+8-9Lines changed: 8 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,26 @@
1
1
---
2
-
title: Running MCA with Arm assembly
2
+
title: Use LLVM Machine Code Analyzer to understand code performance
3
3
4
4
minutes_to_complete: 60
5
5
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.
7
7
8
8
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.
12
12
13
13
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).
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`.
10
13
11
14
### 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
+
13
20

14
21
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
17
27
intfunc(int a, int b, int c, int d, int e, int f) {
18
28
a = a + b;
19
29
a = a + c;
@@ -24,10 +34,28 @@ int func(int a, int b, int c, int d, int e, int f) {
24
34
}
25
35
```
26
36
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
+
28
49

29
50
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
+
31
59

32
60
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