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
title: Create your first Windows on Arm application using Microsoft Visual Studio
3
-
weight: 2
2
+
title: Create and Run a Windows on Arm application
3
+
weight: 3
4
4
5
5
### FIXED, DO NOT MODIFY
6
6
layout: learningpathall
7
7
---
8
+
## Create and configure a project
8
9
9
-
## Install Microsoft Visual Studio
10
+
You are now ready to create a Windows on Arm application. For your first project, you will create a simple console application.
10
11
11
-
Visual Studio 2022, Microsoft's Integrated Development Environment (IDE), empowers developers to build high-performance applications for the Arm architecture.
12
+
The next steps will guide you through how to create and configure your project.
12
13
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.
14
+
Begin by going to the **Start** window, and selecting **Create a new project**. See Figure 1.
14
15
15
-
Visual Studio 2022 offers different editions tailored to various development needs:
16
-
- Community: A free, fully-featured edition ideal for students, open-source contributors, and individual developers.
17
-
- Professional: Offers professional developer tools, services, and subscription benefits for small teams.
18
-
- Enterprise: Provides the most comprehensive set of tools and services for large teams and enterprise-level development.
16
+

19
17
20
-
To select the best edition for you, refer to [Compare Visual Studio 2022 Editions](https://visualstudio.microsoft.com/vs/compare/).
18
+
Then, in **Configure your new project**, do the following:
21
19
22
-
{{% notice Note %}}
23
-
This Learning Path uses Visual Studio Community, but you can also use other editions.
24
-
{{% /notice %}}
20
+
* Select **Console App**.
21
+
* Provide a project name, such as `ConsoleApp1`, as Figure 2 shows.
22
+
* Click **Create**.
25
23
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.
24
+

27
25
28
-
## Create a sample project
29
-
30
-
You are ready to create a sample Windows on Arm application.
31
-
32
-
To keep the example clear and concise, you can create a simple console application.
33
-
34
-
On the start window, click `Create a new project`.
35
-
36
-

37
-
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
-
40
-

41
-
42
-
After the project is created, you will see a line of `Hello, world!` code in the newly created C++ file.
26
+
After you have created the project, you will see a line of code that says `Hello, World!` in the newly-created C++ file.
43
27
44
28
```C++
45
29
#include<iostream>
@@ -50,43 +34,47 @@ int main()
50
34
}
51
35
```
52
36
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.
37
+
Whilst Microsoft Visual Studio automatically configures the build environment for the hardware of the CPU architecture, you still benefit from familiarizing yourself with the relevant configuration settings. So continue to learn more about how to get set up.
54
38
55
-
## ARM64 Configuration Setting
39
+
## ARM64 Configuration Settings
56
40
57
-
Click the `Debug` dropdown and select `Configuration Manager...`
41
+
Now click on the **Debug** drop-down menu, and select **Configuration Manager...**
Click `Build -> Build Solution` and your application compiles successfully.
50
+
Now click **Build**, then **Build Solution**, and your application will compile.
67
51
68
52
## Run your first Windows on Arm application
69
53
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.
54
+
Use the green arrow to run the program you compiled, and you will see the print statement from your code correctly executed in the console.
55
+
56
+

71
57
72
-

58
+
You can also use the tools that Visual Studio provides to check the compiled executable.
73
59
74
-
You can also use the tools provided by Visual Studio to check the compiled executable.
60
+
Visual Studio includes the command-line tool [dumpbin](https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-reference?view=msvc-170), and you can use it to analyze binary files such as:
75
61
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).
62
+
* Executable files (.exe).
63
+
* Object files (.obj).
64
+
* Dynamic-link libraries (.dll).
77
65
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.
66
+
To use `dumpbin`, open a command prompt with Visual Studio configured by opening Windows search, and then looking for `Arm64 Native Tools Command Prompt for VS 2022`. Once you have found this application, open it.
79
67
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.
68
+
A new command prompt opens. It is the same as the regular Windows command prompt, but with the added benefit that you can run Visual Studio tools.
81
69
82
-
Run the command belowwith the executable you crated as an argument:
70
+
Run the command below, replacing the text with the details of the executable that you created as an argument:
83
71
84
72
```cmd
85
73
dumpbin /headers <your exe path>\ConsoleApp1.exe
86
74
```
87
75
88
76
You can see that the file format shows `AA64 machine (ARM64)` in the file header.
89
77
90
-

78
+

91
79
92
-
Continue to the next page to build and run a more computation intensive application.
80
+
Continue to the next page to get set up with Git before you move on to build and run a more computationally-intensive application.
Visual Studio 2022 is an Integrated Development Environment (IDE) developed by Microsoft that empowers developers to build high-performance applications for the Arm architecture.
12
+
13
+
You can learn more about [Microsoft Visual Studio on Arm-powered devices](https://learn.microsoft.com/en-us/visualstudio/install/visual-studio-on-arm-devices?view=vs-2022) from the Microsoft Learn website.
14
+
15
+
There are three editions of Visual Studio 2022 that are tailored to various development needs:
16
+
- Community Edition is a free, fully-featured edition ideal for students, open source contributors, and individual developers.
17
+
- Professional Edition offers professional developer tools, services, and subscription benefits for small teams.
18
+
- Enterprise Edition provides the most comprehensive set of tools and services for large teams and enterprise-level development.
19
+
20
+
To establish which edition is best-suited to your needs, see [Compare Visual Studio 2022 Editions](https://visualstudio.microsoft.com/vs/compare/).
21
+
22
+
{{% notice Note %}}
23
+
This Learning Path uses the Community Edition of Visual Studio 2022, but you can also use other editions.
24
+
{{% /notice %}}
25
+
26
+
Download and install Visual Studio using the [Visual Studio for Windows on Arm](/install-guides/vs-woa/) install guide.
27
+
28
+
Make sure you install C and C++ support, and the LLVM compiler.
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.
27
-
{{% /notice %}}
28
-
29
-
## Spin the cube introduction
30
-
31
-
In Windows File Explorer, double-click `SpinTheCubeInGDI.sln` to open the project in Visual Studio.
32
-
33
-
The source file `SpinTheCubeInGDI.cpp` implements a spinning cube.
34
-
35
-
The four key components are:
36
-
- Shape Generation: Generates the vertices for a sphere using a golden ratio-based algorithm.
37
-
- Rotation Calculation:
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.
40
-
- Performance Measurement: The code measures and displays the number of transforms per second.
14
+
The four key components of the application are:
15
+
16
+
- Shape generation: the application generates the vertices for a sphere using a golden ratio-based algorithm.
17
+
18
+
- Rotation calculation: 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.
19
+
20
+
- Drawing: the application draws the transformed vertices of the shapes on the screen, using a Windows API.
21
+
22
+
- Performance measurement: the code measures and displays the number of transforms per second.
41
23
42
24
The code has two options to calculate the rotation:
43
25
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.
26
+
1. Multithreading: the application utilizes multithreading to improve performance by distributing the rotation calculations across multiple threads.
27
+
2. Arm Performance Libraries: the application utilizes optimized math library functions for the rotation calculations.
46
28
47
29
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
30
49
31
## Option 1: Multithreading
50
32
51
-
One way to speed up the rotation calculations is to use multithreading.
33
+
One way that you can speed up the rotation calculations is to use multithreading.
52
34
53
35
The multithreading implementation option involves two functions:
54
36
55
-
- The `CalcThreadProc()` function
37
+
- The `CalcThreadProc()` function:
56
38
57
39
This function is the entry point for each calculation thread. Each calculation thread waits on its semaphore in `semaphoreList`.
58
40
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:
41
+
When a thread receives a signal, it calls `applyRotation()` to transform its assigned vertices. The updated vertices are stored in the `drawSphereVertecies` vector.
42
+
43
+
The code is shown below:
60
44
61
45
```c++
62
46
DWORD WINAPI CalcThreadProc(LPVOID data)
@@ -76,7 +60,7 @@ The multithreading implementation option involves two functions:
@@ -106,7 +90,7 @@ The multithreading implementation option involves two functions:
106
90
{
107
91
counter++;
108
92
109
-
// take the next three values for a 3d point
93
+
// take the next three values for a 3D point
110
94
refx = *point; point++;
111
95
refy = *point; point++;
112
96
refz = *point; point++;
@@ -129,21 +113,23 @@ The multithreading implementation option involves two functions:
129
113
130
114
## Build and run the application
131
115
132
-
After gaining a general understanding of the project, you can compile and run it.
116
+
After grasping a basic understanding of the project, you can compile and run it.
133
117
134
-
Build the project, and run `SpinTheCubeInGDI.exe`
118
+
Build the project and run `SpinTheCubeInGDI.exe`.
135
119
136
120
You will see a simulated 3D sphere continuously rotating.
137
121
138
-
The number in application represents the number of frames per second (FPS). A higher number indicates better performance.
122
+
The number in the application represents the number of Frames Per Second (FPS).
123
+
124
+
A higher number indicates more frames per second, which indicates improved performance.
139
125
140
-

126
+

141
127
142
-
Performance varies across various Windows on Arm computers, but on the Lenovo X13s the performance generally falls between 3k and 6k FPS.
128
+
Performance varies across different Windows on Arm computers, but on the Lenovo X13s specifically, the performance generally falls between 3K and 6K FPS.
143
129
144
130
145
131
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.
146
132
147
-

133
+

148
134
149
-
Continue to the next section to learn how to improve performance using Arm Performance Libraries.
135
+
Continue learning to find out how you can optimize performance using Arm Performance Libraries.
The repository containing the example is forked from the [original GitHub repository for Spin the Cube](https://github.com/marcpems/SpinTheCubeInGDI) with some modifications for demonstration purposes.
0 commit comments