Skip to content

Commit 344c294

Browse files
Merge pull request #1510 from jasonrandrews/review
First review of Arm Performance Libraries on Windows Learning Path
2 parents f9661b7 + 62ee703 commit 344c294

File tree

5 files changed

+155
-115
lines changed

5 files changed

+155
-115
lines changed
Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Create your first Windows application on Microsoft Visual Studio
2+
title: Create your first Windows on Arm application using Microsoft Visual Studio
33
weight: 2
44

55
### FIXED, DO NOT MODIFY
@@ -8,79 +8,85 @@ layout: learningpathall
88

99
## Install Microsoft Visual Studio
1010

11-
Visual Studio 2022, Microsoft's Integrated Development Environment (IDE), empowers developers to build high-performance applications across a wide range of platforms. With its robust support for Arm architecture, Visual Studio 2022 opens up exciting possibilities for creating native Arm applications and optimizing existing code for Arm-based devices.
11+
Visual Studio 2022, Microsoft's Integrated Development Environment (IDE), empowers developers to build high-performance applications for the Arm architecture.
1212

13-
You can check out this Microsoft [page](https://learn.microsoft.com/en-us/visualstudio/install/visual-studio-on-arm-devices?view=vs-2022) to learn more about Visual Studio on Arm-powered devices.
13+
You can learn more about [Visual Studio on Arm-powered devices](https://learn.microsoft.com/en-us/visualstudio/install/visual-studio-on-arm-devices?view=vs-2022) from Microsoft Learn.
1414

1515
Visual Studio 2022 offers different editions tailored to various development needs:
1616
- Community: A free, fully-featured edition ideal for students, open-source contributors, and individual developers.
1717
- Professional: Offers professional developer tools, services, and subscription benefits for small teams.
1818
- Enterprise: Provides the most comprehensive set of tools and services for large teams and enterprise-level development.
1919

20-
To select the edition best suited to your requirements, compare the features of each on the Visual Studio website: https://visualstudio.microsoft.com/vs/compare/
20+
To select the best edition for you, refer to [Compare Visual Studio 2022 Editions](https://visualstudio.microsoft.com/vs/compare/).
2121

2222
{{% notice Note %}}
23-
This Learning Path documents an example using Visual Studio 2022 Community edition, you can also use advance edition as well.
23+
This Learning Path uses Visual Studio Community, but you can also use other editions.
2424
{{% /notice %}}
2525

26-
Visit Viscual Studio [Downloads](https://visualstudio.microsoft.com/downloads/) page and click the download the installer executable.
26+
Download and install Visual Studio using the [Visual Studio for Windows on Arm](/install-guides/vs-woa/) install guide. Make sure to install C and C++ support and the LLVM compiler.
2727

28-
Installation typically takes a few minutes, depending on your network speed. Double-click the downloaded installer and use the default configuration to complete the installation.
28+
## Create a sample project
2929

30-
Learn how to install C/C++ and LLVM support in this [learning path] (https://learn.arm.com/install-guides/vs-woa/).
30+
You are ready to create a sample Windows on Arm application.
3131

32-
## Create a Sample Project
32+
To keep the example clear and concise, you can create a simple console application.
3333

34-
Now, you are ready to create a sample Windows application.
34+
On the start window, click `Create a new project`.
3535

36-
To keep the example clear and concise, we will use the simplest console app here.
37-
38-
On the start window, click "Create a new project."
3936
![img1](./figures/vs_new_proj1.png)
4037

41-
In the "Create a new project" window, select "Console App" give a project name and then click "Next".
38+
In the `Create a new project` window, select `Console App`, provide a project name, such as `hello-world-1`, and then click `Next`.
39+
4240
![img2](./figures/vs_new_proj2.png)
4341

42+
After the project is created, you will see a line of `Hello, world!` code in the newly created C++ file.
4443

45-
After the project is created, you will see a line of "Hello, world" code in Program.cs.
46-
```TypeScript
47-
Console.WriteLine("Hello, World!");
44+
```C++
45+
#include <iostream>
46+
47+
int main()
48+
{
49+
std::cout << "Hello World!\n";
50+
}
4851
```
4952

50-
Microsoft Visual Studio automatically adds the build environment variable for the current hardware's CPU architecture. However, we can still familiarize ourselves with the relevant settings.
53+
Microsoft Visual Studio automatically configures the build environment for the current hardware's CPU architecture. However, you can still familiarize ourselves with the relevant settings.
54+
55+
## ARM64 Configuration Setting
5156

52-
## Arm64 Configuration Setting
57+
Click the `Debug` drop down and select `Configuration Manager...`
5358

54-
Go the "Debug" -> "Configuration Manager"
5559
![img4](./figures/vs_console_config1.png)
5660

5761

58-
In the Project contexts platform dropdown, click <New...>. In the New platform dialog box: select `ARM64`.
59-
![img5](./figures/vs_console_config2.png)
62+
In the `Project contexts` area you see the platform set to `ARM64`.
6063

64+
![img5](./figures/vs_console_config2.png)
6165

62-
{{% notice Note %}}
63-
Please reference this [learning path](https://learn.arm.com/learning-paths/laptops-and-desktops/win_wpf/how-to-2/) to find more detail about how to configure the Visual Studio platform setting.
64-
{{% /notice %}}
66+
Click `Build -> Build Solution` and your application compiles successfully.
6567

68+
## Run your first Windows on Arm application
6669

67-
Click "Build" -> "Build Solution", your first Windows will compile succesfully.
70+
Use the green arrow to run the program you just compiled, and you'll see the print statement from your code correctly executed in the console.
6871

72+
![img6](./figures/vs_console_exe.png)
6973

70-
## Run Your First Windows Application
74+
You can also use the tools provided by Visual Studio to check the compiled executable.
7175

72-
Use the green arrow to run the program you just compiled, and you'll see the statement from your code correctly executed in the console.
76+
The [dumpbin](https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-reference?view=msvc-170) command-line tool is included with Microsoft Visual Studio. It's used to analyze binary files like executable files (.exe), object files (.obj), and dynamic-link libraries (.dll).
7377

74-
![img6](./figures/vs_console_exe.png)
78+
To use `dumpbin` open a Command Prompt with Visual Studio configured by opening Windows search, and looking for `Arm64 Native Tools Command Prompt for VS 2022`. Find and open this application.
7579

76-
You can also use the tools provided by Visual Studio to check the compiled executable.
80+
A new Command Prompt opens. It's the same as the regular Windows Command Prompt with the addition that Visual Studio tools can be run from the prompt.
7781

78-
[dumpbin](https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-reference?view=msvc-170) is a command-line tool included with Microsoft Visual Studio. It's used to analyze binary files like executable files (.exe), object files (.obj), and dynamic-link libraries (.dll).
79-
In your Windows search, look for "Arm64 Native Tools Command Prompt for VS 2022" and open this program.
82+
Run the command below with the executable you crated as an argument:
8083

8184
```cmd
82-
dumpbin /headers <your exe path>\ConsoelApp1.exe
85+
dumpbin /headers <your exe path>\hello-world-1.exe
8386
```
8487

85-
You can see that the file format is for an AA64 machine.
88+
You can see that the file format shows `AA64 machine (ARM64)` in the file header.
89+
8690
![img7](./figures/vs_checkmachine.jpeg)
91+
92+
Continue to the next page to build and run a more computation intensive application.

content/learning-paths/laptops-and-desktops/windows_armpl/2-multithreading.md

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,62 @@
11
---
2-
title: Build a simple math application and profiling the performance
2+
title: Build a simple numerical application and profile the performance
33
weight: 3
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Clone Example from GitHub
9+
## Install Git for Windows on Arm
1010

11-
We use a Windows application that renders a rotating 3D cube to perform the calculations on different programming options.
11+
This section uses an example application from GitHub to demonstrate the use of Arm Performance Libraries.
1212

13-
First, clone this Windows application repository from GitHub:
13+
Start by installing Git using the [Git install guide](/install-guides/git-woa/) for Windows on Arm.
14+
15+
## Clone the example from GitHub
16+
17+
The example application renders a rotating 3D cube to perform the calculations on different programming options.
18+
19+
First, navigate to an empty directory and clone the example repository from GitHub:
1420

1521
```cmd
1622
git clone https://github.com/odincodeshen/SpinTheCubeInGDI.git
1723
```
1824

1925
{{% notice Note %}}
20-
To facilitate explaining the topic, this repository is forked from the original author [here](https://github.com/marcpems/SpinTheCubeInGDI) with some modifications to aid in the following explanations.
26+
The example repository is forked from the [original GitHub repository](https://github.com/marcpems/SpinTheCubeInGDI) and some minor modifications have been made to aid learning.
2127
{{% /notice %}}
2228

23-
## Quick Introduction
29+
## Spin the cube introduction
30+
31+
In Windows File Explorer, double-click `SpinTheCubeInGDI.sln` to open the project in Visual Studio.
2432

25-
Click the SpinTheCubeInGDI.sln to open the project.
26-
This source code implements a Windows application that renders a spinning 3D cube.
33+
The source file `SpinTheCubeInGDI.cpp` implements a spinning cube.
2734

28-
Four of key components are:
35+
The four key components are:
2936
- Shape Generation: Generates the vertices for a sphere using a golden ratio-based algorithm.
3037
- Rotation Calculation:
31-
The application uses a rotation matrix to rotate the 3D shape around the X, Y, and Z axes. The rotation angle is incremented over time, creating the animation. This code apply two options to calculate:
32-
- Multithreading: The application utilizes multithreading to improve performance by distributing the rotation calculations across multiple threads.
33-
- Arm Performance Libraries: Used for optimized calculations. (Explained in the next session)
34-
- Drawing: The application draws the transformed vertices of the shapes on the screen, using Windows API.
38+
The application uses a rotation matrix to rotate the 3D shape around the X, Y, and Z axes. The rotation angle is incremented over time, creating the animation.
39+
- Drawing: The application draws the transformed vertices of the shapes on the screen, using a Windows API.
3540
- Performance Measurement: The code measures and displays the number of transforms per second.
3641

42+
The code has two options to calculate the rotation:
43+
44+
1. Multithreading: The application utilizes multithreading to improve performance by distributing the rotation calculations across multiple threads.
45+
2. Arm Performance Libraries: The application utilizes optimized math library functions for the rotation calculations.
46+
47+
Option 1 is explained below and option 2 is explained on the next page. By trying both methods you can compare and contrast the code and the performance.
48+
49+
## Option 1: Multithreading
50+
51+
One way to speed up the rotation calculations is to use multithreading.
3752

38-
## Calculation Option#1 -- Multithreading
53+
The multithreading implementation option involves two functions:
3954

40-
In this learning path, our focus is on the impact of different Calculation option on performance.
41-
The multithreading implement on the project involved two of functions:
42-
- CalcThreadProc():
55+
- The `CalcThreadProc()` function
4356

44-
This function is the entry point for each calculation thread. Each calculation thread waits on its semaphore in semaphoreList.
57+
This function is the entry point for each calculation thread. Each calculation thread waits on its semaphore in `semaphoreList`.
4558

46-
When a thread receives a signal, it calls `applyRotation()` to transform its assigned vertices. The updated vertices are stored in the drawSphereVertecies vector
59+
When a thread receives a signal, it calls `applyRotation()` to transform its assigned vertices. The updated vertices are stored in the `drawSphereVertecies` vector. The code is shown below:
4760

4861
```c++
4962
DWORD WINAPI CalcThreadProc(LPVOID data)
@@ -70,9 +83,10 @@ The multithreading implement on the project involved two of functions:
7083
return 0;
7184
}
7285
```
73-
74-
- applyRotation():
75-
This function applies the rotation matrix to a subset of the shape's vertices.
86+
87+
- The `applyRotation()` function:
88+
89+
This function applies the rotation matrix to a subset of the shape's vertices using multiplication. The code is shown below:
7690

7791
```c++
7892
void applyRotation(std::vector<double>& shape, const std::vector<double>& rotMatrix, int startPoint, int stride)
@@ -113,23 +127,23 @@ The multithreading implement on the project involved two of functions:
113127
```
114128

115129

116-
## Build and Test
130+
## Build and run the application
131+
132+
After gaining a general understanding of the project, you can compile and run it.
133+
134+
Build the project, and run `SpinTheCubeInGDI.exe`
117135

118-
After gaining a general understanding of the project, you can compile it.
119-
Build the project, and once successful, run `SpinTheCubeInGDI.exe`.
136+
You will see a simulated 3D sphere continuously rotating.
120137

121-
You'll see a simulated 3D sphere continuously rotating. The number in the upper-left corner represents the number of frames per second (FPS). A higher number indicates better performance, and vice versa.
138+
The number in application represents the number of frames per second (FPS). A higher number indicates better performance.
122139

123140
![gif1](./figures/multithreading.gif)
124141

125-
On my test machine, the performance generally falls between 3 and 6 FPS, which is unstable.
142+
Performance varies across various Windows on Arm computers, but on the Lenovo X13s the performance generally falls between 3k and 6k FPS.
126143

127-
{{% notice Note %}}
128-
Performance may vary depending on the hardware and the system load at the time of testing.
129-
{{% /notice %}}
130144

145+
You can use the [Visual Studio profiling tools](https://learn.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour?view=vs-2022) to observe the dynamic CPU and memory usage while the program is running.
131146

132-
You can also use the [profiling tools](https://learn.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour?view=vs-2022) to observe the dynamic CPU and memory usage while the program is running.
133147
![img8](./figures/mt_cpumem_usage1.png)
134148

135-
149+
Continue to the next section to learn how to improve performance using Arm Performance Libraries.

0 commit comments

Comments
 (0)