Skip to content

Commit 75e876f

Browse files
authored
Merge pull request ArmDeveloperEcosystem#3252 from ArmDeveloperEcosystem/quantlib-learning-path
Quantlib learning path
2 parents 4add43e + 536556c commit 75e876f

7 files changed

Lines changed: 535 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Understand the QuantLib benchmark workflow on Azure Cobalt
3+
weight: 2
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## What is QuantLib?
10+
11+
QuantLib is an open-source C++ library for quantitative finance. It provides tools for pricing, modeling, trading, and risk management, and is widely used as both a development library and a representative financial computing workload.
12+
13+
Because QuantLib is a substantial C++ codebase with realistic compute behavior, it is also useful as a benchmark when evaluating cloud systems and processor architectures.
14+
15+
In this Learning Path, you will build QuantLib from source and run its benchmark executable on an Arm-based Azure Cobalt virtual machine.
16+
17+
## Why use Azure Cobalt?
18+
19+
Azure Cobalt provides Arm64 virtual machines for cloud-native development and performance evaluation. Running QuantLib on Azure Cobalt gives you a practical way to measure how a real C++ finance workload behaves on Arm-based cloud infrastructure.
20+
21+
The workflow in this Learning Path uses:
22+
23+
- Ubuntu Server 22.04 LTS
24+
- an Arm64 Azure Cobalt virtual machine
25+
- a source build of QuantLib
26+
- QuantLib's benchmark executable for repeatable performance testing
27+
28+
## What you'll do
29+
30+
This Learning Path follows a simple workflow:
31+
32+
1. Create and connect to an Arm64 Azure Cobalt virtual machine
33+
2. Install the tools needed to build QuantLib
34+
3. Download and compile QuantLib from source
35+
4. Run benchmark workloads with different problem sizes and thread counts
36+
5. Compare and record results
37+
38+
{{% notice Note %}}
39+
This Learning Path focuses on building and benchmarking QuantLib on Azure Cobalt. It is not a general introduction to quantitative finance or QuantLib development.
40+
{{% /notice %}}
41+
42+
## Benchmarking goals
43+
44+
When benchmarking a workload such as QuantLib, the goal is not just to obtain one runtime number. You want a repeatable process that lets you compare runs across system sizes, thread counts, software versions, and compiler settings.
45+
46+
For that reason, this Learning Path emphasizes:
47+
48+
- using a known VM configuration
49+
- keeping the software environment consistent
50+
- changing one benchmark variable at a time
51+
- recording commands and results so runs can be reproduced later
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
title: Set up the Azure Cobalt environment
3+
weight: 3
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Create an Arm64 Azure Cobalt virtual machine
10+
11+
To run QuantLib on Azure Cobalt, first create an Arm64 Ubuntu virtual machine in the Azure portal.
12+
13+
Use the following settings:
14+
15+
- **Virtual machine name:** `quantlib-cobalt-vm`
16+
- **Region:** a Cobalt-supported region such as **West US 2**
17+
- **Availability options:** **No infrastructure redundancy required**
18+
- **Security type:** **Standard**
19+
- **Image:** **Ubuntu Server 22.04 LTS**
20+
- **VM architecture:** **Arm64**
21+
- **Size:** **Standard_D4ps_v5**
22+
- **Authentication type:** **SSH public key**
23+
- **Username:** `azureuser`
24+
25+
For storage, a `64 GB` OS disk is sufficient for this workflow.
26+
27+
For networking, allow inbound SSH on port `22`. Restricting the source to **My IP** is recommended.
28+
29+
After creating the VM, download the generated private key in `.pem` format if Azure provides one during setup.
30+
31+
## Connect to the virtual machine
32+
33+
On your local machine, update the permissions on the private key:
34+
35+
```bash
36+
chmod 600 ~/Downloads/quantlib-cobalt-vm_key.pem
37+
```
38+
39+
Then connect using SSH:
40+
41+
```bash
42+
ssh -i ~/Downloads/quantlib-cobalt-vm_key.pem azureuser@<VM_PUBLIC_IP>
43+
```
44+
45+
Replace <VM_PUBLIC_IP> with the public IP address of your VM.
46+
47+
### (Optional) Reconnect to cobalt frequently
48+
49+
If you’ll reconnect often, add a shortcut entry to your SSH config:
50+
51+
```bash
52+
nano ~/.ssh/config
53+
```
54+
55+
Add:
56+
57+
```bash
58+
Host quantlib-cobalt
59+
HostName <VM_PUBLIC_IP>
60+
User azureuser
61+
IdentityFile ~/Downloads/quantlib-cobalt-vm_key.pem
62+
```
63+
64+
Then connect with:
65+
66+
```bash
67+
ssh quantlib-cobalt
68+
```
69+
70+
## Confirm that the system is Arm64
71+
72+
After logging in, verify the architecture:
73+
74+
```bash
75+
uname -m
76+
```
77+
78+
The expected output is:
79+
80+
```bash
81+
aarch64
82+
```
83+
84+
If you do not see aarch64, check that you created the VM with Arm64 architecture and selected an Azure Cobalt-compatible instance type.
85+
86+
## Install build dependencies
87+
88+
Update the package index and install required packages:
89+
90+
```bash
91+
sudo apt update
92+
sudo apt install -y build-essential cmake curl libboost-all-dev
93+
```
94+
95+
These packages provide the compiler toolchain, build system support, download tools, and Boost libraries needed to build QuantLib.
96+
97+
## Optional: use tmux for remote builds
98+
99+
If you want the build to continue even if your SSH session disconnects, install tmux:
100+
101+
```bash
102+
sudo apt update
103+
sudo apt install -y tmux
104+
tmux
105+
```
106+
107+
## Download QuantLib
108+
109+
Set the version and download the release archive:
110+
111+
```bash
112+
export QL_VER=1.41
113+
114+
cd ~
115+
curl -L -o QuantLib-$QL_VER.tar.gz \
116+
https://github.com/lballabio/QuantLib/releases/download/v$QL_VER/QuantLib-$QL_VER.tar.gz
117+
```
118+
119+
Check that the file exists. Run:
120+
121+
```bash
122+
ls -lh QuantLib-$QL_VER.tar.gz
123+
```
124+
125+
You should see output showing the file name and size, for example:
126+
127+
```bash
128+
-rw-r--r-- 1 azureuser azureuser 41M QuantLib-1.41.tar.gz
129+
```
130+
131+
If the file is missing or has size 0, re-run the curl command.
132+
133+
## Verify the file type
134+
135+
Use the file command to confirm that the archive is a valid gzip-compressed tar file:
136+
```bash
137+
file QuantLib-$QL_VER.tar.gz
138+
```
139+
140+
Expected output is simlar to:
141+
```bash
142+
QuantLib-1.41.tar.gz: gzip compressed data, max compression, from Unix, original size modulo 2^32 42721280
143+
```
144+
145+
### (Optional) Test archive integrity
146+
147+
To check that the archive is not corrupted, run:
148+
```bash
149+
tar -tzf QuantLib-$QL_VER.tar.gz > /dev/null
150+
```
151+
152+
If the command completes without errors, the archive is valid.
153+
154+
If you see errors such as:
155+
156+
```bash
157+
gzip: stdin: unexpected end of file
158+
tar: Unexpected EOF in archive
159+
```
160+
161+
the download is incomplete or corrupted.l Delete the file and download it again.
162+
163+
## Extract the archive
164+
165+
Once the archive is verified, extract it:
166+
```bash
167+
tar -xzf QuantLib-$QL_VER.tar.gz
168+
```
169+
170+
Then move into the extracted directory:
171+
```bash
172+
cd QuantLib-$QL_VER
173+
```
174+
175+
## Confirm the extracted contents
176+
177+
List the contents:
178+
```bash
179+
ls
180+
```
181+
182+
You should see files and directories such as:
183+
```bash
184+
configure
185+
Makefile.am
186+
ql/
187+
test-suite/
188+
```
189+
190+
This confirms that the source code has been unpacked correctly and is ready to configure and build.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
title: Build QuantLib with benchmark support
3+
weight: 4
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Configure the QuantLib build
10+
11+
From the QuantLib source directory:
12+
13+
```bash
14+
cd ~/QuantLib-$QL_VER
15+
```
16+
17+
Run the configure script:
18+
```bash
19+
./configure \
20+
--prefix=/usr/local \
21+
--enable-benchmark \
22+
--enable-parallel-unit-test-runner \
23+
CFLAGS="-g -O2 -mcpu=native" \
24+
CXXFLAGS="-g -O2 -mcpu=native"
25+
```
26+
27+
This configuration:
28+
29+
- installs QuantLib to `/usr/local`
30+
- enables the benchmark executable
31+
- enables parallel test execution
32+
- applies CPU-specific optimization flags
33+
34+
35+
## Build QuantLib
36+
37+
Compile using all available cores:
38+
39+
```bash
40+
make -j$(nproc)
41+
```
42+
43+
{{% notice Note %}}
44+
The build may take 30–45 minutes on smaller instances. Use tmux to avoid losing progress if your SSH session disconnects.
45+
{{% /notice %}}
46+
47+
## Install QuantLib
48+
49+
After the build completes:
50+
51+
```bash
52+
sudo make install
53+
sudo ldconfig
54+
```
55+
56+
## Verify the build
57+
58+
Move to the test suite:
59+
```bash
60+
cd ~/QuantLib-$QL_VER/test-suite
61+
```
62+
63+
Check that the benchmark executable exists:
64+
```bash
65+
ls quantlib-benchmark
66+
```
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Run QuantLib benchmark workloads
3+
weight: 5
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
## Run a baseline benchmark
9+
10+
After building QuantLib, move to the test suite directory:
11+
12+
```bash
13+
cd ~/QuantLib-$QL_VER/test-suite
14+
```
15+
16+
From the test suite directory, run a baseline benchmark:
17+
18+
```bash
19+
./quantlib-benchmark
20+
```
21+
22+
This confirms that the benchmark is working correctly on your system.
23+
24+
## Vary thread count
25+
26+
To understand how performance scales, run benchmarks with different numbers of threads:
27+
28+
```bash
29+
./quantlib-benchmark --size=80 --nProc=1
30+
./quantlib-benchmark --size=80 --nProc=2
31+
./quantlib-benchmark --size=80 --nProc=4
32+
```
33+
34+
These runs keep the workload size constant while changing the number of threads.
35+
36+
## Vary workload size
37+
38+
Next, vary the problem size while keeping the thread count fixed:
39+
40+
```bash
41+
./quantlib-benchmark --size=1 --nProc=1
42+
./quantlib-benchmark --size=5 --nProc=1
43+
./quantlib-benchmark --size=8 --nProc=1
44+
```
45+
46+
This shows how runtime changes as the workload increases.
47+
48+
## Choose appropriate thread counts
49+
50+
The Standard_D4ps_v5 virtual machine has a limited number of cores.
51+
52+
Start with:
53+
54+
* 1 thread
55+
* 2 threads
56+
* 4 threads
57+
58+
Using larger values can oversubscribe the system and lead to inconsistent results.
59+
60+
Your notes include larger values such as 12, 24, and 48 threads, but these are better suited for larger machines.
61+
62+
## Keep benchmark runs controlled
63+
64+
For meaningful comparisons:
65+
66+
* change one parameter at a time
67+
* keep the environment consistent
68+
* repeat runs if results vary
69+
70+
This helps ensure that differences in runtime reflect real performance changes.

0 commit comments

Comments
 (0)